变量
type Variable struct {
Name string `msgpack:"N,omitempty" json:"N,omitempty"`
Type Vtype `msgpack:"T,omitempty" json:"T,omitempty"` // we have only 4 data types
Value interface{} `msgpack:"V,omitempty" json:"V,omitempty"`
}
函数
type Function struct {
Name string `msgpack:"N,omitempty" json:"N,omitempty"`
Params []Variable `msgpack:"P,omitempty" json:"P,omitempty"`
ReturnValue Variable `msgpack:"R,omitempty" json:"R,omitempty"`
Lines map[uint64][]string `msgpack:"L,omitempty" json:"L,omitempty"`
// map from line number to array index below
LinesNumberIndex map[uint64]uint64 `msgpack:"LI,omitempty" json:"LI,omitempty"` // a map is used to avoid sorting/searching
LineNumbers []uint64 `msgpack:"LN,omitempty" json:"LN,omitempty"`
}
由名字、输入参数、返回值、方法体构成。
智能合约
// each smart code is nothing but a collection of functions
type SmartContract struct {
Functions map[string]Function `msgpack:"F,omitempty" json:"F,omitempty"`
}
由一个个“函数”构成。