Documentation ¶
Index ¶
- Constants
- func ErrFormat(path string, line, pos int, message string) string
- func IsVariadic(obj IObject) bool
- func RandName() string
- type Array
- type AssignAnyFunc
- type AssignFloatFunc
- type AssignIntFunc
- type AssignStrFunc
- type Bcode
- type Buffer
- type Bytecode
- type CmdAnyFunc
- type CmdBinary
- type CmdBlock
- type CmdCommand
- type CmdCommon
- type CmdConst
- type CmdRet
- type CmdType
- type CmdUnary
- type CmdValue
- type CmdVar
- type CodePos
- type ConstObject
- func (constObj *ConstObject) GetCode() *Bytecode
- func (constObj *ConstObject) GetLex() *Lex
- func (constObj *ConstObject) GetName() string
- func (constObj *ConstObject) GetParams() []*TypeObject
- func (constObj *ConstObject) GetType() ObjectType
- func (constObj *ConstObject) GetUnitIndex() uint32
- func (constObj *ConstObject) Result() *TypeObject
- func (constObj *ConstObject) SetPub()
- type Embed
- type EmbedObject
- func (embedObj *EmbedObject) GetCode() *Bytecode
- func (embedObj *EmbedObject) GetLex() *Lex
- func (embedObj *EmbedObject) GetName() string
- func (embedObj *EmbedObject) GetParams() []*TypeObject
- func (embedObj *EmbedObject) GetType() ObjectType
- func (embedObj *EmbedObject) GetUnitIndex() uint32
- func (embedObj *EmbedObject) Result() *TypeObject
- func (embedObj *EmbedObject) SetPub()
- type Exec
- type File
- type Fn
- type FnType
- type FuncObject
- func (funcObj *FuncObject) GetCode() *Bytecode
- func (funcObj *FuncObject) GetLex() *Lex
- func (funcObj *FuncObject) GetName() string
- func (funcObj *FuncObject) GetParams() []*TypeObject
- func (funcObj *FuncObject) GetType() ObjectType
- func (funcObj *FuncObject) GetUnitIndex() uint32
- func (funcObj *FuncObject) Result() *TypeObject
- func (funcObj *FuncObject) SetPub()
- type ICmd
- type IObject
- type Indexer
- type KeyValue
- type Lex
- type Local
- type Map
- type Obj
- type Object
- type ObjectType
- type Range
- type RuntimeError
- type Set
- type Struct
- type StructInfo
- type StructType
- type Token
- type TraceInfo
- type TypeObject
- func (typeObj *TypeObject) GetCode() *Bytecode
- func (typeObj *TypeObject) GetLex() *Lex
- func (typeObj *TypeObject) GetName() (ret string)
- func (typeObj *TypeObject) GetParams() []*TypeObject
- func (typeObj *TypeObject) GetType() ObjectType
- func (typeObj *TypeObject) GetUnitIndex() uint32
- func (typeObj *TypeObject) Result() *TypeObject
- func (typeObj *TypeObject) SetPub()
- type Unit
- func (unit *Unit) AddConst(name string)
- func (unit *Unit) AddFunc(ind int, obj IObject, pub bool)
- func (unit *Unit) FindConst(name string) IObject
- func (unit *Unit) FindFunc(name string, params []*TypeObject) (IObject, bool)
- func (unit *Unit) FindObj(fullName string) IObject
- func (unit *Unit) FindType(name string) IObject
- func (unit *Unit) GetHeader(name string) string
- func (unit *Unit) GetObj(ind uint32) IObject
- func (unit *Unit) ImportEmbed(embed Embed)
- func (unit *Unit) NameToType(name string) IObject
- func (unit *Unit) NewConst(name string, value interface{}, redefined bool) int32
- func (unit *Unit) NewObject(obj IObject) IObject
- func (unit *Unit) NewType(name string, original reflect.Type, indexOf IObject) IObject
- func (unit *Unit) TypeByGoType(goType reflect.Type) *TypeObject
- type Workspace
Constants ¶
const ( TYPENONE = 0 TYPEINT = 0x011 TYPEBOOL = 0x021 TYPECHAR = 0x031 TYPESTR = 0x042 TYPEFLOAT = 0x053 TYPEARR = 0x014 TYPERANGE = 0x024 TYPEMAP = 0x034 TYPEBUF = 0x044 TYPEFUNC = 0x054 TYPEERROR = 0x064 TYPESET = 0x074 TYPEOBJ = 0x084 TYPEFILE = 0x094 TYPEHANDLE = 0x0A4 TYPESTRUCT = 0x104 BlBreak = 0x0001 BlContinue = 0x0002 BlVars = 0x0004 BlPars = 0x0008 BlTry = 0x0010 BlRecover = 0x0020 BlRetry = 0x0040 )
const ( STACKNONE = iota STACKINT STACKSTR STACKFLOAT STACKANY )
const ( NOP = iota PUSH32 // + int32 PUSH64 // + int64 PUSHFLOAT // + float64 PUSHSTR // & (strid << 16 ) PUSHFUNC // + id func ADD // int + int SUB // int - int MUL // int * int DIV // int / int MOD // int % int 10 BITOR // int | int BITXOR // int ^ int BITAND // int & int LSHIFT // int << int RSHIFT // int >> int BITNOT // ^int SIGN // -int EQ // int == int LT // int < int GT // int > int 20 NOT // logical not 1 => 0, 0 => 1 ADDFLOAT // float + float SUBFLOAT // float - float MULFLOAT // float * float DIVFLOAT // float / float SIGNFLOAT // -float EQFLOAT // float == float LTFLOAT // float < float GTFLOAT // float > float ADDSTR // str + str 30 EQSTR // str == str LTSTR // str < str GTSTR // str > str GETVAR // & (block shift<<16) + int16 type + int16 index SETVAR // & (block shift<<16) + int16 type + int16 index + int16 index count + int16 assign DUP // & (type<<16) duplicate top POP // & (type<<16) pop top CYCLE // cycle counter JMP // + int32 jump JZE // + int32 jump if the top value is zero 40 JNZ // + int32 jump if the top value is not zero JEQ // & (type<<16) + int32 jump if equals for case statement JMPOPT // & (idvar<<16) jump if defined INITVARS // & (flags<<16) initializing variables + offset break + offset continue + // parcount<<16 | var count + DELVARS // delete variables OPTPARS // & (count << 16) + {type<<16 | idvar} INITOBJ // & (count<<16) create a new object + int16 type +int16 type item RANGE // create range ARRAY // &(count<<16) create array + int32 types LEN // & (type<<16) length 50 FORINC // & (index<<16) increment counter BREAK // break CONTINUE // continue RECOVER // recover RETRY // retry RET // & (type<<16) return from function END // end of the function CONSTBYID // + int32 id of the object CALLBYID // & (par count<<16) + int32 id of the object GOBYID // & (par count<<16) + int32 id of the object new thread + int32 type of pars 60 EMBED // & (embed id << 16) calls embedded func + int32 count for variadic funcs // + [variadic types] LOCAL // & (par count << 16)+ int32 offset CATCH IOTA // & (iota<<16) INDEX // & (int32 count) + {(type input<<16) + result type} ASSIGNPTR // & (int16 type << 16) ASSIGN // & (int16 type << 16) ASSIGNADD // int += int & (int16 type << 16) str += str ASSIGNSUB // int -= int ASSIGNMUL // int *= int ASSIGNDIV // int /= int ASSIGNMOD // int %= int ASSIGNBITOR // int |= int ASSIGNBITXOR // int ^= int ASSIGNBITAND // int &= int ASSIGNLSHIFT // int <<= int ASSIGNRSHIFT // int >>= int INCDEC EMBEDFUNC )
const ( ConstIotaID = iota ConstDepthID ConstCycleID ConstScriptID )
const ( // ConstDepth is the name of the max depth of calling functions ConstDepth = `DEPTH` // ConstCycle is the name of the max count of cycle ConstCycle = `CYCLE` // ConstIota is the name of iota for constants ConstIota = `IOTA` // ConstScript is the script path ConstScript = `SCRIPT` // ConstVersion is the version of Gentee compiler ConstVersion = `VERSION` ConstRecursive = `RECURSIVE` ConstOnlyFiles = `ONLYFILES` ConstOnlyDirs = `ONLYDIRS` ConstRegExp = `REGEXP` ConstCreate = `CREATE` ConstTrunc = `TRUNC` ConstReadonly = `READONLY` // NotIota means that constant doesn't use IOTA NotIota = -1 // Version is the current version of the compiler Version = `1.22.0` )
const ( // RcBreak means break command RcBreak = 1 + iota // RcContinue means continue command RcContinue // RcLocal means that a local function returns a value RcLocal // RcRecover means recover command RcRecover // RcRetry means retry command RcRetry )
const ( // StackBlock executes function StackBlock = 1 + iota // StackReturn returns values from the function StackReturn // StackIf is the condition statement StackIf // StackWhile is the while statement StackWhile // StackSwitch is the switch statement StackSwitch // StackCase is the case statement StackCase // StackDefault is the default statement of switch StackDefault // StackAssign is an assign operator StackAssign // StackAnd is a logical AND StackAnd // StackOr is a logical OR StackOr // StackQuestion is ?(condition, exp1, exp2) StackQuestion // StackIncDec is ++ -- StackIncDec // StackFor is the for statement StackFor // StackInit inits array and map variables StackInit // StackInitPtr inits array and map variables StackInitPtr // StackNew creates a new array or map StackNew // StackOptional is used for initialization of optional variables StackOptional // StackLocal means local function StackLocal // StackCallLocal means calling local function StackCallLocal // StackLocret returns value from local function StackLocret // StackTry is the try statement StackTry // StackCatch is the try statement StackCatch )
const ( // DefAssignAddArr appends the array to array DefAssignAddArr = `AssignAddºArr` // DefAssignAddArrArr appends the array to array DefAssignAddArrArr = `AssignAddºArrArr` // DefAssignAddMap appends the map to array DefAssignAddMap = `AssignAddºArrMap` // DefAssignArr assigns one array to another DefAssignArr = `AssignºArrArr` // DefAssignMap assigns one map to another DefAssignMap = `AssignºMapMap` // DefLenArr returns the length of the array DefLenArr = `LenºArr` // DefLenMap returns the length of the map DefLenMap = `LenºMap` // DefAssignIntInt equals int = int DefAssignIntInt = `#Assign#int#int` // DefAssignStructStruct equals struct = struct DefAssignStructStruct = `AssignºStructStruct` // DefAssignBitAndStructStruct equals struct &= struct DefAssignBitAndStructStruct = `AssignBitAndºStructStruct` // DefAssignFnFn equals fn = fn DefAssignFnFn = `AssignºFnFn` // DefAssignFileFile equals file = file DefAssignFileFile = `AssignºFileFile` // DefAssignHandleHandle equals handle = handle DefAssignHandleHandle = `AssignºHandleHandle` // DefAssignBitAndArrArr equals arr &= arr DefAssignBitAndArrArr = `AssignBitAndºArrArr` // DefAssignBitAndMapMap equals map &= map DefAssignBitAndMapMap = `AssignBitAndºMapMap` // DefNewKeyValue returns a pair of key value DefNewKeyValue = `NewKeyValue` // DefGetEnv returns an environment variable DefGetEnv = `GetEnv` )
const ( // ErrRunIndex is returned when Run has been executed with wrong index ErrRunIndex = iota + 1 // ErrDepth is returned when maximum depth of recursion has been reached ErrDepth // ErrDivZero is returned when there is division by zero ErrDivZero // ErrCycle is returned when maximum cycle count has been reached ErrCycle // ErrShift is returned when << or >> are used with the negative right operand ErrShift // ErrStrToInt is returned when the conversion string to integer is invalid ErrStrToInt // ErrStrToFloat is returned when the conversion string to float is invalid ErrStrToFloat // ErrEmptyCommand is returned if empty command is specified in $ ErrEmptyCommand // ErrQuoteCommand is returned if there is an unclosed quotation mark in $ command ErrQuoteCommand // ErrIndexOut means that int index is out of the length of the array ErrIndexOut // ErrMapIndex is returned when there is not the key in the map ErrMapIndex // ErrAssignment is returned when there is a recursive assignment ErrAssignment // ErrUndefined means that the value of the variable is undefined ErrUndefined // ErrByteOut is returned when value for buf is greater 255 ErrByteOut // ErrInvalidParam is returned when the function gets invalid parameter(s) ErrInvalidParam // ErrNotRun is returned when the executing unit doesn't have run function ErrNotRun // ErrFnEmpty is returned in case of calling undefined fn variable ErrFnEmpty // ErrThreadIndex is returned when the index of the thread is out of range ErrThreadIndex // ErrThreadClosed is generated when the thread has been closed ErrThreadClosed // ErrPlatform is generated when the function is not supported on the current platform ErrPlatform // ErrObjValue is returned when obj has wrong type ErrObjValue // ErrEmbedded means golang error in embedded functions ErrEmbedded = 254 // ErrRuntime error. It means bug ErrRuntime = 255 )
const ( // NSImported means imported object in NameSpace NSImported = 0x10000000 // NSPub means public object in NameSpace NSPub = 0x20000000 NSIndex = 0x0fffffff )
Prefixes
const ( // DefName is the key name for stdlib DefName = `stdlib` // PubOne means the only next object is public PubOne = 1 // PubAll means all objects are public PubAll = 2 )
const ( // MaxSet is the maximum size of the set MaxSet = int64(64000000) )
const (
// Undefined index
Undefined = -1
)
Variables ¶
This section is empty.
Functions ¶
func IsVariadic ¶
IsVariadic returns true if th efunction is variadic
Types ¶
type Array ¶
type Array struct {
Data []interface{}
}
Array is an array
type AssignAnyFunc ¶ added in v1.6.0
type AssignAnyFunc func(interface{}, interface{}) (interface{}, error)
type AssignFloatFunc ¶ added in v1.6.0
type AssignStrFunc ¶ added in v1.6.0
type Buffer ¶
type Buffer struct {
Data []byte
}
Buffer is []byte
type Bytecode ¶ added in v1.5.0
type Bytecode struct { Code []Bcode Used map[int32]byte // identifier of used objects Init []int32 // offsets of init funcs Strings map[string]uint16 StrOffset []int32 // offsets of PUSHSTR Structs map[string]uint16 StructsList []StructInfo StructsOffset []int32 // offsets of struct types Locals []Local BlockFlags int16 Pos []CodePos }
Bytecode contains bytecode information
type CmdAnyFunc ¶
type CmdAnyFunc struct { CmdCommon Object IObject Result *TypeObject Children []ICmd FnVar ICmd Optional []int // indexes of optional variables IsThread bool }
CmdAnyFunc calls a function with more than 2 parameters
func (*CmdAnyFunc) GetResult ¶
func (cmd *CmdAnyFunc) GetResult() *TypeObject
GetResult returns the type of the result
func (*CmdAnyFunc) GetToken ¶
func (cmd *CmdAnyFunc) GetToken() int
GetToken returns the index of the token
type CmdBinary ¶
type CmdBinary struct { CmdCommon Object IObject Result *TypeObject Left ICmd Right ICmd }
CmdBinary calls a binary function
func (*CmdBinary) GetResult ¶
func (cmd *CmdBinary) GetResult() *TypeObject
GetResult returns the type of the result
type CmdBlock ¶
type CmdBlock struct { CmdCommon Parent *CmdBlock Object IObject ID uint32 // cmdType Vars []*TypeObject ParCount int // the count of parameters Variadic bool VarNames map[string]int Optional map[string]int Result *TypeObject Locals []ICmd LocalNames map[string]int Children []ICmd }
CmdBlock calls a stack command
type CmdCommand ¶
CmdCommand is a runtime command
func (*CmdCommand) GetResult ¶
func (cmd *CmdCommand) GetResult() *TypeObject
GetResult returns result
func (*CmdCommand) GetToken ¶
func (cmd *CmdCommand) GetToken() int
GetToken returns the index of the token
type CmdCommon ¶
type CmdCommon struct {
TokenID uint32 // the index of the token in lexeme
}
CmdCommon is a common structure for all commands
type CmdConst ¶
CmdConst pushes a value of the constant into stack
type CmdRet ¶
type CmdRet struct { Cmd ICmd // the value of the index Type *TypeObject // the type of the result }
CmdRet is the command for getting index values
type CmdType ¶
type CmdType uint32
CmdType is used for types of commands
const ( // CtValue pushes value into stack CtValue CmdType = iota + 1 // CtVar pushes the value of the variable into stack CtVar // CtConst pushes the value of the constant into stack CtConst // CtStack is a stack command CtStack // CtUnary is an unary function CtUnary // CtBinary is binary function CtBinary // CtFunc is other functions CtFunc // CtCommand is a command of vm like break continue CtCommand )
type CmdUnary ¶
type CmdUnary struct { CmdCommon Object IObject Result *TypeObject Operand ICmd }
CmdUnary calls an unary function
func (*CmdUnary) GetResult ¶
func (cmd *CmdUnary) GetResult() *TypeObject
GetResult returns the type of the result
type CmdValue ¶
type CmdValue struct { CmdCommon Value interface{} Result *TypeObject }
CmdValue pushes a value into stack
type CmdVar ¶
type CmdVar struct { CmdCommon Block *CmdBlock // pointer to the block of the variable Index int // the index of the variable in the block Indexes []CmdRet // the indexes list of the variable }
CmdVar pushes the value of the variable into stack
type ConstObject ¶
type ConstObject struct { Object Redefined bool Exp ICmd // expression Return *TypeObject // the type of the constant Iota int64 // iota }
ConstObject contains information about the constant
func (*ConstObject) GetCode ¶ added in v1.5.0
func (constObj *ConstObject) GetCode() *Bytecode
GetCode returns the Bytecode structure
func (*ConstObject) GetLex ¶
func (constObj *ConstObject) GetLex() *Lex
GetLex returns the lex structure of the object
func (*ConstObject) GetName ¶
func (constObj *ConstObject) GetName() string
GetName returns the name of the object
func (*ConstObject) GetParams ¶
func (constObj *ConstObject) GetParams() []*TypeObject
GetParams returns the slice of parameters
func (*ConstObject) GetType ¶
func (constObj *ConstObject) GetType() ObjectType
GetType returns ObjType
func (*ConstObject) GetUnitIndex ¶
func (constObj *ConstObject) GetUnitIndex() uint32
GetUnitIndex returns the index of the unit of this object
func (*ConstObject) Result ¶
func (constObj *ConstObject) Result() *TypeObject
Result returns the type of the result
type Embed ¶ added in v1.6.0
type Embed struct { Name string // name of the function Pars string // parameters with comma delimiter Ret string // result type Code uint32 // Bytecode (if Func == nil) or function index Func interface{} // golang function Return uint16 // the type of the result Params []uint16 // the types of parameters Variadic bool // variadic function Runtime bool // the first parameter is rt CanError bool // can generate error }
Embed contains information about the golang function
type EmbedObject ¶
type EmbedObject struct { Object Func interface{} // golang function Return *TypeObject // the type of the result Params []*TypeObject // the types of parameters Variadic bool // variadic function Runtime bool // the first parameter is rt CanError bool // can generate error }
EmbedObject contains information about the golang function
func (*EmbedObject) GetCode ¶ added in v1.5.0
func (embedObj *EmbedObject) GetCode() *Bytecode
GetCode returns the Bytecode structure
func (*EmbedObject) GetLex ¶
func (embedObj *EmbedObject) GetLex() *Lex
GetLex returns the lex structure of the object
func (*EmbedObject) GetName ¶
func (embedObj *EmbedObject) GetName() string
GetName returns the name of the object
func (*EmbedObject) GetParams ¶
func (embedObj *EmbedObject) GetParams() []*TypeObject
GetParams returns the slice of parameters
func (*EmbedObject) GetType ¶
func (embedObj *EmbedObject) GetType() ObjectType
GetType returns ObjEmbedded
func (*EmbedObject) GetUnitIndex ¶
func (embedObj *EmbedObject) GetUnitIndex() uint32
GetUnitIndex returns the index of the unit of this object
func (*EmbedObject) Result ¶
func (embedObj *EmbedObject) Result() *TypeObject
Result returns the type of the result
type FnType ¶ added in v1.1.0
type FnType struct { Params []*TypeObject // Types of parameters Result *TypeObject // Type of return value }
FnType is used for func types
type FuncObject ¶
FuncObject contains information about the function
func (*FuncObject) GetCode ¶ added in v1.5.0
func (funcObj *FuncObject) GetCode() *Bytecode
GetCode returns the Bytecode structure
func (*FuncObject) GetLex ¶
func (funcObj *FuncObject) GetLex() *Lex
GetLex returns the lex structure of the object
func (*FuncObject) GetName ¶
func (funcObj *FuncObject) GetName() string
GetName returns the name of the object
func (*FuncObject) GetParams ¶
func (funcObj *FuncObject) GetParams() []*TypeObject
GetParams returns the slice of parameters
func (*FuncObject) GetType ¶
func (funcObj *FuncObject) GetType() ObjectType
GetType returns ObjFunc
func (*FuncObject) GetUnitIndex ¶
func (funcObj *FuncObject) GetUnitIndex() uint32
GetUnitIndex returns the index of the unit of this object
func (*FuncObject) Result ¶
func (funcObj *FuncObject) Result() *TypeObject
Result returns the type of the result
type ICmd ¶
type ICmd interface { GetType() CmdType GetResult() *TypeObject GetObject() IObject GetToken() int }
ICmd is an interface for stack commands
type IObject ¶
type IObject interface { GetName() string Result() *TypeObject GetLex() *Lex GetParams() []*TypeObject GetType() ObjectType SetPub() GetUnitIndex() uint32 GetCode() *Bytecode }
IObject describes interface for all objects
type KeyValue ¶
type KeyValue struct { Key interface{} Value interface{} }
KeyValue is the type for key value :
type Lex ¶
type Lex struct { Source []rune Tokens []Token Lines []int // offsets of lines Strings []string // array of constant strings Header string // # header Path string // full path to the source }
Lex contains the result of the lexical parsing
func (Lex) LineColumn ¶
LineColumn return the line and the column of the ind-th token
type Map ¶
type Map struct { Keys []string // it is required for 'for' statement and String interface Data map[string]interface{} }
Map is a map
type Obj ¶ added in v1.8.0
type Obj struct {
Data interface{}
}
Object is an object
type Object ¶
type Object struct { Name string Unit *Unit Pub bool // public object ObjID int32 // index in Objects BCode Bytecode }
Object contains information about any compiled object of the virtual machine
type ObjectType ¶
type ObjectType int
ObjectType is used for types of objects
const ( // ObjType is a type ObjType ObjectType = iota + 1 // ObjEmbedded is a embedded golang function ObjEmbedded // ObjFunc is a gentee function ObjFunc // ObjConst is a constant ObjConst )
type Range ¶
Range is the type for operator ..
type RuntimeError ¶
RuntimeError is a runtime error type
func (*RuntimeError) Error ¶
func (re *RuntimeError) Error() string
type Set ¶ added in v1.3.0
type Set struct {
Data []uint64
}
Set is []bool
type Struct ¶
type Struct struct { Type *TypeObject Values []interface{} // Values of fields }
Struct is used for custom struct types
type StructInfo ¶ added in v1.6.0
type StructType ¶
type StructType struct { Fields map[string]int64 // Names of fields with indexes of the order Types []*TypeObject // Types of fields }
StructType is used for custom struct types
type Token ¶
type Token struct { Type int32 Index int32 // index in Lex.Strings if Type is tkStr Offset int Length int }
Token is a lexical token.
type TraceInfo ¶
type TraceInfo struct { Path string // the full path name of the source Entry string // the entry function name Func string // the called function Line int // line position in the source Pos int // column position in the line }
TraceInfo is a structure for stack func info
type TypeObject ¶
type TypeObject struct { Object Original reflect.Type // Original golang type IndexOf *TypeObject // consists of elements Custom *StructType // for custom struct type Func *FnType // for func type }
TypeObject contains information about the type
func (*TypeObject) GetCode ¶ added in v1.5.0
func (typeObj *TypeObject) GetCode() *Bytecode
GetCode returns the Bytecode structure
func (*TypeObject) GetLex ¶
func (typeObj *TypeObject) GetLex() *Lex
GetLex returns the lex structure of the object
func (*TypeObject) GetName ¶
func (typeObj *TypeObject) GetName() (ret string)
GetName returns the name of the object
func (*TypeObject) GetParams ¶
func (typeObj *TypeObject) GetParams() []*TypeObject
GetParams returns the slice of parameters
func (*TypeObject) GetType ¶
func (typeObj *TypeObject) GetType() ObjectType
GetType returns ObjType
func (*TypeObject) GetUnitIndex ¶
func (typeObj *TypeObject) GetUnitIndex() uint32
GetUnitIndex returns the index of the unit of this object
func (*TypeObject) Result ¶
func (typeObj *TypeObject) Result() *TypeObject
Result returns the type of the result
type Unit ¶
type Unit struct { VM *Workspace Index uint32 // Index of the Unit NameSpace map[string]uint32 // name space of the unit Included map[uint32]bool // false - included or true - imported units Lexeme *Lex // The array of source code RunID int // The index of run function. Undefined (-1) - run has not yet been defined Name string // The name of the unit Pub int // Public mode }
Unit is a common structure for source code
func (*Unit) FindFunc ¶
func (unit *Unit) FindFunc(name string, params []*TypeObject) (IObject, bool)
FindFunc returns the function with the specified name and parameters
func (*Unit) ImportEmbed ¶ added in v1.7.0
ImportEmbed imports Embed funcs to Unit
func (*Unit) NameToType ¶
NameToType searches the type by its name. It accepts names like name.name.name. It creates a new type if it absents.
func (*Unit) TypeByGoType ¶
func (unit *Unit) TypeByGoType(goType reflect.Type) *TypeObject
TypeByGoType returns the type by the go type name
type Workspace ¶ added in v1.5.0
type Workspace struct { Units []*Unit UnitNames map[string]int Objects []IObject Linked map[string]int // compiled files IotaID int32 Embedded []Embed }
Workspace contains information of compiled source code