Documentation
¶
Overview ¶
Package interp is the dev interpreter (REQ-DEV-02, REQ-DEV-05). It runs the Go code that the compiler generates for a .gx file, with reflection, against a table of the symbols that the running app was built with. The compiled path and the interpreted path then run the same statements and call the same functions, so the two render the same bytes.
The interpreter covers a measured part of Go (DR-03): what the code generator writes, and the common expressions of a template. Compile refuses a file that uses more, and the dev server then rebuilds the app.
Only a build with the gxdev tag links this package (SI-08).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Float ¶
Float makes a float constant from a literal or from an exact fraction "a/b". A constant such as 1.0 / 3 has no exact decimal form, and Go keeps it exact until a use gives it a type.
func Int ¶
Int, Float, String and Bool make the untyped constants of a generated symbol table from their Go text.
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File is one compiled source file: its functions by name.
func Compile ¶
Compile parses the Go source of one file of the package with the import path pkgPath and prepares its functions. It resolves each name against the table and returns an *Unsupported error for code that the interpreter does not cover.
type Func ¶
type Func struct {
// contains filtered or unexported fields
}
Func is one interpreted function.
func (*Func) Call ¶
Call runs the function. The arguments must have the parameter types. A panic of the code is a panic of Call, as it is in compiled code.
type Package ¶
type Package struct {
// Path is the import path and Name is the package name.
Path string
Name string
// Values holds the functions, the variables and the typed constants.
// A variable is an addressable value, so the interpreter reads its
// current value and can assign to it.
Values map[string]reflect.Value
// Consts holds the untyped constants.
Consts map[string]constant.Value
// Types holds the named types.
Types map[string]reflect.Type
// Methods holds a function for each method that reflection cannot
// call: an unexported method. The key is "Type.method", or
// "*Type.method" for a pointer receiver. The function takes the
// receiver as its first argument.
Methods map[string]reflect.Value
}
Package is the symbols of one Go package, as the generated symbol table of an app lists them (REQ-DEV-04).
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table is the symbol table of an app: its packages by import path.
type Unsupported ¶
Unsupported is the error of Compile for code outside the part of Go that the interpreter covers, or for a name that the table does not hold. The dev server takes the rebuild path for it.
func (*Unsupported) Error ¶
func (e *Unsupported) Error() string
Directories
¶
| Path | Synopsis |
|---|---|
|
Package interptest holds Go functions that the interpreter tests run two times: as compiled code and as interpreted code.
|
Package interptest holds Go functions that the interpreter tests run two times: as compiled code and as interpreted code. |