Documentation ¶
Overview ¶
MIT License
Copyright (c) 2016 GenesisCommunity ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2016 GenesisCommunity ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2016 GenesisCommunity ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2016 GenesisCommunity ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2016 GenesisCommunity ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2016 GenesisCommunity ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2016 GenesisCommunity ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MIT License ¶
Copyright (c) 2016 GenesisCommunity ¶
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
- Constants
- Variables
- func ContractsList(value string) ([]string, error)
- func ExContract(rt *RunTime, state uint32, name string, params map[string]interface{}) (interface{}, error)
- func ExecContract(rt *RunTime, name, txs string, params ...interface{}) (interface{}, error)
- func GetSettings(rt *RunTime, cntname, name string) (interface{}, error)
- func MemoryUsage(rt *RunTime) int64
- func ParseContract(in string) (id uint64, name string)
- func SetVMError(eType string, eText interface{}) error
- func StateName(state uint32, name string) string
- func ValueToDecimal(v interface{}) (ret decimal.Decimal, err error)
- func ValueToFloat(v interface{}) (ret float64)
- type Block
- type Blocks
- type ByteCode
- type ByteCodes
- type ContractInfo
- type ExtFuncInfo
- type ExtendData
- type FieldInfo
- type FuncInfo
- type FuncName
- type FuncNameCmd
- type IndexInfo
- type Lexem
- type Lexems
- type ObjInfo
- type OwnerInfo
- type RunTime
- type Stacker
- type VM
- func (vm *VM) Call(name string, params []interface{}, extend *map[string]interface{}) (ret []interface{}, err error)
- func (vm *VM) Compile(input []rune, owner *OwnerInfo) error
- func (vm *VM) CompileBlock(input []rune, owner *OwnerInfo) (*Block, error)
- func (vm *VM) CompileEval(input string, state uint32) error
- func (vm *VM) EvalIf(input string, state uint32, vars *map[string]interface{}) (bool, error)
- func (vm *VM) Extend(ext *ExtendData)
- func (vm *VM) FlushBlock(root *Block)
- func (vm *VM) FlushExtern()
- func (vm *VM) RunInit(cost int64) *RunTime
- type VMError
- type VMType
- type VarInfo
Constants ¶
const ( // Decimal is the constant string for decimal type Decimal = `decimal.Decimal` // Interface is the constant string for interface type Interface = `interface` )
const ( // ObjUnknown is an unknown object. It means something wrong. ObjUnknown = iota // ObjContract is a contract object. ObjContract // ObjFunc is a function object. myfunc() ObjFunc // ObjExtFunc is an extended function object. $myfunc() ObjExtFunc // ObjVar is a variable. myvar ObjVar // ObjExtend is an extended variable. $myvar ObjExtend // CostCall is the cost of the function calling CostCall = 50 // CostContract is the cost of the contract calling CostContract = 100 // CostExtend is the cost of the extend function calling CostExtend = 10 // CostDefault is the default maximum cost of F CostDefault = int64(10000000) // VMTypeSmart is smart vm type VMTypeSmart VMType = 1 // VMTypeVDE is vde vm type VMTypeVDE VMType = 2 // VMTypeVDEMaster is VDEMaster type VMTypeVDEMaster VMType = 3 TagFile = "file" TagAddress = "address" TagSignature = "signature" TagOptional = "optional" )
Variables ¶
var ErrMemoryLimit = errors.New("Memory limit exceeded")
Functions ¶
func ContractsList ¶
ContractsList returns list of contracts names from source of code
func ExContract ¶
func ExContract(rt *RunTime, state uint32, name string, params map[string]interface{}) (interface{}, error)
ExContract executes the name contract in the state with specified parameters
func ExecContract ¶
ExecContract runs the name contract where txs contains the list of parameters and params are the values of parameters
func GetSettings ¶
GetSettings returns the value of the parameter
func MemoryUsage ¶
func ParseContract ¶
ParseContract gets a state identifier and the name of the contract from the full name like @[id]name
func SetVMError ¶
SetVMError sets error of VM
func StateName ¶
StateName checks the name of the contract and modifies it to @[state]name if it is necessary.
func ValueToDecimal ¶
ValueToDecimal converts interface (string, float64, Decimal or int64) to Decimal
func ValueToFloat ¶
func ValueToFloat(v interface{}) (ret float64)
ValueToFloat converts interface (string, float64 or int64) to float64
Types ¶
type Block ¶
type Block struct { Objects map[string]*ObjInfo Type int Owner *OwnerInfo Info interface{} Parent *Block Vars []reflect.Type Code ByteCodes Children Blocks }
Block contains all information about compiled block {...} and its children
type ByteCode ¶
type ByteCode struct { Cmd uint16 Value interface{} }
ByteCode stores a command and an additional parameter.
type ContractInfo ¶
type ContractInfo struct { ID uint32 Name string Owner *OwnerInfo Used map[string]bool // Called contracts Tx *[]*FieldInfo Settings map[string]interface{} }
ContractInfo contains the contract information
type ExtFuncInfo ¶
type ExtFuncInfo struct { Name string Params []reflect.Type Results []reflect.Type Auto []string Variadic bool Func interface{} }
ExtFuncInfo is the structure for the extrended function
type ExtendData ¶
ExtendData is used for the definition of the extended functions and variables
type FieldInfo ¶
FieldInfo describes the field of the data structure
func (*FieldInfo) ContainsTag ¶
ContainsTag returns whether the tag is contained in this field
type FuncInfo ¶
type FuncInfo struct { Params []reflect.Type Results []reflect.Type Names *map[string]FuncName Variadic bool ID uint32 }
FuncInfo contains the function information
type Lexem ¶
type Lexem struct { Type uint32 // Type of the lexem Value interface{} // Value of lexem Line uint32 // Line of the lexem Column uint32 // Position inside the line }
Lexem contains information about language item
type OwnerInfo ¶
type OwnerInfo struct { StateID uint32 `json:"state"` Active bool `json:"active"` TableID int64 `json:"tableid"` WalletID int64 `json:"walletid"` TokenID int64 `json:"tokenid"` }
OwnerInfo storing info about owner
type RunTime ¶
type RunTime struct {
// contains filtered or unexported fields
}
RunTime is needed for the execution of the byte-code
func (*RunTime) Run ¶
func (rt *RunTime) Run(block *Block, params []interface{}, extend *map[string]interface{}) (ret []interface{}, err error)
Run executes Block with the specified parameters and extended variables and functions
type VM ¶
type VM struct { Block ExtCost func(string) int64 FuncCallsDB map[string]struct{} Extern bool // extern mode of compilation // contains filtered or unexported fields }
VM is the main type of the virtual machine
func (*VM) Call ¶
func (vm *VM) Call(name string, params []interface{}, extend *map[string]interface{}) (ret []interface{}, err error)
Call executes the name object with the specified params and extended variables and functions
func (*VM) Compile ¶
Compile compiles a source code and loads the byte-code into the virtual machine
func (*VM) CompileBlock ¶
CompileBlock compile the source code into the Block structure with a byte-code
func (*VM) CompileEval ¶
CompileEval compiles conditional exppression
func (*VM) EvalIf ¶
EvalIf runs the conditional expression. It compiles the source code before that if that's necessary.
func (*VM) Extend ¶
func (vm *VM) Extend(ext *ExtendData)
Extend sets the extended variables and functions
func (*VM) FlushBlock ¶
FlushBlock loads the compiled Block into the virtual machine
func (*VM) FlushExtern ¶
func (vm *VM) FlushExtern()
FlushExtern switches off the extern mode of the compilation