Documentation
¶
Overview ¶
Package compiler implements Go to NEF smart contract compiler.
Index ¶
- func Compile(name string, r io.Reader) ([]byte, error)
- func CompileAndSave(src string, o *Options) ([]byte, error)
- func CreateManifest(di *DebugInfo, o *Options) (*manifest.Manifest, error)
- type DebugInfo
- type DebugMethodName
- type DebugParam
- type DebugRange
- type DebugSeqPoint
- type EventDebugInfo
- type MethodDebugInfo
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compile ¶
Compile compiles a Go program into bytecode that can run on the NEO virtual machine. If `r != nil`, `name` is interpreted as a filename, and `r` as file contents. Otherwise `name` is either file name or name of the directory containing source files.
func CompileAndSave ¶
CompileAndSave will compile and save the file to disk in the NEF format.
Types ¶
type DebugInfo ¶ added in v0.75.0
type DebugInfo struct { MainPkg string `json:"-"` Documents []string `json:"documents"` Methods []MethodDebugInfo `json:"methods"` Events []EventDebugInfo `json:"events"` // EmittedEvents contains events occurring in code. EmittedEvents map[string][][]string `json:"-"` // StaticVariables contains list of static variable names and types. StaticVariables []string `json:"static-variables"` }
DebugInfo represents smart-contract debug information.
func CompileWithDebugInfo ¶ added in v0.75.0
CompileWithDebugInfo compiles a Go program into bytecode and emits debug info.
func CompileWithOptions ¶ added in v0.95.2
CompileWithOptions compiles a Go program into bytecode with provided compiler options.
func (*DebugInfo) ConvertToManifest ¶ added in v0.91.0
ConvertToManifest converts contract to the manifest.Manifest struct for debugger. Note: manifest is taken from the external source, however it can be generated ad-hoc. See #1038.
type DebugMethodName ¶ added in v0.75.0
DebugMethodName is a combination of a namespace and name.
func (*DebugMethodName) MarshalJSON ¶ added in v0.75.0
func (d *DebugMethodName) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (*DebugMethodName) UnmarshalJSON ¶ added in v0.75.0
func (d *DebugMethodName) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type DebugParam ¶ added in v0.75.0
type DebugParam struct { Name string `json:"name"` Type string `json:"type"` TypeSC smartcontract.ParamType `json:"-"` }
DebugParam represents variables's name and type.
func (*DebugParam) MarshalJSON ¶ added in v0.75.0
func (d *DebugParam) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (*DebugParam) ToManifestParameter ¶ added in v0.90.0
func (d *DebugParam) ToManifestParameter() manifest.Parameter
ToManifestParameter converts DebugParam to manifest.Parameter.
func (*DebugParam) UnmarshalJSON ¶ added in v0.75.0
func (d *DebugParam) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type DebugRange ¶ added in v0.75.0
DebugRange represents method's section in bytecode.
func (*DebugRange) MarshalJSON ¶ added in v0.75.0
func (d *DebugRange) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (*DebugRange) UnmarshalJSON ¶ added in v0.75.0
func (d *DebugRange) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type DebugSeqPoint ¶ added in v0.75.0
type DebugSeqPoint struct { // Opcode is an opcode's address. Opcode int // Document is an index of file where sequence point occurs. Document int // StartLine is the first line of the break-pointed statement. StartLine int // StartCol is the first column of the break-pointed statement. StartCol int // EndLine is the last line of the break-pointed statement. EndLine int // EndCol is the last column of the break-pointed statement. EndCol int }
DebugSeqPoint represents break-point for debugger.
func (*DebugSeqPoint) MarshalJSON ¶ added in v0.75.0
func (d *DebugSeqPoint) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (*DebugSeqPoint) UnmarshalJSON ¶ added in v0.75.0
func (d *DebugSeqPoint) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type EventDebugInfo ¶ added in v0.75.0
type EventDebugInfo struct { ID string `json:"id"` // Name is a human-readable event name in a format "{namespace},{name}". Name string `json:"name"` Parameters []DebugParam `json:"params"` }
EventDebugInfo represents smart-contract's event debug information.
type MethodDebugInfo ¶ added in v0.75.0
type MethodDebugInfo struct { // ID is the actual name of the method. ID string `json:"id"` // Name is the name of the method with the first letter in a lowercase // together with the namespace it belongs to. We need to keep the first letter // lowercased to match manifest standards. Name DebugMethodName `json:"name"` // IsExported defines whether method is exported. IsExported bool `json:"-"` // IsFunction defines whether method has no receiver. IsFunction bool `json:"-"` // Range is the range of smart-contract's opcodes corresponding to the method. Range DebugRange `json:"range"` // Parameters is a list of method's parameters. Parameters []DebugParam `json:"params"` // ReturnType is method's return type. ReturnType string `json:"return"` // ReturnTypeSC is return type to use in manifest. ReturnTypeSC smartcontract.ParamType `json:"-"` Variables []string `json:"variables"` // SeqPoints is a map between source lines and byte-code instruction offsets. SeqPoints []DebugSeqPoint `json:"sequence-points"` }
MethodDebugInfo represents smart-contract's method debug information.
func (*MethodDebugInfo) ToManifestMethod ¶ added in v0.90.0
func (m *MethodDebugInfo) ToManifestMethod() manifest.Method
ToManifestMethod converts MethodDebugInfo to manifest.Method.
type Options ¶
type Options struct { // The extension of the output file default set to .nef Ext string // The name of the output file. Outfile string // The name of the output for debug info. DebugInfo string // The name of the output for contract manifest file. ManifestFile string // NoEventsCheck specifies if events emitted by contract needs to be present in manifest. // This setting has effect only if manifest is emitted. NoEventsCheck bool // NoStandardCheck specifies if supported standards compliance needs to be checked. // This setting has effect only if manifest is emitted. NoStandardCheck bool // Name is contract's name to be written to manifest. Name string // Runtime notifications. ContractEvents []manifest.Event // The list of standards supported by the contract. ContractSupportedStandards []string // SafeMethods contains list of methods which will be marked as safe in manifest. SafeMethods []string // Permissions is a list of permissions for every contract method. Permissions []manifest.Permission }
Options contains all the parameters that affect the behaviour of the compiler.