transpiler

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

Package transpiler implements a source-to-source compiler for translating Gno code into Go code.

Index

Constants

View Source
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

func PackageDirLocation(s string) string

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

func TranspileImportPath(s string) string

TranspileImportPath takes an import path s, and converts it into the full import path relative to the Gno repository.

func TranspiledFilenameAndTags

func TranspiledFilenameAndTags(gnoFilePath string) (targetFilename, tags string)

TranspiledFilenameAndTags returns the filename and tags for transpiled files.

Types

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

func Transpile(source, tags, filename string) (*Result, error)

Transpile performs transpilation on the given source code. tags can be used to specify build tags; and filename helps generate useful error messages and discriminate between test and normal source files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL