ast

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INDEX_RELOAD     = "IndexOp"
	INDEX_SET_RELOAD = "IndexSetOp"
	CORO_MOD         = "github.com/Chronostasys/calc/runtime/coro"
	GEN_MOD          = "github.com/Chronostasys/calc/runtime/generator"
	CORO_SM_MOD      = CORO_MOD + "/sm"
	CORO_SYNC_MOD    = "github.com/Chronostasys/calc/runtime/coro/sync"
	LIBUV            = "github.com/Chronostasys/calc/runtime/libuv"
	SLICE            = "github.com/Chronostasys/calc/runtime/slice"
	RUNTIME          = "github.com/Chronostasys/calc/runtime"
)

Variables

View Source
var ScopeMap = map[string]*Scope{}

Functions

func AddSTDFunc

func AddSTDFunc(m *ir.Module, s *Scope)

Types

type ArrayInitNode

type ArrayInitNode struct {
	Type TypeNode
	Vals []Node
	// contains filtered or unexported fields
}

type ArrayTypeNode

type ArrayTypeNode struct {
	Len      int
	ElmType  TypeNode
	PtrLevel int
}

func (*ArrayTypeNode) Clone

func (n *ArrayTypeNode) Clone() TypeNode

func (*ArrayTypeNode) GetPtrLevel

func (n *ArrayTypeNode) GetPtrLevel() int

func (*ArrayTypeNode) SetPtrLevel

func (v *ArrayTypeNode) SetPtrLevel(i int)

func (*ArrayTypeNode) String

func (v *ArrayTypeNode) String(s *Scope) string

type AwaitNode

type AwaitNode struct {
	Exp ExpNode
	// contains filtered or unexported fields
}

type BasicTypeNode

type BasicTypeNode struct {
	ResType  int
	CustomTp []string
	PtrLevel int
	Generics []TypeNode
	Pkg      string
}

func (*BasicTypeNode) Clone

func (n *BasicTypeNode) Clone() TypeNode

func (*BasicTypeNode) GetPtrLevel

func (n *BasicTypeNode) GetPtrLevel() int

func (*BasicTypeNode) SetPtrLevel

func (v *BasicTypeNode) SetPtrLevel(i int)

func (*BasicTypeNode) String

func (v *BasicTypeNode) String(s *Scope) string

type BinNode

type BinNode struct {
	Op    int
	Left  ExpNode
	Right ExpNode
}

type BoolConstNode

type BoolConstNode struct {
	Val bool
}

type BoolExpNode

type BoolExpNode struct {
	Op    int
	Left  ExpNode
	Right ExpNode
}

type BreakNode

type BreakNode struct {
}

type CallFuncNode

type CallFuncNode struct {
	Params []Node
	FnNode Node

	Next     Node
	Generics []TypeNode
	// contains filtered or unexported fields
}

type CompareNode

type CompareNode struct {
	Op    int
	Left  ExpNode
	Right ExpNode
}

type ContinueNode

type ContinueNode struct {
}

type DefAndAssignNode

type DefAndAssignNode struct {
	ValNode Node
	ID      string
	Val     func(s *Scope) value.Value
}

type DefineNode

type DefineNode struct {
	ID  string
	TP  TypeNode
	Val value.Value
	// contains filtered or unexported fields
}

type EmptyNode

type EmptyNode struct {
}

type ExpNode

type ExpNode interface {
	Node
	// contains filtered or unexported methods
}

type Field

type Field struct {
	Name string
	TP   TypeNode
}

type ForNode

type ForNode struct {
	Bool         Node
	DefineAssign Node
	Assign       Node
	Statements   Node
}

type FuncNode

type FuncNode struct {
	Params     *ParamsNode
	ID         string
	RetType    TypeNode
	Statements Node
	Generics   []string
	Async      bool
	// contains filtered or unexported fields
}

func (*FuncNode) AddtoScope

func (n *FuncNode) AddtoScope(s *Scope)

type FuncTypeNode

type FuncTypeNode struct {
	Args *ParamsNode
	Ret  TypeNode
	// contains filtered or unexported fields
}

func (*FuncTypeNode) Clone

func (n *FuncTypeNode) Clone() TypeNode

func (*FuncTypeNode) GetPtrLevel

func (n *FuncTypeNode) GetPtrLevel() int

func (*FuncTypeNode) SetPtrLevel

func (v *FuncTypeNode) SetPtrLevel(i int)

func (*FuncTypeNode) String

func (v *FuncTypeNode) String(*Scope) string

type IfElseNode

type IfElseNode struct {
	BoolExp    Node
	Statements Node
	ElSt       Node
}

type IfNode

type IfNode struct {
	BoolExp    Node
	Statements Node
}

type ImportNode

type ImportNode struct {
	Imports map[string]string
}

type InlineFuncNode

type InlineFuncNode struct {
	Fntype TypeNode
	Body   Node
	Async  bool
	// contains filtered or unexported fields
}

type InterfaceDefNode

type InterfaceDefNode struct {
	Funcs      map[string]*FuncNode
	OrderedIDS []string
	// contains filtered or unexported fields
}

func (*InterfaceDefNode) Clone

func (n *InterfaceDefNode) Clone() TypeNode

func (*InterfaceDefNode) GetPtrLevel

func (n *InterfaceDefNode) GetPtrLevel() int

func (*InterfaceDefNode) SetPtrLevel

func (v *InterfaceDefNode) SetPtrLevel(i int)

func (*InterfaceDefNode) String

func (v *InterfaceDefNode) String(*Scope) string

type NilNode

type NilNode struct {
}

type Node

type Node interface {
	// contains filtered or unexported methods
}

func NewTypeDef

func NewTypeDef(id string, tp TypeNode, generics []string, m *ir.Module, s *Scope) Node

type NotNode

type NotNode struct {
	Bool ExpNode
}

type NumNode

type NumNode struct {
	Val value.Value
}

type PackageNode

type PackageNode struct {
	Name string
}

type ParamNode

type ParamNode struct {
	ID  string
	TP  TypeNode
	Val value.Value
}

func (*ParamNode) V

func (n *ParamNode) V() value.Value

type ParamsNode

type ParamsNode struct {
	Params []*ParamNode
	Ext    bool
}

type ProgramNode

type ProgramNode struct {
	PKG         *PackageNode
	Imports     *ImportNode
	Children    []Node
	GlobalScope *Scope
}

func Merge

func Merge(ns ...*ProgramNode) *ProgramNode

func (*ProgramNode) CalcGlobals

func (n *ProgramNode) CalcGlobals(m *ir.Module)

func (*ProgramNode) Emit

func (n *ProgramNode) Emit(m *ir.Module)

type RetNode

type RetNode struct {
	Exp Node
	// contains filtered or unexported fields
}

type SLNode

type SLNode struct {
	Children []Node
}

SLNode statement list node

type Scope

type Scope struct {
	Pkgname string
	// contains filtered or unexported fields
}

func MergeGlobalScopes

func MergeGlobalScopes(ss ...*Scope) *Scope

func NewGlobalScope

func NewGlobalScope(m *ir.Module) *Scope

type StringNode

type StringNode struct {
	Str string
	// contains filtered or unexported fields
}

type StructDefNode

type StructDefNode struct {
	Orderedfields []*Field
	// contains filtered or unexported fields
}

func (*StructDefNode) Clone

func (n *StructDefNode) Clone() TypeNode

func (*StructDefNode) GetPtrLevel

func (n *StructDefNode) GetPtrLevel() int

func (*StructDefNode) SetPtrLevel

func (v *StructDefNode) SetPtrLevel(i int)

func (*StructDefNode) String

func (v *StructDefNode) String(*Scope) string

type StructInitNode

type StructInitNode struct {
	TP     TypeNode
	Fields map[string]Node
	// contains filtered or unexported fields
}

type TakePtrNode

type TakePtrNode struct {
	Node ExpNode
}

type TakeValNode

type TakeValNode struct {
	Level int
	Node  ExpNode
}

type TypeNode

type TypeNode interface {
	SetPtrLevel(int)
	GetPtrLevel() int
	String(*Scope) string
	Clone() TypeNode
	// contains filtered or unexported methods
}

type UnaryNode

type UnaryNode struct {
	Op    int
	Child ExpNode
}

type VarBlockNode

type VarBlockNode struct {
	Token string
	Idxs  []Node

	Next *VarBlockNode
	// contains filtered or unexported fields
}

type YieldNode

type YieldNode struct {
	Exp Node
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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