Documentation
¶
Overview ¶
Package transpiler implements a source-to-source compiler for translating Gno code into Go code.
Index ¶
Constants ¶
const ImportPrefix = "github.com/gnolang/gno"
ImportPrefix is the import path to the root of the gno repository, which should be used to create go import paths.
Variables ¶
This section is empty.
Functions ¶
func PackageDirLocation ¶
PackageDirLocation provides the supposed directory of the package, relative to the root dir.
TODO(morgan): move out, this should go in a "resolver" package.
func TranspileImportPath ¶
TranspileImportPath takes an import path s, and converts it into the full import path relative to the Gno repository.
func TranspiledFilenameAndTags ¶
TranspiledFilenameAndTags returns the filename and tags for transpiled files.
Types ¶
type ImportResolver ¶
ImportResolver maps a Gno import path to its location relative to the gno repo root. ok=false means the import is unresolvable.
func DefaultResolver ¶
func DefaultResolver(rootDir string) ImportResolver
DefaultResolver returns "examples/<path>" for non-stdlibs and "gnovm/stdlibs/<path>" for stdlibs. When rootDir is non-empty it also checks the resolved path exists on disk.
type Result ¶
type Result struct {
Imports []*ast.ImportSpec
Translated string
File *ast.File
}
Result is returned by Transpile, returning the file's imports and output out the transpilation.
func Transpile ¶
Transpile performs transpilation on the given source code. tags can be used to specify build tags; filename helps generate useful error messages and discriminate between test and normal source files. Equivalent to TranspileWithResolver with a nil resolver.
func TranspileWithResolver ¶
func TranspileWithResolver(source, tags, filename string, resolver ImportResolver) (*Result, error)
TranspileWithResolver is like Transpile but uses the supplied resolver for import lookups. A nil resolver falls back to DefaultResolver.