ast

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBinaryOp

func CreateBinaryOp(intstr, fltstr string, blk *ir.BasicBlock, t types.Type, left, right value.Value) value.Value

CreateBinaryOp produces a geode binary op (just a wrapper around llir/llvm's binary instructions)

func DumpTree

func DumpTree(in <-chan Node, useJSON bool) <-chan Node

DumpTree takes a channel of nodes and prints all Nodes it recieves, then pushes them back out a new channel it makes and returns

func MangleFunctionName

func MangleFunctionName(origName string, argTypes ...types.Type) string

MangleFunctionName will mangle a function name like how cpp does :)

func Parse

func Parse(tokens chan lexer.Token) <-chan Node

Parse creates and runs a new lexer, that returns the chan that the nodes will be passed through with

func UnescapeString

func UnescapeString(str string) []byte

UnescapeString UTF-8 string e.g. convert "\u0e27\u0e23\u0e0d\u0e32" to "วรญา"

func UnmangleFunctionName

func UnmangleFunctionName(mangled string) string

UnmangleFunctionName takes some mangled name and returns the unmangled one

Types

type BinaryNode added in v0.0.7

type BinaryNode struct {
	NodeType

	OP    string
	Left  Node
	Right Node
}

BinaryNode is a binary operation representation

func (BinaryNode) Codegen added in v0.0.7

func (n BinaryNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for BinaryNode

func (BinaryNode) InferType added in v0.0.7

func (n BinaryNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (BinaryNode) NameString added in v0.0.7

func (n BinaryNode) NameString() string

NameString implements Node.NameString

type BlockNode added in v0.0.7

type BlockNode struct {
	NodeType
	Nodes []Node
}

BlockNode is a block statement. A block statement is just an array of Nodes that run in sequence.

func (BlockNode) Codegen added in v0.0.7

func (n BlockNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for BlockNode

func (BlockNode) InferType added in v0.0.7

func (n BlockNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (BlockNode) NameString added in v0.0.7

func (n BlockNode) NameString() string

NameString implements Node.NameString

type CastNode added in v0.0.7

type CastNode struct {
	NodeType
	From Node
	To   string
}

CastNode is a type cast "function" call. TODO: Replace this with normal function calls and check in the function call codegen function

func (CastNode) Codegen added in v0.0.7

func (n CastNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for CastNode

func (CastNode) InferType added in v0.0.7

func (n CastNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (CastNode) NameString added in v0.0.7

func (n CastNode) NameString() string

NameString implements Node.NameString

type CharNode added in v0.0.7

type CharNode struct {
	NodeType
	Value int8
}

CharNode is a char literal TODO: get parsing working for this.

func (CharNode) Codegen added in v0.0.7

func (n CharNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for CharNode

func (CharNode) InferType added in v0.0.7

func (n CharNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (CharNode) NameString added in v0.0.7

func (n CharNode) NameString() string

NameString implements Node.NameString

type ClassNode added in v0.0.7

type ClassNode struct {
	NodeType

	Name      string
	Methods   []FunctionNode
	Variables []VariableNode
}

ClassNode -

func (ClassNode) Codegen added in v0.0.7

func (n ClassNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for ClassNode

func (ClassNode) InferType added in v0.0.7

func (n ClassNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (ClassNode) NameString added in v0.0.7

func (n ClassNode) NameString() string

NameString implements Node.NameString

type CompileTarget

type CompileTarget int

CompileTarget is a target to build a binary for

const (
	ASMTarget CompileTarget = iota
	BinaryTarget
)

Some default targets

type Compiler

type Compiler struct {
	Name string
	// A reference to the scope in the package for easier access
	Scope   *Scope
	Package *Package
	Module  *ir.Module

	FN *ir.Function // current funciton being compiled
	// contains filtered or unexported fields
}

Compiler contains all information to compile a program from nodes to llvm ir

func NewCompiler

func NewCompiler(moduleName string, pkg *Package) *Compiler

NewCompiler returns a pointer to a new Compiler object.

func (*Compiler) CurrentBlock

func (c *Compiler) CurrentBlock() *ir.BasicBlock

CurrentBlock -

func (*Compiler) FunctionDefined

func (c *Compiler) FunctionDefined(fn *ir.Function) bool

FunctionDefined returns whether or not a function with a name has been defined in the module's scope

func (*Compiler) PopBlock

func (c *Compiler) PopBlock() *ir.BasicBlock

PopBlock -

func (*Compiler) PushBlock

func (c *Compiler) PushBlock(blk *ir.BasicBlock)

PushBlock -

type DependencyNode added in v0.0.7

type DependencyNode struct {
	NodeType
	Paths    []string
	CLinkage bool
}

DependencyNode is a way of representing the need to include a dependency or multiple dependencies. It also works to link a c program as well. Paths contains a list of paths to the dependencies that the user entered into the statement. These paths are not resolved and may not contain a geode source file.

Example:

Paths = ["std:io"]
CLinkage = false

/

func (DependencyNode) Codegen added in v0.0.7

func (n DependencyNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for DependencyNode

func (DependencyNode) Handle added in v0.0.7

func (n DependencyNode) Handle(c *Compiler) value.Value

Handle will do ast-level handling for a dependency node

func (DependencyNode) InferType added in v0.0.7

func (n DependencyNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (DependencyNode) NameString added in v0.0.7

func (n DependencyNode) NameString() string

NameString implements Node.NameString

type FloatNode added in v0.0.7

type FloatNode struct {
	NodeType
	Value float64
}

FloatNode is a float literla

func (FloatNode) Codegen added in v0.0.7

func (n FloatNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for FloatNode

func (FloatNode) InferType added in v0.0.7

func (n FloatNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (FloatNode) NameString added in v0.0.7

func (n FloatNode) NameString() string

NameString implements Node.NameString

type ForNode added in v0.0.7

type ForNode struct {
	NodeType
	Index int
	Init  Node
	Cond  Node
	Step  Node
	Body  Node
}

ForNode is a for loop structure representation

func (ForNode) Codegen added in v0.0.7

func (n ForNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for ForNode

func (ForNode) InferType added in v0.0.7

func (n ForNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (ForNode) NameString added in v0.0.7

func (n ForNode) NameString() string

NameString implements Node.NameString

type FunctionCallNode added in v0.0.7

type FunctionCallNode struct {
	NodeType

	Name string
	Args []Node
}

FunctionCallNode is a function call, example: `foo(a, b, c)`. This would be:

Name = "foo"
Args = [a, b, c]    <- these are Node references

func (FunctionCallNode) Codegen added in v0.0.7

func (n FunctionCallNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for FunctionCallNode

func (FunctionCallNode) InferType added in v0.0.7

func (n FunctionCallNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (FunctionCallNode) NameString added in v0.0.7

func (n FunctionCallNode) NameString() string

NameString implements Node.NameString

type FunctionNode added in v0.0.7

type FunctionNode struct {
	NodeType

	Name       string
	Args       []VariableNode
	Body       BlockNode
	External   bool
	Variadic   bool
	Nomangle   bool
	ReturnType GeodeTypeRef
}

FunctionNode is the representation of some function. It has methods on it to declare the function as well as codegen. A function has a list of VariableNodes for arguments and a single block for a body, all of which are codegenned.

func (FunctionNode) Arguments added in v0.0.7

func (n FunctionNode) Arguments(scope *Scope) ([]*types.Param, []types.Type)

Arguments returns some FunctionNode's arguments

func (FunctionNode) Codegen added in v0.0.7

func (n FunctionNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for FunctionNode

func (FunctionNode) Declare added in v0.0.7

func (n FunctionNode) Declare(scope *Scope, c *Compiler) *ir.Function

Declare declares some FunctionNode's sig

func (FunctionNode) InferType added in v0.0.7

func (n FunctionNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (FunctionNode) MangledName added in v0.0.7

func (n FunctionNode) MangledName(scope *Scope, c *Compiler) string

MangledName will return the mangled name for a function node

func (FunctionNode) NameString added in v0.0.7

func (n FunctionNode) NameString() string

NameString implements Node.NameString

type FunctionScopeItem

type FunctionScopeItem struct {
	// contains filtered or unexported fields
}

FunctionScopeItem implements ScopeItem. This is used so we can store functions in the scope (mainly in the root scope)

func NewFunctionScopeItem

func NewFunctionScopeItem(name string, function *ir.Function, vis Visibility) FunctionScopeItem

NewFunctionScopeItem constructs a function scope item

func (FunctionScopeItem) Mangled

func (item FunctionScopeItem) Mangled() bool

Mangled implements ScopeItem.Mangled()

func (FunctionScopeItem) Name

func (item FunctionScopeItem) Name() string

Name implements ScopeItem.Name()

func (FunctionScopeItem) SetMangled

func (item FunctionScopeItem) SetMangled(m bool)

SetMangled implements ScopeItem.SetMangled()

func (FunctionScopeItem) Type

func (item FunctionScopeItem) Type() ScopeItemType

Type implements ScopeItem.Type()

func (FunctionScopeItem) Value

func (item FunctionScopeItem) Value() value.Value

Value implements ScopeItem.Value()

func (FunctionScopeItem) Visibility

func (item FunctionScopeItem) Visibility() Visibility

Visibility implements ScopeItem.Visibility()

type GeodeBinaryInstr

type GeodeBinaryInstr struct {
	// Parent basic block.
	Parent *ir.BasicBlock
	// Name of the local variable associated with the instruction.
	Name string
	// Operator string.
	Operator string
	// Operands.
	X, Y value.Value
	// Map from metadata identifier (e.g. !dbg) to metadata associated with the
	// instruction.
	Metadata map[string]*metadata.Metadata
}

GeodeBinaryInstr implements ir.Instruction This will be easier than doing individual work per operation

func NewGeodeBinaryInstr

func NewGeodeBinaryInstr(op string, x, y value.Value) *GeodeBinaryInstr

NewGeodeBinaryInstr returns a new geode binary instruction

func (*GeodeBinaryInstr) GetName

func (inst *GeodeBinaryInstr) GetName() string

GetName returns the name of the local variable associated with the instruction.

func (*GeodeBinaryInstr) GetParent

func (inst *GeodeBinaryInstr) GetParent() *ir.BasicBlock

GetParent returns the parent basic block of the instruction.

func (*GeodeBinaryInstr) Ident

func (inst *GeodeBinaryInstr) Ident() string

Ident returns the identifier associated with the instruction.

func (*GeodeBinaryInstr) SetName

func (inst *GeodeBinaryInstr) SetName(name string)

SetName sets the name of the local variable associated with the instruction.

func (*GeodeBinaryInstr) SetParent

func (inst *GeodeBinaryInstr) SetParent(parent *ir.BasicBlock)

SetParent sets the parent basic block of the instruction.

func (*GeodeBinaryInstr) String

func (inst *GeodeBinaryInstr) String() string

String returns the LLVM syntax representation of the instruction.

func (*GeodeBinaryInstr) Type

func (inst *GeodeBinaryInstr) Type() types.Type

Type returns the type of the instruction.

type GeodeTypeRef

type GeodeTypeRef struct {
	Array        bool
	PointerLevel int
	Name         string
}

GeodeTypeRef -

func (GeodeTypeRef) BuildPointerType

func (r GeodeTypeRef) BuildPointerType(t types.Type) types.Type

BuildPointerType will take some type and apply a level of nested pointers

type IfNode added in v0.0.7

type IfNode struct {
	NodeType
	If    Node
	Then  Node
	Else  Node
	Index int
}

IfNode is an if statement representation

func (IfNode) Codegen added in v0.0.7

func (n IfNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for IfNode

func (IfNode) InferType added in v0.0.7

func (n IfNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (IfNode) NameString added in v0.0.7

func (n IfNode) NameString() string

NameString implements Node.NameString

type IntNode added in v0.0.7

type IntNode struct {
	NodeType
	Value int64
}

IntNode is an integer literal

func (IntNode) Codegen added in v0.0.7

func (n IntNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for IntNode

func (IntNode) InferType added in v0.0.7

func (n IntNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (IntNode) NameString added in v0.0.7

func (n IntNode) NameString() string

NameString implements Node.NameString

type LLVMIdent added in v0.0.7

type LLVMIdent struct {
	// Parent basic block.
	Parent *ir.BasicBlock

	// Map from metadata identifier (e.g. !dbg) to metadata associated with the
	// instruction.
	Metadata map[string]*metadata.Metadata
	// contains filtered or unexported fields
}

LLVMIdent implements ir.Instruction This will be easier than doing individual work per operation

func NewLLVMIdent added in v0.0.7

func NewLLVMIdent(typ types.Type, lines ...string) *LLVMIdent

NewLLVMIdent returns a new geode binary instruction

func (*LLVMIdent) GetName added in v0.0.7

func (inst *LLVMIdent) GetName() string

GetName returns the name of the local variable associated with the instruction.

func (*LLVMIdent) GetParent added in v0.0.7

func (inst *LLVMIdent) GetParent() *ir.BasicBlock

GetParent returns the parent basic block of the instruction.

func (*LLVMIdent) Ident added in v0.0.7

func (inst *LLVMIdent) Ident() string

Ident returns the identifier associated with the instruction.

func (*LLVMIdent) SetName added in v0.0.7

func (inst *LLVMIdent) SetName(name string)

SetName sets the name of the local variable associated with the instruction.

func (*LLVMIdent) SetParent added in v0.0.7

func (inst *LLVMIdent) SetParent(parent *ir.BasicBlock)

SetParent sets the parent basic block of the instruction.

func (*LLVMIdent) String added in v0.0.7

func (inst *LLVMIdent) String() string

String returns the LLVM syntax representation of the instruction.

func (*LLVMIdent) Type added in v0.0.7

func (inst *LLVMIdent) Type() types.Type

Type returns the type of the instruction.

type Linker

type Linker struct {
	// contains filtered or unexported fields
}

Linker is an instance that can link several object files into a single binary or other format

func NewLinker

func NewLinker(output string) *Linker

NewLinker constructs a linker with an outpu

func (*Linker) AddObject

func (l *Linker) AddObject(path string)

AddObject appends an object path to a linker

func (*Linker) Cleanup

func (l *Linker) Cleanup()

Cleanup removes all the

func (*Linker) HasObject added in v0.0.7

func (l *Linker) HasObject(path string) bool

HasObject returns if the linker already has a path

func (*Linker) Run

func (l *Linker) Run()

Run a list of objects through a linker and build into a single outfile with the given target

func (*Linker) SetOptimize

func (l *Linker) SetOptimize(o bool)

SetOptimize -

func (*Linker) SetOutput

func (l *Linker) SetOutput(path string)

SetOutput -

func (*Linker) SetTarget

func (l *Linker) SetTarget(t CompileTarget)

SetTarget sets the target output format of the linker be it binary, asm, etc...

type NamespaceNode added in v0.0.7

type NamespaceNode struct {
	NodeType

	Name string
}

NamespaceNode -

func (NamespaceNode) Codegen added in v0.0.7

func (n NamespaceNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen returns some NamespaceNode's arguments

func (NamespaceNode) InferType added in v0.0.7

func (n NamespaceNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (NamespaceNode) NameString added in v0.0.7

func (n NamespaceNode) NameString() string

NameString implements Node.NameString

type Node

type Node interface {
	Kind() NodeType
	NameString() string
	Codegen(*Scope, *Compiler) value.Value
	InferType(scope *Scope) types.Type
}

Node -

func QuickParseExpression added in v0.0.7

func QuickParseExpression(src string) Node

QuickParseExpression takes a stream of tokens and lexes them into a single node

func QuickParseFunction added in v0.0.7

func QuickParseFunction(src string) Node

QuickParseFunction takes a stream of tokens and lexes them into a single node

func QuickParseIdentifier added in v0.0.7

func QuickParseIdentifier(src string) Node

QuickParseIdentifier takes a stream of tokens and lexes them into a single node

type NodeType

type NodeType int

NodeType -

func (NodeType) Kind

func (t NodeType) Kind() NodeType

Kind -

type Package

type Package struct {
	fmt.Stringer

	Name         string
	Source       *lexer.Sourcefile
	Nodes        []Node
	Dependencies []*Package
	Scope        *Scope
	Compiler     *Compiler
	IsRuntime    bool

	Compiled      bool
	CLinkages     []string
	NamespaceName string
	// contains filtered or unexported fields
}

Package is a wrapper around a module. It is able to compile and emit code, as well as lex and parse it.

var RuntimePackage *Package

RuntimePackage is the global runtime package

func GetRuntime added in v0.0.7

func GetRuntime() *Package

GetRuntime builds a runtime

func NewPackage

func NewPackage(name string, source *lexer.Sourcefile) *Package

NewPackage returns a pointer to a new package

func (*Package) AddClinkage added in v0.0.7

func (p *Package) AddClinkage(libPath string)

AddClinkage - takes an absolute path to a c file, and adds it to the link list

func (*Package) AddDepPackage added in v0.0.7

func (p *Package) AddDepPackage(pkg *Package)

AddDepPackage appends a dependency from a pacakge

func (*Package) Compile

func (p *Package) Compile() chan *Package

Compile returns a codegen-ed compiler instance

func (*Package) Emit

func (p *Package) Emit(buildDir string) string

Emit will emit the package as IR to a file for further compiling

func (*Package) Hash

func (p *Package) Hash() []byte

Hash returns the truncated sha1 of the soruce file

func (*Package) Inject

func (p *Package) Inject(c *Package)

Inject another Package's defintions into this Package This is how external dependencies work

func (*Package) InjectExternalFunction

func (p *Package) InjectExternalFunction(from *Package, fn *ir.Function)

InjectExternalFunction injects the function without the body, just the sig

func (*Package) LoadDep added in v0.0.7

func (p *Package) LoadDep(depPath string) *Package

LoadDep appends a dependency from a path

func (*Package) Parse

func (p *Package) Parse() chan *Package

Parse returns a channel of new packages that will be compiled.

func (*Package) String

func (p *Package) String() string

String will get the LLVM IR from the package's compiler

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser -

func NewQuickParser added in v0.0.7

func NewQuickParser(source string) *Parser

NewQuickParser is used to lex and build a parser from tokens quickly for small lexing tasks

func (*Parser) Error

func (p *Parser) Error(format string, args ...interface{})

Error is a helper function to make logging easier

type ReferenceType

type ReferenceType int

ReferenceType is how we go about accessing a variable. Do we just want the value, or do we want to assign to it

const (
	ReferenceDefine ReferenceType = iota
	ReferenceAssign
	ReferenceAccessValue
	ReferenceAccessStackAddress
	ReferenceDereference
)

The different ways you can access a VariableNode

type ReturnNode added in v0.0.7

type ReturnNode struct {
	NodeType
	Value Node
}

ReturnNode is how functions return values from any block A return node contains the value (another Node) that will be codegenned and used in a `NewRet()` call on the parent function

func (ReturnNode) Codegen added in v0.0.7

func (n ReturnNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for ReturnNode

func (ReturnNode) InferType added in v0.0.7

func (n ReturnNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (ReturnNode) NameString added in v0.0.7

func (n ReturnNode) NameString() string

NameString implements Node.NameString

type Scope

type Scope struct {
	Parent *Scope
	Vals   map[string]ScopeItem
	Types  *map[string]*TypeDef
}

Scope trees represent block scoping by having a root scope and children scopes that point back to their parent scope.

func NewScope

func NewScope() *Scope

NewScope creates a scope (for use when generating root scopes)

func (*Scope) Add

func (s *Scope) Add(val ScopeItem)

Add a value to this specific scope

func (*Scope) Find

func (s *Scope) Find(name string) (ScopeItem, bool)

Find will traverse the scope tree to find some definition of a symbol

func (*Scope) FindFunctions

func (s *Scope) FindFunctions(needle string) []FunctionScopeItem

FindFunctions returns a list of functions that might match the name provided The needle can be any of the following: bare name, mangled name

func (*Scope) FindType added in v0.0.7

func (s *Scope) FindType(name string) *TypeDef

FindType returns the type stored with a name in this scope

func (*Scope) InjectPrimitives added in v0.0.7

func (s *Scope) InjectPrimitives()

InjectPrimitives injects primitve types like int, byte, etc

func (*Scope) SpawnChild

func (s *Scope) SpawnChild() *Scope

SpawnChild takes a parent scope and creates a new variable scope for scoped variable access.

type ScopeItem

type ScopeItem interface {
	Type() ScopeItemType
	Value() value.Value // an llvm value
	Visibility() Visibility
	Name() string
	Mangled() bool
	SetMangled(m bool)
}

ScopeItem is what the scope contains.ScopeItem When you set a value in the scope, you must wrap it in a struct implementing ScopeItem

type ScopeItemType

type ScopeItemType int

ScopeItemType -

const (
	ScopeItemFunctionType ScopeItemType = iota
	ScopeItemVariableType
	ScopeItemTypeType
)

The ScopeItemTypes available

type StringNode added in v0.0.7

type StringNode struct {
	NodeType
	Value string
}

StringNode is a string literal

func (StringNode) Codegen added in v0.0.7

func (n StringNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for StringNode

func (StringNode) InferType added in v0.0.7

func (n StringNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (StringNode) NameString added in v0.0.7

func (n StringNode) NameString() string

NameString implements Node.NameString

type TypeDef added in v0.0.7

type TypeDef struct {
	Type types.Type
	Name string
	Prec int
}

TypeDef is a storage for types in the scope. They are stored seperately from variables.

func NewTypeDef added in v0.0.7

func NewTypeDef(name string, t types.Type, prec int) *TypeDef

NewTypeDef constructs a function scope item

func (*TypeDef) InjectInto added in v0.0.7

func (t *TypeDef) InjectInto(s *Scope)

InjectInto will inject the type into a given scope

type UnaryNode added in v0.0.7

type UnaryNode struct {
	NodeType

	Operator string
	Operand  Node
}

UnaryNode is a unary operation representation. Example:

  • !a
  • &value

func (UnaryNode) Codegen added in v0.0.7

func (n UnaryNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for UnaryNode

func (UnaryNode) InferType added in v0.0.7

func (n UnaryNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (UnaryNode) NameString added in v0.0.7

func (n UnaryNode) NameString() string

NameString implements Node.NameString

type VariableNode added in v0.0.7

type VariableNode struct {
	NodeType
	Type         GeodeTypeRef
	HasValue     bool
	Name         string
	IsPointer    bool
	RefType      ReferenceType
	IndexExpr    Node
	IsArray      bool
	Reassignment bool
	Body         Node
}

VariableNode is a generic variable statement representation this contains a reference type inside it that tellst the code generator what kind of variable statement to build

func (VariableNode) Codegen added in v0.0.7

func (n VariableNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for VariableNode

func (VariableNode) InferType added in v0.0.7

func (n VariableNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (VariableNode) NameString added in v0.0.7

func (n VariableNode) NameString() string

NameString implements Node.NameString

type VariableScopeItem

type VariableScopeItem struct {
	// contains filtered or unexported fields
}

VariableScopeItem implements ScopeItem. This is used so we can store functions in the scope (mainly in the root scope)

func NewVariableScopeItem

func NewVariableScopeItem(name string, value value.Value, vis Visibility) VariableScopeItem

NewVariableScopeItem constructs a function scope item

func (VariableScopeItem) Mangled

func (item VariableScopeItem) Mangled() bool

Mangled implements ScopeItem.Mangled()

func (VariableScopeItem) Name

func (item VariableScopeItem) Name() string

Name implements ScopeItem.Name()

func (VariableScopeItem) SetMangled

func (item VariableScopeItem) SetMangled(m bool)

SetMangled implements ScopeItem.SetMangled()

func (VariableScopeItem) Type

func (item VariableScopeItem) Type() ScopeItemType

Type implements ScopeItem.Type()

func (VariableScopeItem) Value

func (item VariableScopeItem) Value() value.Value

Value implements ScopeItem.Value()

func (VariableScopeItem) Visibility

func (item VariableScopeItem) Visibility() Visibility

Visibility implements ScopeItem.Visibility()

type Visibility

type Visibility int

Visibility is the access modifier of some scope variable.

const (
	PublicVisibility Visibility = iota
	PrivateVisibility
)

Visibility options for scope items

type WhileNode added in v0.0.7

type WhileNode struct {
	NodeType

	If    Node
	Body  Node
	Index int
}

WhileNode is a while loop representationvbnm,bvbnm

func (WhileNode) Codegen added in v0.0.7

func (n WhileNode) Codegen(scope *Scope, c *Compiler) value.Value

Codegen implements Node.Codegen for WhileNode

func (WhileNode) InferType added in v0.0.7

func (n WhileNode) InferType(scope *Scope) types.Type

InferType implements Node.InferType

func (WhileNode) NameString added in v0.0.7

func (n WhileNode) NameString() string

NameString implements Node.NameString

Jump to

Keyboard shortcuts

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