Documentation
¶
Index ¶
- Constants
- func Compile(program, source string, init bool, offopt uint32) (string, error)
- func Decompile(program string) string
- func EncodeRLP(x any) string
- func EncodeString(s string) string
- func EncodeWithSignature(signature string, args ...any) string
- func MakeConstructor(deployedBytecode string) string
- func NewCompilationError(origin Origin, message string) error
- func NewLexicalError(filename string, line, column int, message, token string) error
- func NumArguments(signature string) int
- func SegmentsGetPosition(xs []Segment, id int32) int
- func SegmentsToString(xs []Segment) string
- func VisitSequence(v Visitor, s *Scope, esp int, nodes []Node, dir int) int
- type BytecodeVisitor
- func (v *BytecodeVisitor) GetOptimizedSegments() []Segment
- func (v *BytecodeVisitor) VisitFunction(s *Scope, esp int, call Node)
- func (v *BytecodeVisitor) VisitNil()
- func (v *BytecodeVisitor) VisitNumber(x *uint256.Int)
- func (v *BytecodeVisitor) VisitString(n Node)
- func (v *BytecodeVisitor) VisitSymbol(s *Scope, esp int, symbol Node)
- func (v *BytecodeVisitor) VisitT()
- type CompilationError
- type Hash
- type KeccakState
- type LexicalError
- type LispFunction
- type Node
- func NewNodeApplication(functionName string, origin Origin) Node
- func NewNodeList(origin Origin) Node
- func NewNodeNil(origin Origin) Node
- func NewNodeProgn() Node
- func NewNodeQuote(child Node, origin Origin) Node
- func NewNodeString(value string, origin Origin) Node
- func NewNodeSymbol(symbol string, origin Origin) Node
- func NewNodeU256(x *uint256.Int, origin Origin) Node
- func NewNodeU64(x uint64, origin Origin) Node
- func OptimizeAST(node Node, offs uint32) Node
- func Parse(tokens *TokenIterator) Node
- func (n *Node) Accept(v Visitor, s *Scope, esp int)
- func (n *Node) AddChild(child Node)
- func (n *Node) AddChildren(children []Node)
- func (n *Node) FunctionName() string
- func (n *Node) IsAtom() bool
- func (n *Node) IsConstant() bool
- func (n *Node) IsEmptyList() bool
- func (n *Node) IsFunctionCall(name string) bool
- func (n *Node) IsList() bool
- func (n *Node) IsNil() bool
- func (n *Node) IsQuote() bool
- func (n *Node) IsString() bool
- func (n *Node) IsSymbol() bool
- func (n *Node) IsT() bool
- func (n *Node) IsThisSymbol(s string) bool
- func (n *Node) NumChildren() int
- func (n *Node) String() string
- type Origin
- type Scope
- func (s *Scope) Defconst(identifier string, value Node)
- func (s *Scope) Defun(fn LispFunction)
- func (s *Scope) GetCallAddress(identifier string) (int32, bool)
- func (s *Scope) GetConstant(identifier string) (Node, bool)
- func (s *Scope) GetFunction(identifier string) (LispFunction, bool)
- func (s *Scope) GetStackVariable(identifier string) (StackVariable, bool)
- func (s *Scope) GetStorageVariable(identifier string) (int32, bool)
- func (s *Scope) IsGlobal() bool
- func (s *Scope) NewChildScope() *Scope
- func (s *Scope) SetCallAddress(identifier string, segmentID int32)
- func (s *Scope) SetStackVariable(identifier string, variable StackVariable)
- func (s *Scope) SetStorageVariable(name string, position int32)
- type Segment
- type StackVariable
- type StoredFunction
- type Token
- type TokenIterator
- type Visitor
Constants ¶
View Source
const ( NodeList = iota // 0 NodeNumber // 1 NodeString // 2 NodeSymbol // 3 )
View Source
const ( TokenLeftParen = iota // ( TokenRightParen // ) TokenQuote // ' TokenNumber TokenString TokenSymbol )
View Source
const ( OffoptArithmetic = 1 << iota OffoptIf = 1 << iota )
Flags to turn off optimizations.
View Source
const (
// HashLength is the expected length of the hash
HashLength = 32
)
Variables ¶
This section is empty.
Functions ¶
func EncodeString ¶
func EncodeWithSignature ¶
func MakeConstructor ¶
func NewCompilationError ¶
func NewLexicalError ¶
func NumArguments ¶
func SegmentsGetPosition ¶
func SegmentsToString ¶
Types ¶
type BytecodeVisitor ¶
type BytecodeVisitor struct {
// contains filtered or unexported fields
}
func NewBytecodeVisitor ¶
func NewBytecodeVisitor(init bool) *BytecodeVisitor
func (*BytecodeVisitor) GetOptimizedSegments ¶
func (v *BytecodeVisitor) GetOptimizedSegments() []Segment
func (*BytecodeVisitor) VisitFunction ¶
func (v *BytecodeVisitor) VisitFunction(s *Scope, esp int, call Node)
func (*BytecodeVisitor) VisitNil ¶
func (v *BytecodeVisitor) VisitNil()
func (*BytecodeVisitor) VisitNumber ¶
func (v *BytecodeVisitor) VisitNumber(x *uint256.Int)
func (*BytecodeVisitor) VisitString ¶
func (v *BytecodeVisitor) VisitString(n Node)
func (*BytecodeVisitor) VisitSymbol ¶
func (v *BytecodeVisitor) VisitSymbol(s *Scope, esp int, symbol Node)
func (*BytecodeVisitor) VisitT ¶
func (v *BytecodeVisitor) VisitT()
type CompilationError ¶
func (CompilationError) Error ¶
func (e CompilationError) Error() string
type LexicalError ¶
func (LexicalError) Error ¶
func (e LexicalError) Error() string
type LispFunction ¶
func NewLispFunction ¶
func NewLispFunction(n Node) (LispFunction, error)
type Node ¶
type Node struct { Type int ValueString string ValueNumber *uint256.Int Children []Node Origin Origin }
func NewNodeApplication ¶
func NewNodeList ¶
func NewNodeNil ¶
func NewNodeProgn ¶
func NewNodeProgn() Node
func NewNodeQuote ¶
func NewNodeString ¶
func NewNodeSymbol ¶
func NewNodeU64 ¶
func OptimizeAST ¶
func Parse ¶
func Parse(tokens *TokenIterator) Node
func (*Node) AddChild ¶
TODO: Maybe accepting (Node) is better? And then:
parent = parent.AddChild(child)
func (*Node) AddChildren ¶
func (*Node) FunctionName ¶
func (*Node) IsConstant ¶
func (*Node) IsEmptyList ¶
func (*Node) IsFunctionCall ¶
func (*Node) IsThisSymbol ¶
func (*Node) NumChildren ¶
type Origin ¶
func NewOriginEmpty ¶
func NewOriginEmpty() Origin
type Scope ¶
type Scope struct { Constants map[string]Node Functions map[string]LispFunction CallAddresses map[string]int32 StackVariables map[string]StackVariable StorageVariables map[string]int32 Parent *Scope }
func NewGlobalScope ¶
func NewGlobalScope() *Scope
func (*Scope) Defun ¶
func (s *Scope) Defun(fn LispFunction)
func (*Scope) GetFunction ¶
func (s *Scope) GetFunction(identifier string) (LispFunction, bool)
func (*Scope) GetStackVariable ¶
func (s *Scope) GetStackVariable(identifier string) (StackVariable, bool)
func (*Scope) GetStorageVariable ¶
func (*Scope) NewChildScope ¶
func (*Scope) SetCallAddress ¶
func (*Scope) SetStackVariable ¶
func (s *Scope) SetStackVariable(identifier string, variable StackVariable)
func (*Scope) SetStorageVariable ¶
type Segment ¶
type Segment struct {
// contains filtered or unexported fields
}
func OptimizeBytecode ¶
type StackVariable ¶
type StoredFunction ¶
type StoredFunction struct {
// contains filtered or unexported fields
}
type Token ¶
type TokenIterator ¶
type TokenIterator struct {
// contains filtered or unexported fields
}
func NewTokenIterator ¶
func NewTokenIterator() TokenIterator
func (*TokenIterator) HasNext ¶
func (i *TokenIterator) HasNext() bool
func (*TokenIterator) Next ¶
func (i *TokenIterator) Next() Token
func (*TokenIterator) Peek ¶
func (i *TokenIterator) Peek() Token
type Visitor ¶
type Visitor interface { // Simple literals, do not need a scope. VisitNil() VisitT() VisitNumber(value *uint256.Int) VisitString(node Node) // Symbols currently serve only as const/variable identifiers. VisitSymbol(s *Scope, esp int, symbol Node) VisitFunction(s *Scope, esp int, call Node) }
Each visit function returns the stack delta, i.e. how many stack elements were pushed or taken.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.