compiler

package
v0.76.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2020 License: MIT Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compile

func Compile(r io.Reader) ([]byte, error)

Compile compiles a Go program into bytecode that can run on the NEO virtual machine.

func CompileAndSave

func CompileAndSave(src string, o *Options) ([]byte, error)

CompileAndSave will compile and save the file to disk.

Types

type ABI added in v0.75.0

type ABI struct {
	Hash       util.Uint160 `json:"hash"`
	Metadata   Metadata     `json:"metadata"`
	EntryPoint string       `json:"entrypoint"`
	Functions  []Method     `json:"functions"`
	Events     []Event      `json:"events"`
}

ABI represents ABI contract info in compatible with NEO Blockchain Toolkit format

type DebugInfo added in v0.75.0

type DebugInfo struct {
	EntryPoint string            `json:"entrypoint"`
	Documents  []string          `json:"documents"`
	Methods    []MethodDebugInfo `json:"methods"`
	Events     []EventDebugInfo  `json:"events"`
}

DebugInfo represents smart-contract debug information.

func CodeGen

func CodeGen(info *buildInfo) ([]byte, *DebugInfo, error)

CodeGen compiles the program to bytecode.

func CompileWithDebugInfo added in v0.75.0

func CompileWithDebugInfo(r io.Reader) ([]byte, *DebugInfo, error)

CompileWithDebugInfo compiles a Go program into bytecode and emits debug info.

type DebugMethodName added in v0.75.0

type DebugMethodName struct {
	Namespace string
	Name      string
}

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"`
}

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) 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

type DebugRange struct {
	Start uint16
	End   uint16
}

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 Event added in v0.75.0

type Event struct {
	Name       string       `json:"name"`
	Parameters []DebugParam `json:"parameters"`
}

Event represents ABI event's metadata.

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:"parameters"`
}

EventDebugInfo represents smart-contract's event debug information.

type Metadata added in v0.75.0

type Metadata struct {
	Author               string `json:"author"`
	Email                string `json:"email"`
	Version              string `json:"version"`
	Title                string `json:"title"`
	Description          string `json:"description"`
	HasStorage           bool   `json:"has-storage"`
	HasDynamicInvocation bool   `json:"has-dynamic-invoke"`
	IsPayable            bool   `json:"is-payable"`
}

Metadata represents ABI contract metadata

type Method added in v0.75.0

type Method struct {
	Name       string       `json:"name"`
	Parameters []DebugParam `json:"parameters"`
	ReturnType string       `json:"returntype"`
}

Method represents ABI method's metadata.

type MethodDebugInfo added in v0.75.0

type MethodDebugInfo struct {
	ID string `json:"id"`
	// Name is the name of the method together with the namespace it belongs to.
	Name DebugMethodName `json:"name"`
	// 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-type"`
	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.

type Options

type Options struct {
	// The extension of the output file default set to .avm
	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 application binary interface info.
	ABIInfo string

	// Contract metadata.
	ContractDetails *smartcontract.ContractDetails
}

Options contains all the parameters that affect the behaviour of the compiler.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL