translate

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const EntrySize = 8

Variables

This section is empty.

Functions

func ExtractAbi

func ExtractAbi(c ast.Contract) (*abi.ABI, error)

Types

type Asm

type Asm struct {
	AsmCodes []AsmCode
}

Asm is generated by compiling.

func CompileContract

func CompileContract(c ast.Contract) (Asm, error)

TODO: implement me w/ test cases :-) CompileContract() compiles a smart contract. returns bytecode and error.

func (*Asm) Emerge

func (a *Asm) Emerge(operator opcode.Type, operands ...[]byte) int

Emerge() translates instruction to bytecode An operand of operands should be 4 bytes.

func (*Asm) EmergeAt

func (a *Asm) EmergeAt(index int, operator opcode.Type, operands ...[]byte) int

EmergeAt() translates instruction to bytecode and append at index An operand of operands should be 4 bytes.

func (*Asm) Equal

func (a *Asm) Equal(a1 Asm) bool

func (*Asm) ReplaceOperandAt

func (a *Asm) ReplaceOperandAt(index int, operands []byte) error

func (*Asm) ReplaceOperatorAt

func (a *Asm) ReplaceOperatorAt(index int, operator opcode.Type) error

func (*Asm) String

func (a *Asm) String() string

func (*Asm) ToRawByteCode

func (a *Asm) ToRawByteCode() []byte

type AsmCode

type AsmCode struct {
	RawByte []byte
	Value   string
}

type EntryError

type EntryError struct {
	Id string
}

func (EntryError) Error

func (e EntryError) Error() string

type FuncMap

type FuncMap map[string]int

func (FuncMap) Declare

func (m FuncMap) Declare(signature string, asm Asm)

Declare() saves the start point of function.

type MemDefiner

type MemDefiner interface {
	Define(id string) MemEntry
}

Define() saves an variable to EntryMap and increase the MemoryCounter. This should be used when compiles the assign statement. ex) a = 5 -> Define("a", 5) b = "abc" -> Define("b", "abc")

type MemEntry

type MemEntry struct {
	Offset int
	Size   int
}

MemEntry saves size and offset of the value which the variable has.

type MemEntryTable

type MemEntryTable struct {
	EntryMap      map[string]MemEntry
	MemoryCounter int
}

MemEntryTable is used to know the location of the memory

func NewMemEntryTable

func NewMemEntryTable() *MemEntryTable

func (MemEntryTable) Counter

func (m MemEntryTable) Counter() int

TODO: implement test cases :-)

func (*MemEntryTable) Define

func (m *MemEntryTable) Define(id string) MemEntry

func (MemEntryTable) Entry

func (m MemEntryTable) Entry(id string) (MemEntry, error)

func (MemEntryTable) MemSize

func (m MemEntryTable) MemSize() int

TODO: implement test cases :-)

type MemGetter

type MemGetter interface {
	Entry(id string) (MemEntry, error)
	Counter() int
	MemSize() int
}

MemGetter gets the data of the memory entry. GetOffsetOfEntry() returns the offset of the memory entry corresponding the Id. GetSizeOfEntry() returns the size of the memory entry corresponding the Id.

type MemTracer

type MemTracer interface {
	MemDefiner
	MemGetter
}

Jump to

Keyboard shortcuts

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