 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package eval is the beginning of an interpreter for Go. It can run simple Go programs but does not implement interface values or packages.
Index ¶
- Variables
- func FuncFromNativeTyped(fn func(*Thread, []Value, []Value), t interface{}) (*FuncType, FuncValue)
- type ArrayType
- type ArrayValue
- type BoolValue
- type BoundedType
- type Code
- type Constant
- type Def
- type DivByZeroError
- type FloatValue
- type Frame
- type Func
- type FuncDecl
- type FuncType
- type FuncValue
- type IMethod
- type IdealFloatValue
- type IdealIntValue
- type IndexError
- type IntValue
- type Interface
- type InterfaceType
- type InterfaceValue
- type KeyError
- type Map
- type MapType
- type MapValue
- type Method
- type MultiType
- type NamedType
- type NegativeCapacityError
- type NegativeLengthError
- type NilPointerError
- type PackageValue
- type PkgIdent
- type PtrType
- type PtrValue
- type RedefinitionError
- type Scope
- func (b Scope) ChildScope() *Scope
- func (b Scope) DefineConst(name string, pos token.Pos, t Type, v Value) (*Constant, Def)
- func (b Scope) DefinePackage(id, path string, pos token.Pos) (*PkgIdent, Def)
- func (b Scope) DefineTemp(t Type) *Variable
- func (b Scope) DefineType(name string, pos token.Pos, t Type) Type
- func (b Scope) DefineVar(name string, pos token.Pos, t Type) (*Variable, Def)
- func (b Scope) Lookup(name string) (bl *block, level int, def Def)
- func (s *Scope) NewFrame(outer *Frame) *Frame
 
- type Slice
- type SliceError
- type SliceType
- type SliceValue
- type StringValue
- type StructField
- type StructType
- type StructValue
- type Thread
- type Type
- type UintValue
- type Value
- type Variable
- type World
- func (w *World) Compile(fset *token.FileSet, text string) (Code, error)
- func (w *World) CompileDeclList(fset *token.FileSet, decls []ast.Decl) (Code, error)
- func (w *World) CompileExpr(fset *token.FileSet, e ast.Expr) (Code, error)
- func (w *World) CompilePackage(fset *token.FileSet, files []*ast.File, pkgpath string) (Code, error)
- func (w *World) CompileStmtList(fset *token.FileSet, stmts []ast.Stmt) (Code, error)
- func (w *World) DefineConst(name string, t Type, val Value) error
- func (w *World) DefineVar(name string, t Type, val Value) error
 
Constants ¶
This section is empty.
Variables ¶
var ( Uint8Type = universe.DefineType("uint8", universePos, &uintType{commonType{}, 8, false, "uint8"}) Uint16Type = universe.DefineType("uint16", universePos, &uintType{commonType{}, 16, false, "uint16"}) Uint32Type = universe.DefineType("uint32", universePos, &uintType{commonType{}, 32, false, "uint32"}) Uint64Type = universe.DefineType("uint64", universePos, &uintType{commonType{}, 64, false, "uint64"}) UintType = universe.DefineType("uint", universePos, &uintType{commonType{}, 0, false, "uint"}) UintptrType = universe.DefineType("uintptr", universePos, &uintType{commonType{}, 0, true, "uintptr"}) )
var ( Int8Type = universe.DefineType("int8", universePos, &intType{commonType{}, 8, "int8"}) Int16Type = universe.DefineType("int16", universePos, &intType{commonType{}, 16, "int16"}) Int32Type = universe.DefineType("int32", universePos, &intType{commonType{}, 32, "int32"}) Int64Type = universe.DefineType("int64", universePos, &intType{commonType{}, 64, "int64"}) IntType = universe.DefineType("int", universePos, &intType{commonType{}, 0, "int"}) )
var ( Float32Type = universe.DefineType("float32", universePos, &floatType{commonType{}, 32, "float32"}) Float64Type = universe.DefineType("float64", universePos, &floatType{commonType{}, 64, "float64"}) )
var BoolType = universe.DefineType("bool", universePos, &boolType{})
    var StringType = universe.DefineType("string", universePos, &stringType{})
    Functions ¶
func FuncFromNativeTyped ¶
FuncFromNativeTyped is like FuncFromNative, but constructs the function type from a function pointer using reflection. Typically, the type will be given as a nil pointer to a function with the desired signature.
Types ¶
type ArrayType ¶
type ArrayValue ¶
type ArrayValue interface {
	Value
	// TODO(austin) Get() is here for uniformity, but is
	// completely useless.  If a lot of other types have similarly
	// useless Get methods, just special-case these uses.
	Get(*Thread) ArrayValue
	Elem(*Thread, int64) Value
	// Sub returns an ArrayValue backed by the same array that
	// starts from element i and has length len.
	Sub(i int64, len int64) ArrayValue
}
    type Code ¶
type Constant ¶
type Def ¶
A definition can be a *Variable, *Constant, or Type.
type DivByZeroError ¶
type DivByZeroError struct{}
    func (DivByZeroError) Error ¶
func (DivByZeroError) Error() string
type Frame ¶
type FuncDecl ¶
type FuncType ¶
type FuncValue ¶
func FuncFromNative ¶
FuncFromNative creates an interpreter function from a native function that takes its in and out arguments as slices of interpreter Value's. While somewhat inconvenient, this avoids value marshalling.
type IdealIntValue ¶
TODO(austin) IdealIntValue and IdealFloatValue should not exist because ideals are not l-values.
type IndexError ¶
type IndexError struct {
	Idx, Len int64
}
    func (IndexError) Error ¶
func (e IndexError) Error() string
type InterfaceType ¶
type InterfaceType struct {
	// contains filtered or unexported fields
}
    func NewInterfaceType ¶
func NewInterfaceType(methods []IMethod, embeds []*InterfaceType) *InterfaceType
func (*InterfaceType) String ¶
func (t *InterfaceType) String() string
func (*InterfaceType) Zero ¶
func (t *InterfaceType) Zero() Value
type InterfaceValue ¶
type KeyError ¶
type KeyError struct {
	Key interface{}
}
    type Map ¶
type Map interface {
	Len(*Thread) int64
	// Retrieve an element from the map, returning nil if it does
	// not exist.
	Elem(t *Thread, key interface{}) Value
	// Set an entry in the map.  If val is nil, delete the entry.
	SetElem(t *Thread, key interface{}, val Value)
	// TODO(austin)  Perhaps there should be an iterator interface instead.
	Iter(func(key interface{}, val Value) bool)
}
    type MapType ¶
type Method ¶
type Method struct {
	// contains filtered or unexported fields
}
    type MultiType ¶
type MultiType struct {
	Elems []Type
	// contains filtered or unexported fields
}
    MultiType is a special type used for multi-valued expressions, akin to a tuple type. It's not generally accessible within the language.
type NamedType ¶
type NamedType struct {
	NamePos token.Pos
	Name    string
	// Underlying type.  If incomplete is true, this will be nil.
	// If incomplete is false and this is still nil, then this is
	// a placeholder type representing an error.
	Def Type
	// contains filtered or unexported fields
}
    func NewNamedType ¶
TODO(austin) This is temporarily needed by the debugger's remote type parser. This should only be possible with block.DefineType.
type NegativeCapacityError ¶
type NegativeCapacityError struct {
	Len int64
}
    func (NegativeCapacityError) Error ¶
func (e NegativeCapacityError) Error() string
type NegativeLengthError ¶
type NegativeLengthError struct {
	Len int64
}
    func (NegativeLengthError) Error ¶
func (e NegativeLengthError) Error() string
type NilPointerError ¶
type NilPointerError struct{}
    func (NilPointerError) Error ¶
func (NilPointerError) Error() string
type PackageValue ¶
type PkgIdent ¶
type RedefinitionError ¶
func (*RedefinitionError) Error ¶
func (e *RedefinitionError) Error() string
type Scope ¶
type Scope struct {
	// contains filtered or unexported fields
}
    A Scope is the compile-time analogue of a Frame, which captures some subtree of blocks.
func (Scope) DefineConst ¶
func (Scope) DefinePackage ¶
func (Scope) DefineVar ¶
type Slice ¶
type Slice struct {
	Base     ArrayValue
	Len, Cap int64
}
    type SliceError ¶
type SliceError struct {
	Lo, Hi, Cap int64
}
    func (SliceError) Error ¶
func (e SliceError) Error() string
type StructType ¶
type StructType struct {
	Elems []StructField
	// contains filtered or unexported fields
}
    func NewStructType ¶
func NewStructType(fields []StructField) *StructType
func (*StructType) String ¶
func (t *StructType) String() string
func (*StructType) Zero ¶
func (t *StructType) Zero() Value
type StructValue ¶
type Thread ¶
type Thread struct {
	// contains filtered or unexported fields
}
    func (*Thread) Abort ¶
Abort aborts the thread's current computation, causing the innermost Try to return err.
type Type ¶
type Type interface {
	// Zero returns a new zero value of this type.
	Zero() Value
	// String returns the string representation of this type.
	String() string
	// contains filtered or unexported methods
}
    var EmptyType Type = NewMultiType([]Type{})
    var IdealFloatType Type = &idealFloatType{}
    var IdealIntType Type = &idealIntType{}
    func TypeFromNative ¶
TypeFromNative converts a regular Go type into a the corresponding interpreter Type.
type Value ¶
type Variable ¶
type Variable struct {
	VarPos token.Pos
	// Index of this variable in the Frame structure
	Index int
	// Static type of this variable
	Type Type
	// Value of this variable.  This is only used by Scope.NewFrame;
	// therefore, it is useful for global scopes but cannot be used
	// in function scopes.
	Init Value
}
    
       Source Files
      ¶
      Source Files
      ¶
    
- abort.go
- bridge.go
- compiler.go
- expr.go
- expr1.go
- func.go
- scope.go
- stmt.go
- type.go
- typec.go
- value.go
- world.go