js

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CAST_MACRO_NAME = "cast"
)
View Source
const NewRPCClientMemberName = "newRPCClient"

Variables

View Source
var ActivateMacroHeaders func(name string) = nil
View Source
var TARGET = "nodejs"
View Source
var (
	VERBOSITY = 0
)

Functions

func AssertCallable

func AssertCallable(t Token) error

func FillAllScope

func FillAllScope(scope Scope)

func FillBrowserAndWorkerCommonScope

func FillBrowserAndWorkerCommonScope(scope Scope)

func FillBrowserScope

func FillBrowserScope(scope Scope)

func FillCoreScope

func FillCoreScope(scope Scope)

scope provided by all js environments

func FillGlobalScope

func FillGlobalScope(scope Scope)

func FillNodeJSScope

func FillNodeJSScope(scope Scope)

func FillWorkerScope

func FillWorkerScope(scope Scope)

func HashControl

func HashControl(fname string) string

func IsAnyMember

func IsAnyMember(t Expression) bool

func IsAssign

func IsAssign(t Expression) bool

func IsCallable

func IsCallable(t Token) bool

used by the parser

func IsLiteral

func IsLiteral(expr Expression) bool

it is easier to do this via assertion than to add a method to each expression

func IsLiteralInt

func IsLiteralInt(t Expression) bool

func IsLiteralTrue

func IsLiteralTrue(t Expression) bool

func IsMember

func IsMember(t Expression, name string) bool

func IsNodeJSPackage

func IsNodeJSPackage(name string) bool

func IsNotFoundError added in v0.4.1

func IsNotFoundError(err_ error) bool

func IsSimpleAssign

func IsSimpleAssign(t Expression) bool

func IsSimpleLT

func IsSimpleLT(t Expression) bool

func IsSimplePostIncr

func IsSimplePostIncr(t Expression) bool

func IsVarExpression

func IsVarExpression(t Expression) bool

func IsVoidReturn

func IsVoidReturn(t Token) bool

func MergeContexts

func MergeContexts(ts ...Token) context.Context

func ReserveMacroNames

func ReserveMacroNames(scope Scope)

func VarTypeToString

func VarTypeToString(varType VarType) string

func WriteGlobalHeaders

func WriteGlobalHeaders(nl string, tab string) string

Types

type AddOp

type AddOp struct {
	BinaryOp
}

func (*AddOp) EvalExpression

func (t *AddOp) EvalExpression() (values.Value, error)

func (*AddOp) Walk

func (t *AddOp) Walk(fn WalkFunc) error

type Assign

type Assign struct {
	TokenData
	// contains filtered or unexported fields
}

func NewAssign

func NewAssign(lhs Expression, rhs Expression, op string, ctx context.Context) *Assign

func (*Assign) AddStatement

func (t *Assign) AddStatement(st Statement)

func (*Assign) Args

func (t *Assign) Args() []Token

func (*Assign) Dump

func (t *Assign) Dump(indent string) string

func (*Assign) EvalExpression

func (t *Assign) EvalExpression() (values.Value, error)

func (*Assign) EvalStatement

func (t *Assign) EvalStatement() error

func (*Assign) GetLhsVarExpression

func (t *Assign) GetLhsVarExpression() (*VarExpression, error)

func (*Assign) HasLhsVarExpression

func (t *Assign) HasLhsVarExpression() bool

func (*Assign) HoistNames

func (t *Assign) HoistNames(scope Scope) error

func (*Assign) IsRegular

func (t *Assign) IsRegular() bool

func (*Assign) ResolveExpressionActivity

func (t *Assign) ResolveExpressionActivity(usage Usage) error

func (*Assign) ResolveExpressionNames

func (t *Assign) ResolveExpressionNames(scope Scope) error

func (*Assign) ResolveStatementActivity

func (t *Assign) ResolveStatementActivity(usage Usage) error

func (*Assign) ResolveStatementNames

func (t *Assign) ResolveStatementNames(scope Scope) error

func (*Assign) UniqueExpressionNames

func (t *Assign) UniqueExpressionNames(ns Namespace) error

func (*Assign) UniqueStatementNames

func (t *Assign) UniqueStatementNames(ns Namespace) error

func (*Assign) UniversalExpressionNames

func (t *Assign) UniversalExpressionNames(ns Namespace) error

func (*Assign) UniversalStatementNames

func (t *Assign) UniversalStatementNames(ns Namespace) error

func (*Assign) Walk

func (t *Assign) Walk(fn WalkFunc) error

func (*Assign) WriteExpression

func (t *Assign) WriteExpression() string

func (*Assign) WriteStatement

func (t *Assign) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Await

type Await struct {
	TokenData
	// contains filtered or unexported fields
}

func NewAwait

func NewAwait(expr Expression, ctx context.Context) (*Await, error)

func (*Await) AddStatement

func (t *Await) AddStatement(st Statement)

func (*Await) Args

func (t *Await) Args() []Token

func (*Await) Dump

func (t *Await) Dump(indent string) string

func (*Await) EvalExpression

func (t *Await) EvalExpression() (values.Value, error)

func (*Await) EvalStatement

func (t *Await) EvalStatement() error

func (*Await) HoistNames

func (t *Await) HoistNames(scope Scope) error

func (*Await) ResolveExpressionActivity

func (t *Await) ResolveExpressionActivity(usage Usage) error

func (*Await) ResolveExpressionNames

func (t *Await) ResolveExpressionNames(scope Scope) error

func (*Await) ResolveStatementActivity

func (t *Await) ResolveStatementActivity(usage Usage) error

func (*Await) ResolveStatementNames

func (t *Await) ResolveStatementNames(scope Scope) error

func (*Await) UniqueExpressionNames

func (t *Await) UniqueExpressionNames(ns Namespace) error

func (*Await) UniqueStatementNames

func (t *Await) UniqueStatementNames(ns Namespace) error

func (*Await) UniversalExpressionNames

func (t *Await) UniversalExpressionNames(ns Namespace) error

func (*Await) UniversalStatementNames

func (t *Await) UniversalStatementNames(ns Namespace) error

func (*Await) Walk

func (t *Await) Walk(fn WalkFunc) error

func (*Await) WriteExpression

func (t *Await) WriteExpression() string

func (*Await) WriteStatement

func (t *Await) WriteStatement(usage Usage, indent string, nl string, tab string) string

type BinaryBitOp

type BinaryBitOp struct {
	BinaryOp
}

func (*BinaryBitOp) EvalExpression

func (t *BinaryBitOp) EvalExpression() (values.Value, error)

func (*BinaryBitOp) Walk

func (t *BinaryBitOp) Walk(fn WalkFunc) error

TODO: implement for each special function

type BinaryOp

type BinaryOp struct {
	TokenData
	// contains filtered or unexported fields
}

func (*BinaryOp) Args

func (t *BinaryOp) Args() []Token

func (*BinaryOp) Dump

func (t *BinaryOp) Dump(indent string) string

func (*BinaryOp) ResolveExpressionActivity

func (t *BinaryOp) ResolveExpressionActivity(usage Usage) error

func (*BinaryOp) ResolveExpressionNames

func (t *BinaryOp) ResolveExpressionNames(scope Scope) error

func (*BinaryOp) UniqueExpressionNames

func (t *BinaryOp) UniqueExpressionNames(ns Namespace) error

func (*BinaryOp) UniversalExpressionNames

func (t *BinaryOp) UniversalExpressionNames(ns Namespace) error

func (*BinaryOp) Walk

func (t *BinaryOp) Walk(fn WalkFunc) error

func (*BinaryOp) WriteExpression

func (t *BinaryOp) WriteExpression() string

type BitAndOp

type BitAndOp struct {
	BinaryBitOp
}

type BitNotOp

type BitNotOp struct {
	PreUnaryOp
}

func (*BitNotOp) EvalExpression

func (t *BitNotOp) EvalExpression() (values.Value, error)

func (*BitNotOp) Walk

func (t *BitNotOp) Walk(fn WalkFunc) error

type BitOrOp

type BitOrOp struct {
	BinaryBitOp
}

type BitXorOp

type BitXorOp struct {
	BinaryBitOp
}

type Block

type Block struct {
	TokenData
	// contains filtered or unexported fields
}

func (*Block) AddStatement

func (t *Block) AddStatement(statement Statement)

func (*Block) Dump

func (t *Block) Dump(indent string) string

func (*Block) EvalStatement

func (t *Block) EvalStatement() error

func (*Block) HoistAndResolveStatementNames

func (t *Block) HoistAndResolveStatementNames(scope Scope) error

func (*Block) HoistNames

func (t *Block) HoistNames(scope Scope) error

///////////////////////// 1. Name resolution stage /////////////////////////

func (*Block) NewScope

func (t *Block) NewScope(parent Scope) Scope

func (*Block) ResolveStatementActivity

func (t *Block) ResolveStatementActivity(usage Usage) error

func (*Block) ResolveStatementNames

func (t *Block) ResolveStatementNames(scope Scope) error

func (*Block) UniqueStatementNames

func (t *Block) UniqueStatementNames(ns Namespace) error

func (*Block) UniversalStatementNames

func (t *Block) UniversalStatementNames(ns Namespace) error

func (*Block) Walk

func (t *Block) Walk(fn WalkFunc) error

type BlockScope

type BlockScope struct {
	ScopeData
}

func NewBlockScope

func NewBlockScope(parent Scope) *BlockScope

func (*BlockScope) SetVariable

func (t *BlockScope) SetVariable(name string, v Variable) error

vars are hoisted out (use SubScope to avoid this)

type BranchScope

type BranchScope struct {
	ScopeData
}

func NewBranchScope

func NewBranchScope(parent Scope) *BranchScope

func (*BranchScope) IsAsync

func (scope *BranchScope) IsAsync() bool

func (*BranchScope) IsBreakable

func (scope *BranchScope) IsBreakable() bool

func (*BranchScope) IsContinueable

func (scope *BranchScope) IsContinueable() bool

type Break

type Break struct {
	TokenData
}

func NewBreak

func NewBreak(ctx context.Context) (*Break, error)

func (*Break) AddStatement

func (t *Break) AddStatement(st Statement)

func (*Break) Dump

func (t *Break) Dump(indent string) string

func (*Break) EvalStatement

func (t *Break) EvalStatement() error

func (*Break) HoistNames

func (t *Break) HoistNames(scope Scope) error

func (*Break) ResolveStatementActivity

func (t *Break) ResolveStatementActivity(usage Usage) error

func (*Break) ResolveStatementNames

func (t *Break) ResolveStatementNames(scope Scope) error

func (*Break) UniqueStatementNames

func (t *Break) UniqueStatementNames(ns Namespace) error

func (*Break) UniversalStatementNames

func (t *Break) UniversalStatementNames(ns Namespace) error

func (*Break) Walk

func (t *Break) Walk(fn WalkFunc) error

func (*Break) WriteStatement

func (t *Break) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Call

type Call struct {
	TokenData
	// contains filtered or unexported fields
}

func NewCall

func NewCall(lhs Expression, args []Expression, ctx context.Context) *Call

func (*Call) AddStatement

func (t *Call) AddStatement(st Statement)

func (*Call) Args

func (t *Call) Args() []Expression

func (*Call) Dump

func (t *Call) Dump(indent string) string

func (*Call) EvalExpression

func (t *Call) EvalExpression() (values.Value, error)

func (*Call) EvalStatement

func (t *Call) EvalStatement() error

func (*Call) HoistNames

func (t *Call) HoistNames(scope Scope) error

func (*Call) Name

func (t *Call) Name() string

returns empty string if lhs is not *VarExpression

func (*Call) ResolveExpressionActivity

func (t *Call) ResolveExpressionActivity(usage Usage) error

func (*Call) ResolveExpressionNames

func (t *Call) ResolveExpressionNames(scope Scope) error

func (*Call) ResolveStatementActivity

func (t *Call) ResolveStatementActivity(usage Usage) error

func (*Call) ResolveStatementNames

func (t *Call) ResolveStatementNames(scope Scope) error

func (*Call) UniqueExpressionNames

func (t *Call) UniqueExpressionNames(ns Namespace) error

func (*Call) UniqueStatementNames

func (t *Call) UniqueStatementNames(ns Namespace) error

func (*Call) UniversalExpressionNames

func (t *Call) UniversalExpressionNames(ns Namespace) error

func (*Call) UniversalStatementNames

func (t *Call) UniversalStatementNames(ns Namespace) error

func (*Call) Walk

func (t *Call) Walk(fn WalkFunc) error

func (*Call) WriteExpression

func (t *Call) WriteExpression() string

func (*Call) WriteStatement

func (t *Call) WriteStatement(usage Usage, indent string, nl string, tab string) string

type CaseScope

type CaseScope struct {
	ScopeData
}

func NewCaseScope

func NewCaseScope(parent Scope) *CaseScope

func (*CaseScope) IsAsync

func (scope *CaseScope) IsAsync() bool

func (*CaseScope) IsBreakable

func (scope *CaseScope) IsBreakable() bool

func (*CaseScope) IsContinueable

func (scope *CaseScope) IsContinueable() bool

type Class

type Class struct {
	TokenData
	// contains filtered or unexported fields
}

only support single inheritance (easier to maintain code, and similar to java)

func NewClass

func NewClass(nameExpr *TypeExpression, parentExpr *TypeExpression, interfExprs []*VarExpression, isAbstract bool, isFinal bool, universalName string, ctx context.Context) (*Class, error)

func (*Class) AddConstructor

func (t *Class) AddConstructor(fn *Function) error

func (*Class) AddFunction

func (t *Class) AddFunction(fn *Function) error

func (*Class) AddProperty

func (t *Class) AddProperty(name *Word, expr *TypeExpression) error

func (*Class) AddStatement

func (t *Class) AddStatement(st Statement)

func (*Class) Check

func (t *Class) Check(other_ values.Interface, ctx context.Context) error

func (*Class) Dump

func (t *Class) Dump(indent string) string

func (*Class) EvalExpression

func (t *Class) EvalExpression() (values.Value, error)

func (*Class) EvalStatement

func (t *Class) EvalStatement() error

func (*Class) GetClassMember

func (t *Class) GetClassMember(key string, includePrivate bool, ctx context.Context) (values.Value, error)

func (*Class) GetClassValue

func (t *Class) GetClassValue() (*values.Class, error)

func (*Class) GetInstanceMember

func (t *Class) GetInstanceMember(key string, includePrivate bool, ctx context.Context) (values.Value, error)

potentially return Setter/Getter as second ClassMember return non-nil prototypes.BuiltinPrototype for further specific searching

func (*Class) GetInterfaces

func (t *Class) GetInterfaces() ([]values.Interface, error)

func (*Class) GetParent

func (t *Class) GetParent() (values.Prototype, error)

available after resolve names stage returns nil if not found

func (*Class) GetPrototypes

func (t *Class) GetPrototypes() ([]values.Prototype, error)

func (*Class) GetVariable

func (t *Class) GetVariable() Variable

func (*Class) HoistNames

func (t *Class) HoistNames(scope Scope) error

func (*Class) IsAbstract

func (t *Class) IsAbstract() bool

func (*Class) IsFinal

func (t *Class) IsFinal() bool

func (*Class) IsRPC

func (t *Class) IsRPC() bool

func (*Class) IsUniversal

func (t *Class) IsUniversal() bool

func (*Class) Name

func (t *Class) Name() string

func (*Class) Properties

func (t *Class) Properties() (map[string]values.Value, error)

func (*Class) ResolveExpressionActivity

func (t *Class) ResolveExpressionActivity(usage Usage) error

func (*Class) ResolveExpressionNames

func (t *Class) ResolveExpressionNames(scope Scope) error

func (*Class) ResolveStatementActivity

func (t *Class) ResolveStatementActivity(usage Usage) error

func (*Class) ResolveStatementNames

func (t *Class) ResolveStatementNames(scope Scope) error

func (*Class) SetInstanceMember

func (t *Class) SetInstanceMember(key string, includePrivate bool, arg values.Value, ctx context.Context) error

func (*Class) UniqueExpressionNames

func (t *Class) UniqueExpressionNames(ns Namespace) error

func (*Class) UniqueStatementNames

func (t *Class) UniqueStatementNames(ns Namespace) error

func (*Class) UniversalExpressionNames

func (t *Class) UniversalExpressionNames(ns Namespace) error

func (*Class) UniversalStatementNames

func (t *Class) UniversalStatementNames(ns Namespace) error

func (*Class) Walk

func (t *Class) Walk(fn WalkFunc) error

func (*Class) WriteExpression

func (t *Class) WriteExpression() string

func (*Class) WriteStatement

func (t *Class) WriteStatement(usage Usage, indent string, nl string, tab string) string

type ClassFunction

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

implements the values.Callable interface

func NewClassFunction

func NewClassFunction(fn *Function) *ClassFunction

func (*ClassFunction) Context

func (m *ClassFunction) Context() context.Context

func (*ClassFunction) Dump

func (m *ClassFunction) Dump(indent string) string

func (*ClassFunction) Eval

func (m *ClassFunction) Eval() error

func (*ClassFunction) GetThisVariable

func (m *ClassFunction) GetThisVariable() Variable

func (*ClassFunction) GetValue

func (m *ClassFunction) GetValue(ctx context.Context) (values.Value, error)

func (*ClassFunction) IsUniversal

func (m *ClassFunction) IsUniversal() bool

func (*ClassFunction) Name

func (m *ClassFunction) Name() string

func (*ClassFunction) ResolveActivity

func (m *ClassFunction) ResolveActivity(usage Usage) error

func (*ClassFunction) ResolveNames

func (m *ClassFunction) ResolveNames(scope Scope) error

func (*ClassFunction) Role

func (*ClassFunction) SetValue

func (m *ClassFunction) SetValue(v values.Value, ctx context.Context) error

func (*ClassFunction) UniqueNames

func (m *ClassFunction) UniqueNames(ns Namespace) error

func (*ClassFunction) UniversalNames

func (m *ClassFunction) UniversalNames(ns Namespace) error

func (*ClassFunction) Walk

func (m *ClassFunction) Walk(fn WalkFunc) error

func (*ClassFunction) WriteStatement

func (m *ClassFunction) WriteStatement(usage Usage, indent string, nl string, tab string) string

type ClassMember

type ClassMember interface {
	Context() context.Context
	Name() string
	Dump(indent string) string
	WriteStatement(usage Usage, indent string, nl string, tab string) string
	Role() prototypes.FunctionRole

	IsUniversal() bool // functions are always universal, properties not necessarily
	ResolveNames(scope Scope) error

	GetValue(ctx context.Context) (values.Value, error)
	SetValue(v values.Value, ctx context.Context) error
	Eval() error

	ResolveActivity(usage Usage) error
	UniversalNames(ns Namespace) error
	UniqueNames(ns Namespace) error
	Walk(fn WalkFunc) error
}

type ClassProperty

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

func NewClassProperty

func NewClassProperty(name *Word, typeExpr *TypeExpression) *ClassProperty

func (*ClassProperty) Context

func (p *ClassProperty) Context() context.Context

func (*ClassProperty) Dump

func (p *ClassProperty) Dump(indent string) string

func (*ClassProperty) Eval

func (p *ClassProperty) Eval() error

func (*ClassProperty) GetValue

func (p *ClassProperty) GetValue(ctx context.Context) (values.Value, error)

func (*ClassProperty) IsUniversal

func (p *ClassProperty) IsUniversal() bool

func (*ClassProperty) Name

func (p *ClassProperty) Name() string

func (*ClassProperty) ResolveActivity

func (p *ClassProperty) ResolveActivity(usage Usage) error

func (*ClassProperty) ResolveNames

func (p *ClassProperty) ResolveNames(scope Scope) error

func (*ClassProperty) Role

func (*ClassProperty) SetValue

func (p *ClassProperty) SetValue(v values.Value, ctx context.Context) error

func (*ClassProperty) UniqueNames

func (p *ClassProperty) UniqueNames(ns Namespace) error

func (*ClassProperty) UniversalNames

func (p *ClassProperty) UniversalNames(ns Namespace) error

func (*ClassProperty) Walk

func (p *ClassProperty) Walk(fn WalkFunc) error

func (*ClassProperty) WriteStatement

func (p *ClassProperty) WriteStatement(usage Usage, indent string, nl string, tab string) string

type ClassScope

type ClassScope struct {
	ScopeData
	// contains filtered or unexported fields
}

func NewClassScope

func NewClassScope(class *Class, parent Scope) *ClassScope

func (*ClassScope) FriendlyPrototypes

func (s *ClassScope) FriendlyPrototypes() []values.Prototype

type Continue

type Continue struct {
	TokenData
}

func NewContinue

func NewContinue(ctx context.Context) (*Continue, error)

func (*Continue) AddStatement

func (t *Continue) AddStatement(st Statement)

func (*Continue) Dump

func (t *Continue) Dump(indent string) string

func (*Continue) EvalStatement

func (t *Continue) EvalStatement() error

func (*Continue) HoistNames

func (t *Continue) HoistNames(scope Scope) error

func (*Continue) ResolveStatementActivity

func (t *Continue) ResolveStatementActivity(usage Usage) error

func (*Continue) ResolveStatementNames

func (t *Continue) ResolveStatementNames(scope Scope) error

func (*Continue) UniqueStatementNames

func (t *Continue) UniqueStatementNames(ns Namespace) error

func (*Continue) UniversalStatementNames

func (t *Continue) UniversalStatementNames(ns Namespace) error

func (*Continue) Walk

func (t *Continue) Walk(fn WalkFunc) error

func (*Continue) WriteStatement

func (t *Continue) WriteStatement(usage Usage, indent string, nl string, tab string) string

type DeleteOp

type DeleteOp struct {
	PreUnaryOp
}

func NewDeleteOp

func NewDeleteOp(a Expression, ctx context.Context) *DeleteOp

func (*DeleteOp) EvalExpression

func (t *DeleteOp) EvalExpression() (values.Value, error)

func (*DeleteOp) EvalStatement

func (t *DeleteOp) EvalStatement() error

func (*DeleteOp) ResolveStatementActivity

func (t *DeleteOp) ResolveStatementActivity(usage Usage) error

func (*DeleteOp) ResolveStatementNames

func (t *DeleteOp) ResolveStatementNames(scope Scope) error

func (*DeleteOp) UniqueStatementNames

func (t *DeleteOp) UniqueStatementNames(ns Namespace) error

func (*DeleteOp) UniversalStatementNames

func (t *DeleteOp) UniversalStatementNames(ns Namespace) error

func (*DeleteOp) Walk

func (t *DeleteOp) Walk(fn WalkFunc) error

func (*DeleteOp) WriteStatement

func (t *DeleteOp) WriteStatement(usage Usage, indent string, nl string, tab string) string

type DivOp

type DivOp struct {
	BinaryOp
}

func (*DivOp) EvalExpression

func (t *DivOp) EvalExpression() (values.Value, error)

func (*DivOp) Walk

func (t *DivOp) Walk(fn WalkFunc) error

type DontKeepSignRightShiftOp

type DontKeepSignRightShiftOp struct {
	ShiftOp
}

type Enum

type Enum struct {
	TokenData
	// contains filtered or unexported fields
}

enum is a statement (and also a Class!)

func NewEnum

func NewEnum(nameExpr *TypeExpression, parentExpr *TypeExpression, keys []*Word,
	vs []Expression, ctx context.Context) (*Enum, error)

func (*Enum) AddStatement

func (t *Enum) AddStatement(st Statement)

func (*Enum) Check

func (t *Enum) Check(other_ values.Interface, ctx context.Context) error

func (*Enum) Dump

func (t *Enum) Dump(indent string) string

func (*Enum) EvalStatement

func (t *Enum) EvalStatement() error

XXX: should enums be available as expressions

func (*Enum) GetClassMember

func (t *Enum) GetClassMember(key string, includePrivate bool, ctx context.Context) (values.Value, error)

func (*Enum) GetClassValue

func (t *Enum) GetClassValue() (*values.Class, error)

can never be directly constructed

func (*Enum) GetEnumValue

func (t *Enum) GetEnumValue() (*values.Enum, error)

func (*Enum) GetInstanceMember

func (t *Enum) GetInstanceMember(key string, includePrivate bool, ctx context.Context) (values.Value, error)

func (*Enum) GetInterfaces

func (t *Enum) GetInterfaces() ([]values.Interface, error)

func (*Enum) GetParent

func (t *Enum) GetParent() (values.Prototype, error)

func (*Enum) GetPrototypes

func (t *Enum) GetPrototypes() ([]values.Prototype, error)

func (*Enum) GetVariable

func (t *Enum) GetVariable() Variable

func (*Enum) HoistNames

func (t *Enum) HoistNames(scope Scope) error

func (*Enum) IsAbstract

func (t *Enum) IsAbstract() bool

func (*Enum) IsFinal

func (t *Enum) IsFinal() bool

func (*Enum) IsRPC

func (t *Enum) IsRPC() bool

func (*Enum) IsUniversal

func (t *Enum) IsUniversal() bool

func (*Enum) Name

func (t *Enum) Name() string

func (*Enum) ResolveStatementActivity

func (t *Enum) ResolveStatementActivity(usage Usage) error

func (*Enum) ResolveStatementNames

func (t *Enum) ResolveStatementNames(scope Scope) error

func (*Enum) SetInstanceMember

func (t *Enum) SetInstanceMember(key string, includePrivate bool, arg values.Value, ctx context.Context) error

func (*Enum) UniqueStatementNames

func (t *Enum) UniqueStatementNames(ns Namespace) error

func (*Enum) UniversalStatementNames

func (t *Enum) UniversalStatementNames(ns Namespace) error

func (*Enum) Walk

func (t *Enum) Walk(fn WalkFunc) error

func (*Enum) WriteStatement

func (t *Enum) WriteStatement(usage Usage, indent string, nl string, tab string) string

type EnumMember

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

func (*EnumMember) Context

func (m *EnumMember) Context() context.Context

func (*EnumMember) Eval

func (m *EnumMember) Eval() (values.Value, error)

func (*EnumMember) Walk

func (m *EnumMember) Walk(fn WalkFunc) error

type EqCompareOp

type EqCompareOp struct {
	BinaryOp
}

func (*EqCompareOp) EvalExpression

func (t *EqCompareOp) EvalExpression() (values.Value, error)

func (*EqCompareOp) Walk

func (t *EqCompareOp) Walk(fn WalkFunc) error

TODO: implement for specific types

type EqOp

type EqOp struct {
	EqCompareOp
}

type Export

type Export struct {
	TokenData
	// contains filtered or unexported fields
}

func NewExport

func NewExport(newName *Word, varExpr *VarExpression, ctx context.Context) *Export

func (*Export) AddStatement

func (t *Export) AddStatement(st Statement)

func (*Export) Dump

func (t *Export) Dump(indent string) string

func (*Export) EvalStatement

func (t *Export) EvalStatement() error

func (*Export) HoistNames

func (t *Export) HoistNames(scope Scope) error

func (*Export) ResolveStatementActivity

func (t *Export) ResolveStatementActivity(usage Usage) error

func (*Export) ResolveStatementNames

func (t *Export) ResolveStatementNames(scope Scope) error

func (*Export) UniqueStatementNames

func (t *Export) UniqueStatementNames(ns Namespace) error

func (*Export) UniversalStatementNames

func (t *Export) UniversalStatementNames(ns Namespace) error

func (*Export) Walk

func (t *Export) Walk(fn WalkFunc) error

func (*Export) WriteStatement

func (t *Export) WriteStatement(usage Usage, indent string, nl string, tab string) string

type ExportedVariable

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

type Expression

type Expression interface {
	WriteExpression() string

	ResolveExpressionNames(scope Scope) error

	EvalExpression() (values.Value, error)

	ResolveExpressionActivity(usage Usage) error

	// universal names need to be registered before other unique names are generated
	UniversalExpressionNames(ns Namespace) error

	UniqueExpressionNames(ns Namespace) error

	Walk(fn WalkFunc) error

	Token
}

type FillPackageFunction

type FillPackageFunction func(pkg values.Package)

type For

type For struct {
	ForBlock
	// contains filtered or unexported fields
}

func NewFor

func NewFor(varType VarType, inits []Expression, cond Expression, incrs []Expression,
	ctx context.Context) (*For, error)

inits can be empty, cond can be nil, incrs can be empty in extreme case 'for(;;);' is written

func (*For) Dump

func (t *For) Dump(indent string) string

func (*For) EvalStatement

func (t *For) EvalStatement() error

func (*For) HoistNames

func (t *For) HoistNames(scope Scope) error

func (*For) ResolveStatementActivity

func (t *For) ResolveStatementActivity(usage Usage) error

func (*For) ResolveStatementNames

func (t *For) ResolveStatementNames(scope Scope) error

func (*For) UniqueStatementNames

func (t *For) UniqueStatementNames(ns Namespace) error

func (*For) UniversalStatementNames

func (t *For) UniversalStatementNames(ns Namespace) error

func (*For) Walk

func (t *For) Walk(fn WalkFunc) error

func (*For) WriteStatement

func (t *For) WriteStatement(usage Usage, indent string, nl string, tab string) string

type ForBlock

type ForBlock struct {
	Block
	// contains filtered or unexported fields
}

common for For, ForIn, ForOf all for statements must specify a new variable using const, let or var

type ForIn

type ForIn struct {
	ForInOf
}

func NewForIn

func NewForIn(varType VarType, lhs *VarExpression, rhs Expression, ctx context.Context) (*ForIn, error)

func (*ForIn) Dump

func (t *ForIn) Dump(indent string) string

func (*ForIn) EvalStatement

func (t *ForIn) EvalStatement() error

func (*ForIn) Walk

func (t *ForIn) Walk(fn WalkFunc) error

func (*ForIn) WriteStatement

func (t *ForIn) WriteStatement(usage Usage, indent string, nl string, tab string) string

type ForInOf

type ForInOf struct {
	ForBlock
	// contains filtered or unexported fields
}

common base class for ForIn and ForOf

func (*ForInOf) HoistNames

func (t *ForInOf) HoistNames(scope Scope) error

///////////////////////// 1. Name resolution stage /////////////////////////

func (*ForInOf) ResolveStatementActivity

func (t *ForInOf) ResolveStatementActivity(usage Usage) error

func (*ForInOf) ResolveStatementNames

func (t *ForInOf) ResolveStatementNames(scope Scope) error

func (*ForInOf) UniqueStatementNames

func (t *ForInOf) UniqueStatementNames(ns Namespace) error

func (*ForInOf) UniversalStatementNames

func (t *ForInOf) UniversalStatementNames(ns Namespace) error

func (*ForInOf) Walk

func (t *ForInOf) Walk(fn WalkFunc) error

type ForOf

type ForOf struct {
	ForInOf
	// contains filtered or unexported fields
}

func NewForOf

func NewForOf(await bool, varType VarType, lhs *VarExpression, rhs Expression,
	ctx context.Context) (*ForOf, error)

func (*ForOf) Dump

func (t *ForOf) Dump(indent string) string

func (*ForOf) EvalStatement

func (t *ForOf) EvalStatement() error

func (*ForOf) Walk

func (t *ForOf) Walk(fn WalkFunc) error

func (*ForOf) WriteStatement

func (t *ForOf) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Function

type Function struct {
	Block
	// contains filtered or unexported fields
}

func NewFunction

func NewFunction(fi *FunctionInterface, isArrow bool,
	ctx context.Context) (*Function, error)

func (*Function) Dump

func (t *Function) Dump(indent string) string

func (*Function) EvalExpression

func (t *Function) EvalExpression() (values.Value, error)

func (*Function) EvalStatement

func (t *Function) EvalStatement() error

func (*Function) GetArgValues

func (t *Function) GetArgValues() ([]values.Value, error)

func (*Function) GetFunctionValue

func (t *Function) GetFunctionValue() (*values.Function, error)

func (*Function) GetReturnValue

func (t *Function) GetReturnValue() (values.Value, error)

post async return type can be nil in case of void

func (*Function) GetThisVariable

func (t *Function) GetThisVariable() Variable

func (*Function) GetVariable

func (t *Function) GetVariable() Variable

func (*Function) HoistNames

func (t *Function) HoistNames(scope Scope) error

func (*Function) Interface

func (t *Function) Interface() *FunctionInterface

func (*Function) IsAsync

func (t *Function) IsAsync() bool

func (*Function) IsVoid

func (t *Function) IsVoid() bool

func (*Function) Length

func (t *Function) Length() int

func (*Function) Name

func (t *Function) Name() string

func (*Function) NewScope

func (t *Function) NewScope(parent Scope) *FunctionScope

func (*Function) RegisterReturn

func (t *Function) RegisterReturn(ret *Return)

func (*Function) ResolveExpressionActivity

func (t *Function) ResolveExpressionActivity(usage Usage) error

func (*Function) ResolveExpressionNames

func (t *Function) ResolveExpressionNames(outer Scope) error

func (*Function) ResolveStatementActivity

func (t *Function) ResolveStatementActivity(usage Usage) error

func (*Function) ResolveStatementNames

func (t *Function) ResolveStatementNames(scope Scope) error

func (*Function) Role

func (t *Function) Role() prototypes.FunctionRole

func (*Function) UniqueExpressionNames

func (t *Function) UniqueExpressionNames(ns Namespace) error

func (*Function) UniqueStatementNames

func (t *Function) UniqueStatementNames(ns Namespace) error

func (*Function) UniversalExpressionNames

func (t *Function) UniversalExpressionNames(ns Namespace) error

func (*Function) UniversalStatementNames

func (t *Function) UniversalStatementNames(ns Namespace) error

func (*Function) Walk

func (t *Function) Walk(fn WalkFunc) error

func (*Function) WriteExpression

func (t *Function) WriteExpression() string

func (*Function) WriteStatement

func (t *Function) WriteStatement(usage Usage, indent string, nl string, tab string) string

type FunctionArgument

type FunctionArgument struct {
	TokenData
	// contains filtered or unexported fields
}

func NewFunctionArgument

func NewFunctionArgument(name string, typeExpr *TypeExpression, def Expression,
	ctx context.Context) (*FunctionArgument, error)

func (*FunctionArgument) AssertNoDefault

func (fa *FunctionArgument) AssertNoDefault() error

func (*FunctionArgument) Dump

func (fa *FunctionArgument) Dump(indent string) string

func (*FunctionArgument) Eval

func (fa *FunctionArgument) Eval() error

func (*FunctionArgument) GetValue

func (fa *FunctionArgument) GetValue() (values.Value, error)

func (*FunctionArgument) GetVariable

func (fa *FunctionArgument) GetVariable() Variable

func (*FunctionArgument) HasDefault

func (fa *FunctionArgument) HasDefault() bool

func (*FunctionArgument) Name

func (fa *FunctionArgument) Name() string

func (*FunctionArgument) ResolveInterfaceNames

func (fa *FunctionArgument) ResolveInterfaceNames(scope Scope) error

func (*FunctionArgument) ResolveNames

func (fa *FunctionArgument) ResolveNames(scope Scope) error

func (*FunctionArgument) TypeName

func (fa *FunctionArgument) TypeName() string

func (*FunctionArgument) UniqueNames

func (fa *FunctionArgument) UniqueNames(ns Namespace) error

func (*FunctionArgument) UniversalNames

func (fa *FunctionArgument) UniversalNames(ns Namespace) error

func (*FunctionArgument) Walk

func (fa *FunctionArgument) Walk(fn WalkFunc) error

func (*FunctionArgument) Write

func (fa *FunctionArgument) Write() string

type FunctionInterface

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

func NewFunctionInterface

func NewFunctionInterface(name string, role prototypes.FunctionRole,
	ctx context.Context) *FunctionInterface

func (*FunctionInterface) AppendArg

func (fi *FunctionInterface) AppendArg(arg *FunctionArgument)

func (*FunctionInterface) AssertNoDefaults

func (fi *FunctionInterface) AssertNoDefaults() error

func (*FunctionInterface) CheckRPC

func (fi *FunctionInterface) CheckRPC() error

func (*FunctionInterface) Context

func (fi *FunctionInterface) Context() context.Context

func (*FunctionInterface) Dump

func (fi *FunctionInterface) Dump() string

func (*FunctionInterface) Eval

func (fi *FunctionInterface) Eval() error

func (*FunctionInterface) GetArgValues

func (fi *FunctionInterface) GetArgValues() ([]values.Value, error)

func (*FunctionInterface) GetFunctionValue

func (fi *FunctionInterface) GetFunctionValue() (*values.Function, error)

func (*FunctionInterface) GetReturnValue

func (fi *FunctionInterface) GetReturnValue() (values.Value, error)

post async

func (*FunctionInterface) GetVariable

func (fi *FunctionInterface) GetVariable() Variable

func (*FunctionInterface) IsVoid

func (fi *FunctionInterface) IsVoid() bool

func (*FunctionInterface) Length

func (fi *FunctionInterface) Length() int

func (*FunctionInterface) Name

func (fi *FunctionInterface) Name() string

func (*FunctionInterface) ResolveNames

func (fi *FunctionInterface) ResolveNames(scope Scope) error

func (*FunctionInterface) Role

func (*FunctionInterface) SetReturnType

func (fi *FunctionInterface) SetReturnType(ret *TypeExpression)

used by parser to gradually fill the interface struct

func (*FunctionInterface) SetRole

func (fi *FunctionInterface) SetRole(r prototypes.FunctionRole)

func (*FunctionInterface) UniqueNames

func (fi *FunctionInterface) UniqueNames(ns Namespace) error

func (*FunctionInterface) UniversalNames

func (fi *FunctionInterface) UniversalNames(ns Namespace) error

func (*FunctionInterface) Walk

func (fi *FunctionInterface) Walk(fn WalkFunc) error

func (*FunctionInterface) Write

func (fi *FunctionInterface) Write() string

type FunctionScope

type FunctionScope struct {
	ScopeData
	// contains filtered or unexported fields
}

func NewFunctionScope

func NewFunctionScope(fn *Function, parent Scope) *FunctionScope

func (*FunctionScope) GetFunction

func (fs *FunctionScope) GetFunction() *Function

func (*FunctionScope) IsAsync

func (fs *FunctionScope) IsAsync() bool

func (*FunctionScope) SetVariable

func (fs *FunctionScope) SetVariable(name string, v Variable) error

type GEOp

type GEOp struct {
	OrderCompareOp
}

type GTOp

type GTOp struct {
	OrderCompareOp
}

type GlobalScope

type GlobalScope interface {
	Scope
	GetModule(path string) (Module, error)
}

func GetGlobalScope

func GetGlobalScope(s_ Scope) GlobalScope

type GlobalScopeData

type GlobalScopeData struct {
	ScopeData
}

wrapped by BundleScope in order to implement the GlobalScope interface

func NewFilledGlobalScope

func NewFilledGlobalScope() *GlobalScopeData

func (*GlobalScopeData) GetVariable

func (s *GlobalScopeData) GetVariable(name string) (Variable, error)

type If

type If struct {
	Block // dont use the Block.statements
	// contains filtered or unexported fields
}

func NewIf

func NewIf(ctx context.Context) (*If, error)

func (*If) AddCondition

func (t *If) AddCondition(expr Expression) error

func (*If) AddElse

func (t *If) AddElse() error

func (*If) AddStatement

func (t *If) AddStatement(statement Statement)

func (*If) Dump

func (t *If) Dump(indent string) string

func (*If) EvalStatement

func (t *If) EvalStatement() error

func (*If) HoistNames

func (t *If) HoistNames(scope Scope) error

func (*If) ResolveStatementActivity

func (t *If) ResolveStatementActivity(usage Usage) error

func (*If) ResolveStatementNames

func (t *If) ResolveStatementNames(scope Scope) error

func (*If) UniqueStatementNames

func (t *If) UniqueStatementNames(ns Namespace) error

func (*If) UniversalStatementNames

func (t *If) UniversalStatementNames(ns Namespace) error

func (*If) Walk

func (t *If) Walk(fn WalkFunc) error

func (*If) WriteStatement

func (t *If) WriteStatement(usage Usage, indent string, nl string, tab string) string

type IfElseOp

type IfElseOp struct {
	TernaryOp
}

func (*IfElseOp) EvalExpression

func (t *IfElseOp) EvalExpression() (values.Value, error)

func (*IfElseOp) Walk

func (t *IfElseOp) Walk(fn WalkFunc) error

type Import

type Import struct {
	TokenData
	// contains filtered or unexported fields
}

func NewImport

func NewImport(name string, ctx context.Context) *Import

func (*Import) AddStatement

func (t *Import) AddStatement(st Statement)

func (*Import) Dump

func (t *Import) Dump(indent string) string

func (*Import) EvalStatement

func (t *Import) EvalStatement() error

func (*Import) HoistNames

func (t *Import) HoistNames(scope Scope) error

func (*Import) ResolveStatementActivity

func (t *Import) ResolveStatementActivity(usage Usage) error

func (*Import) ResolveStatementNames

func (t *Import) ResolveStatementNames(scope Scope) error

func (*Import) UniqueStatementNames

func (t *Import) UniqueStatementNames(ns Namespace) error

func (*Import) UniversalStatementNames

func (t *Import) UniversalStatementNames(ns Namespace) error

func (*Import) Walk

func (t *Import) Walk(fn WalkFunc) error

func (*Import) WriteStatement

func (t *Import) WriteStatement(usage Usage, indent string, nl string, tab string) string

type ImportedVariable

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

func NewImportedVariable

func NewImportedVariable(oldName, newName string, pathLiteral *LiteralString, lang files.Lang, ctx context.Context) (*ImportedVariable, error)

func (*ImportedVariable) AbsPath

func (iv *ImportedVariable) AbsPath() string

func (*ImportedVariable) Context

func (iv *ImportedVariable) Context() context.Context

func (*ImportedVariable) GetVariable

func (iv *ImportedVariable) GetVariable() Variable

func (*ImportedVariable) PathContext

func (iv *ImportedVariable) PathContext() context.Context

func (*ImportedVariable) PathLiteral

func (iv *ImportedVariable) PathLiteral() *LiteralString

func (*ImportedVariable) Walk

func (iv *ImportedVariable) Walk(fn WalkFunc) error

type InOp

type InOp struct {
	BinaryOp
}

InstanceOf if in InstanceOf.go

func (*InOp) EvalExpression

func (t *InOp) EvalExpression() (values.Value, error)

func (*InOp) Walk

func (t *InOp) Walk(fn WalkFunc) error

type Index

type Index struct {
	TokenData
	// contains filtered or unexported fields
}

func NewIndex

func NewIndex(container Expression, index Expression, ctx context.Context) *Index

func (*Index) Dump

func (t *Index) Dump(indent string) string

func (*Index) EvalExpression

func (t *Index) EvalExpression() (values.Value, error)

func (*Index) EvalSet

func (t *Index) EvalSet(rhsValue values.Value, ctx context.Context) error

func (*Index) ResolveExpressionActivity

func (t *Index) ResolveExpressionActivity(usage Usage) error

func (*Index) ResolveExpressionNames

func (t *Index) ResolveExpressionNames(scope Scope) error

///////////////////////// 1. Name resolution stage /////////////////////////

func (*Index) UniqueExpressionNames

func (t *Index) UniqueExpressionNames(ns Namespace) error

func (*Index) UniversalExpressionNames

func (t *Index) UniversalExpressionNames(ns Namespace) error

func (*Index) Walk

func (t *Index) Walk(fn WalkFunc) error

func (*Index) WriteExpression

func (t *Index) WriteExpression() string

type InstanceOf

type InstanceOf struct {
	BinaryOp
	// contains filtered or unexported fields
}

in a file by itself because it is more complex than the typical operator

func NewInstanceOf

func NewInstanceOf(a Expression, b Expression, ctx context.Context) (*InstanceOf, error)

func (*InstanceOf) CollectTypeGuards

func (t *InstanceOf) CollectTypeGuards(c map[Variable]values.Interface) (bool, error)

func (*InstanceOf) EvalExpression

func (t *InstanceOf) EvalExpression() (values.Value, error)

func (*InstanceOf) ResolveExpressionNames

func (t *InstanceOf) ResolveExpressionNames(scope Scope) error

func (*InstanceOf) Walk

func (t *InstanceOf) Walk(fn WalkFunc) error

func (*InstanceOf) WriteExpression

func (t *InstanceOf) WriteExpression() string

type Interface

type Interface struct {
	TokenData
	// contains filtered or unexported fields
}

func NewInterface

func NewInterface(nameExpr *TypeExpression, parents []*VarExpression, isRPC bool,
	ctx context.Context) (*Interface, error)

func (*Interface) AddMember

func (t *Interface) AddMember(member *FunctionInterface) error

func (*Interface) AddStatement

func (t *Interface) AddStatement(st Statement)

func (*Interface) Check

func (t *Interface) Check(other_ values.Interface, ctx context.Context) error

cached Check

func (*Interface) Dump

func (t *Interface) Dump(indent string) string

func (*Interface) EvalStatement

func (t *Interface) EvalStatement() error

func (*Interface) GetInstanceMember

func (t *Interface) GetInstanceMember(key string, includePrivate bool, ctx context.Context) (values.Value, error)

func (*Interface) GetInterfaces

func (t *Interface) GetInterfaces() ([]values.Interface, error)

func (*Interface) GetPrototypes

func (t *Interface) GetPrototypes() ([]values.Prototype, error)

func (*Interface) GetVariable

func (t *Interface) GetVariable() Variable

func (*Interface) HoistNames

func (t *Interface) HoistNames(scope Scope) error

func (*Interface) IsRPC

func (t *Interface) IsRPC() bool

func (*Interface) IsUniversal

func (t *Interface) IsUniversal() bool

can only be called after eval phase! (because registration is done during eval phase)

func (*Interface) Name

func (t *Interface) Name() string

func (*Interface) ResolveStatementActivity

func (t *Interface) ResolveStatementActivity(usage Usage) error

func (*Interface) ResolveStatementNames

func (t *Interface) ResolveStatementNames(scope Scope) error

func (*Interface) SetInstanceMember

func (t *Interface) SetInstanceMember(key string, includePrivate bool, arg values.Value, ctx context.Context) error

func (*Interface) UniqueStatementNames

func (t *Interface) UniqueStatementNames(ns Namespace) error

func (*Interface) UniversalStatementNames

func (t *Interface) UniversalStatementNames(ns Namespace) error

func (*Interface) Walk

func (t *Interface) Walk(fn WalkFunc) error

func (*Interface) WriteStatement

func (t *Interface) WriteStatement(usage Usage, indent string, nl string, tab string) string

type KeepSignRightShiftOp

type KeepSignRightShiftOp struct {
	ShiftOp
}

type LEOp

type LEOp struct {
	OrderCompareOp
}

type LTOp

type LTOp struct {
	OrderCompareOp
}

type LeftShiftOp

type LeftShiftOp struct {
	ShiftOp
}

type LiteralArray

type LiteralArray struct {
	LiteralData
	// contains filtered or unexported fields
}

func NewLiteralArray

func NewLiteralArray(items []Expression, ctx context.Context) *LiteralArray

func (*LiteralArray) Dump

func (t *LiteralArray) Dump(indent string) string

func (*LiteralArray) EvalExpression

func (t *LiteralArray) EvalExpression() (values.Value, error)

func (*LiteralArray) ResolveExpressionActivity

func (t *LiteralArray) ResolveExpressionActivity(usage Usage) error

func (*LiteralArray) ResolveExpressionNames

func (t *LiteralArray) ResolveExpressionNames(scope Scope) error

func (*LiteralArray) UniqueExpressionNames

func (t *LiteralArray) UniqueExpressionNames(ns Namespace) error

func (*LiteralArray) UniversalExpressionNames

func (t *LiteralArray) UniversalExpressionNames(ns Namespace) error

func (*LiteralArray) Walk

func (t *LiteralArray) Walk(fn WalkFunc) error

func (*LiteralArray) WriteExpression

func (t *LiteralArray) WriteExpression() string

type LiteralBoolean

type LiteralBoolean struct {
	LiteralData
	// contains filtered or unexported fields
}

func NewLiteralBoolean

func NewLiteralBoolean(value bool, ctx context.Context) *LiteralBoolean

func (*LiteralBoolean) Dump

func (t *LiteralBoolean) Dump(indent string) string

func (*LiteralBoolean) EvalExpression

func (t *LiteralBoolean) EvalExpression() (values.Value, error)

func (*LiteralBoolean) Value

func (t *LiteralBoolean) Value() bool

func (*LiteralBoolean) Walk

func (t *LiteralBoolean) Walk(fn WalkFunc) error

func (*LiteralBoolean) WriteExpression

func (t *LiteralBoolean) WriteExpression() string

type LiteralData

type LiteralData struct {
	TokenData
}

intended for LiteralInt, LiteralBool, LiteralFloat, LiteralString and LiteralNull

func (*LiteralData) ResolveExpressionActivity

func (t *LiteralData) ResolveExpressionActivity(usage Usage) error

func (*LiteralData) ResolveExpressionNames

func (t *LiteralData) ResolveExpressionNames(scope Scope) error

func (*LiteralData) UniqueExpressionNames

func (t *LiteralData) UniqueExpressionNames(ns Namespace) error

func (*LiteralData) UniversalExpressionNames

func (t *LiteralData) UniversalExpressionNames(ns Namespace) error

type LiteralFloat

type LiteralFloat struct {
	LiteralData
	// contains filtered or unexported fields
}

func NewLiteralFloat

func NewLiteralFloat(value float64, ctx context.Context) *LiteralFloat

func (*LiteralFloat) Dump

func (t *LiteralFloat) Dump(indent string) string

func (*LiteralFloat) EvalExpression

func (t *LiteralFloat) EvalExpression() (values.Value, error)

func (*LiteralFloat) Value

func (t *LiteralFloat) Value() float64

func (*LiteralFloat) Walk

func (t *LiteralFloat) Walk(fn WalkFunc) error

func (*LiteralFloat) WriteExpression

func (t *LiteralFloat) WriteExpression() string

type LiteralInt

type LiteralInt struct {
	LiteralData
	// contains filtered or unexported fields
}

func NewLiteralInt

func NewLiteralInt(value int, ctx context.Context) *LiteralInt

func (*LiteralInt) Dump

func (t *LiteralInt) Dump(indent string) string

func (*LiteralInt) EvalExpression

func (t *LiteralInt) EvalExpression() (values.Value, error)

func (*LiteralInt) Value

func (t *LiteralInt) Value() int

func (*LiteralInt) Walk

func (t *LiteralInt) Walk(fn WalkFunc) error

func (*LiteralInt) WriteExpression

func (t *LiteralInt) WriteExpression() string

type LiteralNull

type LiteralNull struct {
	LiteralData
}

func NewLiteralNull

func NewLiteralNull(ctx context.Context) *LiteralNull

func (*LiteralNull) Dump

func (t *LiteralNull) Dump(indent string) string

func (*LiteralNull) EvalExpression

func (t *LiteralNull) EvalExpression() (values.Value, error)

func (*LiteralNull) Walk

func (t *LiteralNull) Walk(fn WalkFunc) error

func (*LiteralNull) WriteExpression

func (t *LiteralNull) WriteExpression() string

type LiteralObject

type LiteralObject struct {
	TokenData
	// contains filtered or unexported fields
}

func NewLiteralObject

func NewLiteralObject(keys []*Word, values []Expression, ctx context.Context) (*LiteralObject, error)

func (*LiteralObject) Dump

func (t *LiteralObject) Dump(indent string) string

func (*LiteralObject) EvalExpression

func (t *LiteralObject) EvalExpression() (values.Value, error)

func (*LiteralObject) ResolveExpressionActivity

func (t *LiteralObject) ResolveExpressionActivity(usage Usage) error

func (*LiteralObject) ResolveExpressionNames

func (t *LiteralObject) ResolveExpressionNames(scope Scope) error

func (*LiteralObject) UniqueExpressionNames

func (t *LiteralObject) UniqueExpressionNames(ns Namespace) error

func (*LiteralObject) UniversalExpressionNames

func (t *LiteralObject) UniversalExpressionNames(ns Namespace) error

func (*LiteralObject) Walk

func (t *LiteralObject) Walk(fn WalkFunc) error

func (*LiteralObject) WriteExpression

func (t *LiteralObject) WriteExpression() string

type LiteralObjectMember

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

func (*LiteralObjectMember) Walk

func (m *LiteralObjectMember) Walk(fn WalkFunc) error

type LiteralString

type LiteralString struct {
	LiteralData
	// contains filtered or unexported fields
}

func NewLiteralString

func NewLiteralString(value string, ctx context.Context) *LiteralString

func (*LiteralString) Dump

func (t *LiteralString) Dump(indent string) string

func (*LiteralString) EvalExpression

func (t *LiteralString) EvalExpression() (values.Value, error)

func (*LiteralString) InnerContext

func (t *LiteralString) InnerContext() context.Context

for refactoring

func (*LiteralString) Value

func (t *LiteralString) Value() string

func (*LiteralString) Walk

func (t *LiteralString) Walk(fn WalkFunc) error

func (*LiteralString) WriteExpression

func (t *LiteralString) WriteExpression() string

type LogicalAndOp

type LogicalAndOp struct {
	LogicalBinaryOp
}

func (*LogicalAndOp) CollectTypeGuards

func (t *LogicalAndOp) CollectTypeGuards(c map[Variable]values.Interface) (bool, error)

func (*LogicalAndOp) Walk

func (t *LogicalAndOp) Walk(fn WalkFunc) error

type LogicalBinaryOp

type LogicalBinaryOp struct {
	BinaryOp
}

func (*LogicalBinaryOp) EvalExpression

func (t *LogicalBinaryOp) EvalExpression() (values.Value, error)

type LogicalNotOp

type LogicalNotOp struct {
	PreUnaryOp
}

func (*LogicalNotOp) EvalExpression

func (t *LogicalNotOp) EvalExpression() (values.Value, error)

func (*LogicalNotOp) Walk

func (t *LogicalNotOp) Walk(fn WalkFunc) error

type LogicalOrOp

type LogicalOrOp struct {
	LogicalBinaryOp
}

func (*LogicalOrOp) Walk

func (t *LogicalOrOp) Walk(fn WalkFunc) error

type LoopScope

type LoopScope struct {
	ScopeData
}

func NewLoopScope

func NewLoopScope(parent Scope) *LoopScope

func (*LoopScope) IsAsync

func (scope *LoopScope) IsAsync() bool

func (*LoopScope) IsBreakable

func (scope *LoopScope) IsBreakable() bool

func (*LoopScope) IsContinueable

func (scope *LoopScope) IsContinueable() bool

type Member

type Member struct {
	TokenData
	// contains filtered or unexported fields
}

func NewMember

func NewMember(object Expression, key *Word, ctx context.Context) *Member

func (*Member) Args

func (t *Member) Args() []Token

func (*Member) Dump

func (t *Member) Dump(indent string) string

func (*Member) EvalExpression

func (t *Member) EvalExpression() (values.Value, error)

func (*Member) EvalSet

func (t *Member) EvalSet(rhsValue values.Value, ctx context.Context) error

func (*Member) GetPackageMember

func (t *Member) GetPackageMember() (Variable, error)

return nil if this is not a package member

func (*Member) IsBuiltinPackage

func (t *Member) IsBuiltinPackage() bool

func (*Member) KeyContext

func (t *Member) KeyContext() context.Context

used for refactoring

func (*Member) ObjectContext

func (t *Member) ObjectContext() context.Context

used for refactoring

func (*Member) ObjectNameAndKey

func (t *Member) ObjectNameAndKey() (string, string)

return empty name if object is not VarExpression

func (*Member) PackageName

func (t *Member) PackageName() string

func (*Member) PackagePath

func (t *Member) PackagePath() string

used for refactoring

func (*Member) ResolveExpressionActivity

func (t *Member) ResolveExpressionActivity(usage Usage) error

func (*Member) ResolveExpressionNames

func (t *Member) ResolveExpressionNames(scope Scope) error

func (*Member) ToTypeExpression

func (t *Member) ToTypeExpression() (*TypeExpression, error)

func (*Member) UniqueExpressionNames

func (t *Member) UniqueExpressionNames(ns Namespace) error

func (*Member) UniversalExpressionNames

func (t *Member) UniversalExpressionNames(ns Namespace) error

func (*Member) Walk

func (t *Member) Walk(fn WalkFunc) error

func (*Member) WriteExpression

func (t *Member) WriteExpression() string

type Module

type Module interface {
	GetExportedVariable(gs GlobalScope, name string,
		nameCtx context.Context) (Variable, error)

	SymbolDependencies(allModules map[string]Module, name string) []string // non-unique, not sorted
	MinimalDependencies(allModules map[string]Module) []string             // non-unique, not-sorted

	Context() context.Context
}

type ModuleData

type ModuleData struct {
	Block
	// contains filtered or unexported fields
}

func GetModule

func GetModule(s_ Scope) *ModuleData

func NewModule

func NewModule(ctx context.Context) *ModuleData

func (*ModuleData) AddAggregateExport

func (m *ModuleData) AddAggregateExport(newName, oldName string, pathLiteral *LiteralString, lang files.Lang, ctx context.Context) error

func (*ModuleData) AddExportedName

func (m *ModuleData) AddExportedName(outerName, innerName string, v Variable, ctx context.Context) error

func (*ModuleData) AddImportedName

func (m *ModuleData) AddImportedName(newName, oldName string, pathLiteral *LiteralString, lang files.Lang, ctx context.Context) error

func (*ModuleData) Dependencies

func (m *ModuleData) Dependencies() []files.PathLang

import statements must be toplevel, so we could instead loop the statements

func (*ModuleData) Dump

func (m *ModuleData) Dump() string

func (*ModuleData) EvalTypes

func (m *ModuleData) EvalTypes() error

func (*ModuleData) GetExportedVariable

func (m *ModuleData) GetExportedVariable(gs GlobalScope, name string,
	nameCtx context.Context) (Variable, error)

called from within other module

func (*ModuleData) MinimalDependencies added in v0.4.1

func (m *ModuleData) MinimalDependencies(allModules map[string]Module) []string

func (*ModuleData) Parent

func (m *ModuleData) Parent() Scope

func (*ModuleData) ResolveActivity

func (m *ModuleData) ResolveActivity(usage Usage) error

func (*ModuleData) ResolveNames

func (m *ModuleData) ResolveNames(gs GlobalScope) error

func (*ModuleData) SymbolDependencies added in v0.4.1

func (m *ModuleData) SymbolDependencies(allModules map[string]Module, name string) []string

func (*ModuleData) UniqueEntryPointNames

func (m *ModuleData) UniqueEntryPointNames(ns Namespace) error

func (*ModuleData) UniqueNames

func (m *ModuleData) UniqueNames(ns Namespace) error

func (*ModuleData) UniversalNames

func (m *ModuleData) UniversalNames(ns Namespace) error

func (*ModuleData) Walk

func (m *ModuleData) Walk(fn WalkFunc) error

func (*ModuleData) Write

func (m *ModuleData) Write(usage Usage, nl string, tab string) (string, error)

type ModuleScope

type ModuleScope struct {
	ScopeData
	// contains filtered or unexported fields
}

func (*ModuleScope) GetVariable

func (ms *ModuleScope) GetVariable(name string) (Variable, error)

func (*ModuleScope) HasVariable

func (ms *ModuleScope) HasVariable(name string) bool

type MulOp

type MulOp struct {
	BinaryOp
}

func (*MulOp) EvalExpression

func (t *MulOp) EvalExpression() (values.Value, error)

func (*MulOp) Walk

func (t *MulOp) Walk(fn WalkFunc) error

type NEOp

type NEOp struct {
	EqCompareOp
}

type Namespace

type Namespace interface {
	NewBlockNamespace() Namespace
	NewFunctionNamespace() Namespace

	CurrentFunctionNamespace() Namespace

	UniversalName(v Variable, name string) error
	ClassName(v Variable) error // classnames must be the same project wide!
	FunctionName(v Variable)
	ArgName(v Variable)
	LetName(v Variable)
	VarName(v Variable)

	LibName(v Variable, name string) error

	HasName(new string) bool
	HasVar(v Variable) bool
}

func NewNamespace

func NewNamespace(parent Namespace, isFunction bool) Namespace

type NamespaceData

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

func (*NamespaceData) ArgName

func (ns *NamespaceData) ArgName(v Variable)

func (*NamespaceData) ClassName

func (ns *NamespaceData) ClassName(v Variable) error

func (*NamespaceData) CurrentFunctionNamespace

func (ns *NamespaceData) CurrentFunctionNamespace() Namespace

func (*NamespaceData) FunctionName

func (ns *NamespaceData) FunctionName(v Variable)

func (*NamespaceData) HasName

func (ns *NamespaceData) HasName(new string) bool

func (*NamespaceData) HasVar

func (ns *NamespaceData) HasVar(v Variable) bool

func (*NamespaceData) LetName

func (ns *NamespaceData) LetName(v Variable)

func (*NamespaceData) LibName

func (ns *NamespaceData) LibName(v Variable, name string) error

func (*NamespaceData) NewBlockNamespace

func (ns *NamespaceData) NewBlockNamespace() Namespace

func (*NamespaceData) NewFunctionNamespace

func (ns *NamespaceData) NewFunctionNamespace() Namespace

func (*NamespaceData) OriginalName

func (ns *NamespaceData) OriginalName(v Variable, name string) error

func (*NamespaceData) UniversalName

func (ns *NamespaceData) UniversalName(v Variable, name string) error

func (*NamespaceData) VarName

func (ns *NamespaceData) VarName(v Variable)

type NegOp

type NegOp struct {
	PreUnaryOp
}

func (*NegOp) EvalExpression

func (t *NegOp) EvalExpression() (values.Value, error)

func (*NegOp) Walk

func (t *NegOp) Walk(fn WalkFunc) error

type NewOp

type NewOp struct {
	PreUnaryOp
}

no longer used, but keep the code anyway

func (*NewOp) EvalExpression

func (t *NewOp) EvalExpression() (values.Value, error)

func (*NewOp) Walk

func (t *NewOp) Walk(fn WalkFunc) error

func (*NewOp) WriteExpression

func (t *NewOp) WriteExpression() string

type NodeJSImport

type NodeJSImport struct {
	TokenData
	// contains filtered or unexported fields
}

func NewNodeJSImport

func NewNodeJSImport(name string, expr *VarExpression, ctx context.Context) *NodeJSImport

func (*NodeJSImport) AddStatement

func (m *NodeJSImport) AddStatement(st Statement)

func (*NodeJSImport) Dump

func (m *NodeJSImport) Dump(indent string) string

func (*NodeJSImport) EvalStatement

func (m *NodeJSImport) EvalStatement() error

func (*NodeJSImport) HoistNames

func (m *NodeJSImport) HoistNames(scope Scope) error

func (*NodeJSImport) ResolveStatementActivity

func (m *NodeJSImport) ResolveStatementActivity(usage Usage) error

func (*NodeJSImport) ResolveStatementNames

func (m *NodeJSImport) ResolveStatementNames(scope Scope) error

func (*NodeJSImport) UniqueStatementNames

func (m *NodeJSImport) UniqueStatementNames(ns Namespace) error

func (*NodeJSImport) UniversalStatementNames

func (m *NodeJSImport) UniversalStatementNames(ns Namespace) error

func (*NodeJSImport) Walk

func (m *NodeJSImport) Walk(fn WalkFunc) error

func (*NodeJSImport) WriteStatement

func (m *NodeJSImport) WriteStatement(usage Usage, indent string, nl string, tab string) string

type NotFoundMarker added in v0.4.1

type NotFoundMarker struct {
}

func NewNotFoundMarker added in v0.4.1

func NewNotFoundMarker() *NotFoundMarker

type Op

type Op interface {
	Args() []Token
	Expression
}

func NewBinaryOp

func NewBinaryOp(op string, a Expression, b Expression, ctx context.Context) (Op, error)

func NewPostUnaryOp

func NewPostUnaryOp(op string, a Expression, ctx context.Context) (Op, error)

func NewPreUnaryOp

func NewPreUnaryOp(op string, a Expression, ctx context.Context) (Op, error)

func NewTernaryOp

func NewTernaryOp(op string, a Expression, b Expression, c Expression, ctx context.Context) (Op, error)

type OrderCompareOp

type OrderCompareOp struct {
	BinaryOp
}

func (*OrderCompareOp) EvalExpression

func (t *OrderCompareOp) EvalExpression() (values.Value, error)

>=, <=, >, <

func (*OrderCompareOp) Walk

func (t *OrderCompareOp) Walk(fn WalkFunc) error

TODO: implement for specific types

type Package

type Package struct {
	TokenData
	// contains filtered or unexported fields
}

func NewBuiltinPackage

func NewBuiltinPackage(name string) *Package

for builtin packages

func NewPackage

func NewPackage(path string, ctx context.Context) *Package

user packages start nameless

func (*Package) AddPrototype

func (t *Package) AddPrototype(proto values.Prototype)

func (*Package) AddValue

func (t *Package) AddValue(memberName string, v values.Value)

func (*Package) Constant

func (t *Package) Constant() bool

func (*Package) Dump

func (t *Package) Dump(indent string) string

func (*Package) GetObject

func (t *Package) GetObject() interface{}

func (*Package) GetValue

func (t *Package) GetValue() values.Value

func (*Package) IsBuiltin

func (t *Package) IsBuiltin() bool

func (*Package) Name

func (t *Package) Name() string

func (*Package) Path

func (t *Package) Path() string

func (*Package) Rename

func (t *Package) Rename(newName string)

func (*Package) SetConstant

func (t *Package) SetConstant()

func (*Package) SetObject

func (t *Package) SetObject(ptr interface{})

func (*Package) SetValue

func (t *Package) SetValue(v values.Value)

type Parens

type Parens struct {
	TokenData
	// contains filtered or unexported fields
}

func NewParens

func NewParens(expr Expression, ctx context.Context) *Parens

func (*Parens) CollectTypeGuards

func (t *Parens) CollectTypeGuards(c map[Variable]values.Interface) (bool, error)

func (*Parens) Dump

func (t *Parens) Dump(indent string) string

func (*Parens) EvalExpression

func (t *Parens) EvalExpression() (values.Value, error)

func (*Parens) ResolveExpressionActivity

func (t *Parens) ResolveExpressionActivity(usage Usage) error

func (*Parens) ResolveExpressionNames

func (t *Parens) ResolveExpressionNames(scope Scope) error

func (*Parens) UniqueExpressionNames

func (t *Parens) UniqueExpressionNames(ns Namespace) error

func (*Parens) UniversalExpressionNames

func (t *Parens) UniversalExpressionNames(ns Namespace) error

func (*Parens) Walk

func (t *Parens) Walk(fn WalkFunc) error

func (*Parens) WriteExpression

func (t *Parens) WriteExpression() string

type PosOp

type PosOp struct {
	PreUnaryOp
}

func (*PosOp) EvalExpression

func (t *PosOp) EvalExpression() (values.Value, error)

func (*PosOp) Walk

func (t *PosOp) Walk(fn WalkFunc) error

type PostDecrOp

type PostDecrOp struct {
	PostUnaryOp
}

func NewPostDecrOp

func NewPostDecrOp(a Expression, ctx context.Context) *PostDecrOp

func (*PostDecrOp) EvalExpression

func (t *PostDecrOp) EvalExpression() (values.Value, error)

func (*PostDecrOp) EvalStatement

func (t *PostDecrOp) EvalStatement() error

func (*PostDecrOp) ResolveStatementActivity

func (t *PostDecrOp) ResolveStatementActivity(usage Usage) error

func (*PostDecrOp) ResolveStatementNames

func (t *PostDecrOp) ResolveStatementNames(scope Scope) error

func (*PostDecrOp) UniqueStatementNames

func (t *PostDecrOp) UniqueStatementNames(ns Namespace) error

func (*PostDecrOp) UniversalStatementNames

func (t *PostDecrOp) UniversalStatementNames(ns Namespace) error

func (*PostDecrOp) Walk

func (t *PostDecrOp) Walk(fn WalkFunc) error

func (*PostDecrOp) WriteStatement

func (t *PostDecrOp) WriteStatement(usage Usage, indent string, nl string, tab string) string

type PostIncrOp

type PostIncrOp struct {
	PostUnaryOp
}

func NewPostIncrOp

func NewPostIncrOp(a Expression, ctx context.Context) *PostIncrOp

func (*PostIncrOp) EvalExpression

func (t *PostIncrOp) EvalExpression() (values.Value, error)

func (*PostIncrOp) EvalStatement

func (t *PostIncrOp) EvalStatement() error

func (*PostIncrOp) ResolveStatementActivity

func (t *PostIncrOp) ResolveStatementActivity(usage Usage) error

func (*PostIncrOp) ResolveStatementNames

func (t *PostIncrOp) ResolveStatementNames(scope Scope) error

func (*PostIncrOp) UniqueStatementNames

func (t *PostIncrOp) UniqueStatementNames(ns Namespace) error

func (*PostIncrOp) UniversalStatementNames

func (t *PostIncrOp) UniversalStatementNames(ns Namespace) error

func (*PostIncrOp) Walk

func (t *PostIncrOp) Walk(fn WalkFunc) error

func (*PostIncrOp) WriteStatement

func (t *PostIncrOp) WriteStatement(usage Usage, indent string, nl string, tab string) string

type PostUnaryOp

type PostUnaryOp struct {
	UnaryOp
}

func (*PostUnaryOp) AddStatement

func (t *PostUnaryOp) AddStatement(st Statement)

func (*PostUnaryOp) Dump

func (t *PostUnaryOp) Dump(indent string) string

func (*PostUnaryOp) HoistNames

func (t *PostUnaryOp) HoistNames(scope Scope) error

func (*PostUnaryOp) WriteExpression

func (t *PostUnaryOp) WriteExpression() string

type PowOp

type PowOp struct {
	BinaryOp
}

func (*PowOp) EvalExpression

func (t *PowOp) EvalExpression() (values.Value, error)

func (*PowOp) Walk

func (t *PowOp) Walk(fn WalkFunc) error

type PreDecrOp

type PreDecrOp struct {
	PreUnaryOp
}

cannot be used as statement

func (*PreDecrOp) EvalExpression

func (t *PreDecrOp) EvalExpression() (values.Value, error)

func (*PreDecrOp) Walk

func (t *PreDecrOp) Walk(fn WalkFunc) error

type PreIncrOp

type PreIncrOp struct {
	PreUnaryOp
}

cannot be used as statement

func (*PreIncrOp) EvalExpression

func (t *PreIncrOp) EvalExpression() (values.Value, error)

func (*PreIncrOp) Walk

func (t *PreIncrOp) Walk(fn WalkFunc) error

type PreUnaryOp

type PreUnaryOp struct {
	UnaryOp
}

func (*PreUnaryOp) AddStatement

func (t *PreUnaryOp) AddStatement(st Statement)

func (*PreUnaryOp) Dump

func (t *PreUnaryOp) Dump(indent string) string

func (*PreUnaryOp) HoistNames

func (t *PreUnaryOp) HoistNames(scope Scope) error

func (*PreUnaryOp) WriteExpression

func (t *PreUnaryOp) WriteExpression() string

type RemainderOp

type RemainderOp struct {
	BinaryOp
}

func (*RemainderOp) EvalExpression

func (t *RemainderOp) EvalExpression() (values.Value, error)

func (*RemainderOp) Walk

func (t *RemainderOp) Walk(fn WalkFunc) error

type Return

type Return struct {
	TokenData
	// contains filtered or unexported fields
}

func NewReturn

func NewReturn(expr Expression, ctx context.Context) (*Return, error)

func (*Return) AddStatement

func (t *Return) AddStatement(st Statement)

func (*Return) Dump

func (t *Return) Dump(indent string) string

func (*Return) EvalStatement

func (t *Return) EvalStatement() error

func (*Return) HoistNames

func (t *Return) HoistNames(scope Scope) error

func (*Return) ResolveStatementActivity

func (t *Return) ResolveStatementActivity(usage Usage) error

func (*Return) ResolveStatementNames

func (t *Return) ResolveStatementNames(scope Scope) error

func (*Return) UniqueStatementNames

func (t *Return) UniqueStatementNames(ns Namespace) error

func (*Return) UniversalStatementNames

func (t *Return) UniversalStatementNames(ns Namespace) error

func (*Return) Walk

func (t *Return) Walk(fn WalkFunc) error

func (*Return) WriteStatement

func (t *Return) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Scope

type Scope interface {
	Parent() Scope

	HasVariable(name string) bool
	GetVariable(name string) (Variable, error)
	SetVariable(name string, v Variable) error

	FriendlyPrototypes() []values.Prototype
	IsBreakable() bool
	IsContinueable() bool
	IsAsync() bool
	GetFunction() *Function
}

type ScopeData

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

eg. used by GlobalScope

func NewScope

func NewScope(parent Scope) *ScopeData

func (*ScopeData) FriendlyPrototypes

func (s *ScopeData) FriendlyPrototypes() []values.Prototype

func (*ScopeData) GetFunction

func (s *ScopeData) GetFunction() *Function

func (*ScopeData) GetVariable

func (s *ScopeData) GetVariable(name string) (Variable, error)

func (*ScopeData) HasVariable

func (s *ScopeData) HasVariable(name string) bool

func (*ScopeData) IsAsync

func (s *ScopeData) IsAsync() bool

func (*ScopeData) IsBreakable

func (s *ScopeData) IsBreakable() bool

func (*ScopeData) IsContinueable

func (s *ScopeData) IsContinueable() bool

func (*ScopeData) Parent

func (s *ScopeData) Parent() Scope

func (*ScopeData) SetVariable

func (s *ScopeData) SetVariable(name string, v Variable) error

type ShiftOp

type ShiftOp struct {
	BinaryBitOp
}

type SpecialNumber

type SpecialNumber struct {
	TokenData
	// contains filtered or unexported fields
}

func NewSpecialNumber

func NewSpecialNumber(value string, ctx context.Context) *SpecialNumber

func (*SpecialNumber) Dump

func (t *SpecialNumber) Dump(indent string) string

func (*SpecialNumber) EvalExpression

func (t *SpecialNumber) EvalExpression() (values.Value, error)

func (*SpecialNumber) ResolveExpressionActivity

func (t *SpecialNumber) ResolveExpressionActivity(usage Usage) error

func (*SpecialNumber) ResolveExpressionNames

func (t *SpecialNumber) ResolveExpressionNames(scope Scope) error

func (*SpecialNumber) UniqueExpressionNames

func (t *SpecialNumber) UniqueExpressionNames(ns Namespace) error

func (*SpecialNumber) UniversalExpressionNames

func (t *SpecialNumber) UniversalExpressionNames(ns Namespace) error

func (*SpecialNumber) Value

func (t *SpecialNumber) Value() string

func (*SpecialNumber) Walk

func (t *SpecialNumber) Walk(fn WalkFunc) error

func (*SpecialNumber) WriteExpression

func (t *SpecialNumber) WriteExpression() string

type Statement

type Statement interface {
	Token

	AddStatement(st Statement) // panics if Statement is not Block-like

	WriteStatement(usage Usage, indent string, nl string, tab string) string

	HoistNames(scope Scope) error

	ResolveStatementNames(scope Scope) error

	EvalStatement() error

	// usage is resolved in reverse order, so that unused 'mutations' (i.e. variable assignments) can be detected
	ResolveStatementActivity(usage Usage) error

	// universal names need to be registered before other unique names are generated
	UniversalStatementNames(ns Namespace) error

	UniqueStatementNames(ns Namespace) error

	// used be refactoring tools
	Walk(fn WalkFunc) error
}

type StrictEqOp

type StrictEqOp struct {
	EqCompareOp
}

func (*StrictEqOp) EvalExpression

func (t *StrictEqOp) EvalExpression() (values.Value, error)

func (*StrictEqOp) Walk

func (t *StrictEqOp) Walk(fn WalkFunc) error

type StrictNEOp

type StrictNEOp struct {
	EqCompareOp
}

func (*StrictNEOp) EvalExpression

func (t *StrictNEOp) EvalExpression() (values.Value, error)

func (*StrictNEOp) Walk

func (t *StrictNEOp) Walk(fn WalkFunc) error

type SubOp

type SubOp struct {
	BinaryOp
}

func (*SubOp) EvalExpression

func (t *SubOp) EvalExpression() (values.Value, error)

func (*SubOp) Walk

func (t *SubOp) Walk(fn WalkFunc) error

type SubScope

type SubScope struct {
	ScopeData
}

func NewSubScope

func NewSubScope(parent Scope) *SubScope

simply passes everyting to parent

type Switch

type Switch struct {
	Block // dont use the Block.statements
	// contains filtered or unexported fields
}

func NewSwitch

func NewSwitch(expr Expression, ctx context.Context) (*Switch, error)

func (*Switch) AddCase

func (t *Switch) AddCase(clause Expression) error

func (*Switch) AddDefault

func (t *Switch) AddDefault(ctx context.Context) error

func (*Switch) AddStatement

func (t *Switch) AddStatement(statement Statement)

func (*Switch) ConvertToIf

func (t *Switch) ConvertToIf() *If

func (*Switch) Dump

func (t *Switch) Dump(indent string) string

func (*Switch) EvalStatement

func (t *Switch) EvalStatement() error

func (*Switch) HoistNames

func (t *Switch) HoistNames(scope Scope) error

func (*Switch) ResolveStatementActivity

func (t *Switch) ResolveStatementActivity(usage Usage) error

func (*Switch) ResolveStatementNames

func (t *Switch) ResolveStatementNames(scope Scope) error

func (*Switch) UniqueStatementNames

func (t *Switch) UniqueStatementNames(ns Namespace) error

func (*Switch) UniversalStatementNames

func (t *Switch) UniversalStatementNames(ns Namespace) error

func (*Switch) Walk

func (t *Switch) Walk(fn WalkFunc) error

func (*Switch) WriteStatement

func (t *Switch) WriteStatement(usage Usage, indent string, nl string, tab string) string

type TemplateString

type TemplateString struct {
	LiteralData
	// contains filtered or unexported fields
}

func NewTemplateString

func NewTemplateString(exprs []Expression, ctx context.Context) (*TemplateString, error)

func (*TemplateString) Dump

func (t *TemplateString) Dump(indent string) string

func (*TemplateString) EvalExpression

func (t *TemplateString) EvalExpression() (values.Value, error)

func (*TemplateString) ResolveExpressionActivity

func (t *TemplateString) ResolveExpressionActivity(usage Usage) error

func (*TemplateString) ResolveExpressionNames

func (t *TemplateString) ResolveExpressionNames(scope Scope) error

func (*TemplateString) UniqueExpressionNames

func (t *TemplateString) UniqueExpressionNames(ns Namespace) error

func (*TemplateString) UniversalExpressionNames

func (t *TemplateString) UniversalExpressionNames(ns Namespace) error

func (*TemplateString) Walk

func (t *TemplateString) Walk(fn WalkFunc) error

func (*TemplateString) WriteExpression

func (t *TemplateString) WriteExpression() string

type TernaryOp

type TernaryOp struct {
	TokenData
	// contains filtered or unexported fields
}

func (*TernaryOp) Args

func (t *TernaryOp) Args() []Token

func (*TernaryOp) Dump

func (t *TernaryOp) Dump(indent string) string

func (*TernaryOp) ResolveExpressionActivity

func (t *TernaryOp) ResolveExpressionActivity(usage Usage) error

func (*TernaryOp) ResolveExpressionNames

func (t *TernaryOp) ResolveExpressionNames(scope Scope) error

func (*TernaryOp) UniqueExpressionNames

func (t *TernaryOp) UniqueExpressionNames(ns Namespace) error

func (*TernaryOp) UniversalExpressionNames

func (t *TernaryOp) UniversalExpressionNames(ns Namespace) error

func (*TernaryOp) Walk

func (t *TernaryOp) Walk(fn WalkFunc) error

func (*TernaryOp) WriteExpression

func (t *TernaryOp) WriteExpression() string

type Throw

type Throw struct {
	TokenData
	// contains filtered or unexported fields
}

func NewThrow

func NewThrow(expr Expression, ctx context.Context) (*Throw, error)

func (*Throw) AddStatement

func (t *Throw) AddStatement(st Statement)

func (*Throw) Dump

func (t *Throw) Dump(indent string) string

func (*Throw) EvalStatement

func (t *Throw) EvalStatement() error

func (*Throw) HoistNames

func (t *Throw) HoistNames(scope Scope) error

func (*Throw) ResolveStatementActivity

func (t *Throw) ResolveStatementActivity(usage Usage) error

func (*Throw) ResolveStatementNames

func (t *Throw) ResolveStatementNames(scope Scope) error

func (*Throw) UniqueStatementNames

func (t *Throw) UniqueStatementNames(ns Namespace) error

func (*Throw) UniversalStatementNames

func (t *Throw) UniversalStatementNames(ns Namespace) error

func (*Throw) Walk

func (t *Throw) Walk(fn WalkFunc) error

func (*Throw) WriteStatement

func (t *Throw) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Token

type Token interface {
	Dump(indent string) string
	Context() context.Context
}

type TokenData

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

func (*TokenData) Context

func (t *TokenData) Context() context.Context

type TryCatch

type TryCatch struct {
	Block
	// contains filtered or unexported fields
}

func NewTryCatch

func NewTryCatch(ctx context.Context) (*TryCatch, error)

func (*TryCatch) AddCatch

func (t *TryCatch) AddCatch(arg *FunctionArgument) error

arg can be nil

func (*TryCatch) AddFinally

func (t *TryCatch) AddFinally() error

func (*TryCatch) AddStatement

func (t *TryCatch) AddStatement(statement Statement)

func (*TryCatch) Dump

func (t *TryCatch) Dump(indent string) string

func (*TryCatch) EvalStatement

func (t *TryCatch) EvalStatement() error

func (*TryCatch) HoistNames

func (t *TryCatch) HoistNames(scope Scope) error

func (*TryCatch) ResolveStatementActivity

func (t *TryCatch) ResolveStatementActivity(usage Usage) error

func (*TryCatch) ResolveStatementNames

func (t *TryCatch) ResolveStatementNames(scope Scope) error

func (*TryCatch) UniqueStatementNames

func (t *TryCatch) UniqueStatementNames(ns Namespace) error

func (*TryCatch) UniversalStatementNames

func (t *TryCatch) UniversalStatementNames(ns Namespace) error

func (*TryCatch) Walk

func (t *TryCatch) Walk(fn WalkFunc) error

func (*TryCatch) WriteStatement

func (t *TryCatch) WriteStatement(usage Usage, indent string, nl string, tab string) string

type TypeExpression

type TypeExpression struct {
	VarExpression // the base type will be a class variable
	// contains filtered or unexported fields
}

very similar to VarExpression, but with extra

func GetTypeExpression

func GetTypeExpression(expr_ Expression) (*TypeExpression, error)

func NewTypeExpression

func NewTypeExpression(name string, parameterKeys []*Word,
	parameterTypes []*TypeExpression, ctx context.Context) (*TypeExpression, error)

func (*TypeExpression) Dump

func (t *TypeExpression) Dump(indent string) string

func (*TypeExpression) EvalExpression

func (t *TypeExpression) EvalExpression() (values.Value, error)

Acts as the new generate instance

func (*TypeExpression) ResolveExpressionNames

func (t *TypeExpression) ResolveExpressionNames(scope Scope) error

func (*TypeExpression) Walk

func (t *TypeExpression) Walk(fn WalkFunc) error

func (*TypeExpression) WriteUniversalRuntimeType

func (t *TypeExpression) WriteUniversalRuntimeType() string

type TypeExpressionMember

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

func (*TypeExpressionMember) Walk

func (t *TypeExpressionMember) Walk(fn WalkFunc) error

type TypeGuard

type TypeGuard interface {
	// collect all variables/interfaces
	// return false if all typeguards should be voided
	// (should also do everything EvalExpression does)
	CollectTypeGuards(c map[Variable]values.Interface) (bool, error)
}

type TypeOfOp

type TypeOfOp struct {
	PreUnaryOp
}

func (*TypeOfOp) EvalExpression

func (t *TypeOfOp) EvalExpression() (values.Value, error)

func (*TypeOfOp) Walk

func (t *TypeOfOp) Walk(fn WalkFunc) error

type UnaryOp

type UnaryOp struct {
	TokenData
	// contains filtered or unexported fields
}

func (*UnaryOp) Args

func (t *UnaryOp) Args() []Token

func (*UnaryOp) ResolveExpressionActivity

func (t *UnaryOp) ResolveExpressionActivity(usage Usage) error

func (*UnaryOp) ResolveExpressionNames

func (t *UnaryOp) ResolveExpressionNames(scope Scope) error

func (*UnaryOp) UniqueExpressionNames

func (t *UnaryOp) UniqueExpressionNames(ns Namespace) error

func (*UnaryOp) UniversalExpressionNames

func (t *UnaryOp) UniversalExpressionNames(ns Namespace) error

func (*UnaryOp) Walk

func (t *UnaryOp) Walk(fn WalkFunc) error

type Usage

type Usage interface {
	SetInFunction(bool)
	InFunction() bool
	Rereference(v Variable, ctx context.Context) error
	Use(v Variable, ctx context.Context) error
	DetectUnused() error
}

func NewUsage

func NewUsage() Usage

type UsageData

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

func (*UsageData) DetectUnused

func (u *UsageData) DetectUnused() error

func (*UsageData) InFunction

func (u *UsageData) InFunction() bool

func (*UsageData) Rereference

func (u *UsageData) Rereference(v Variable, ctx context.Context) error

func (*UsageData) SetInFunction

func (u *UsageData) SetInFunction(inFunction bool)

func (*UsageData) Use

func (u *UsageData) Use(v Variable, ctx context.Context) error

type UsageState

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

type VarExpression

type VarExpression struct {
	TokenData
	// contains filtered or unexported fields
}

simply prints the variable name

func AssertVarExpression

func AssertVarExpression(t Token) (*VarExpression, error)

func NewConstantVarExpression

func NewConstantVarExpression(name string, ctx context.Context) *VarExpression

for Function and Class statements

func NewVarExpression

func NewVarExpression(name string, ctx context.Context) *VarExpression

func (*VarExpression) Dump

func (t *VarExpression) Dump(indent string) string

func (*VarExpression) EvalExpression

func (t *VarExpression) EvalExpression() (values.Value, error)

as rhs

func (*VarExpression) EvalSet

func (t *VarExpression) EvalSet(v values.Value, ctx context.Context) error

as lhs

func (*VarExpression) GetInterface

func (t *VarExpression) GetInterface() values.Interface

func (*VarExpression) GetPrototype

func (t *VarExpression) GetPrototype() values.Prototype

func (*VarExpression) GetVariable

func (t *VarExpression) GetVariable() Variable

func (*VarExpression) Name

func (t *VarExpression) Name() string

func (*VarExpression) NonPackageContext

func (t *VarExpression) NonPackageContext() context.Context

use by refactoring tools

func (*VarExpression) PackageContext

func (t *VarExpression) PackageContext() context.Context

use by refactoring tools

func (*VarExpression) PackagePath

func (t *VarExpression) PackagePath() string

func (*VarExpression) RefersToPackage

func (t *VarExpression) RefersToPackage(absPath string) bool

func (*VarExpression) ResolveExpressionActivity

func (t *VarExpression) ResolveExpressionActivity(usage Usage) error

func (*VarExpression) ResolveExpressionNames

func (t *VarExpression) ResolveExpressionNames(scope Scope) error

func (*VarExpression) ToTypeExpression

func (t *VarExpression) ToTypeExpression() (*TypeExpression, error)

func (*VarExpression) UniqueExpressionNames

func (t *VarExpression) UniqueExpressionNames(ns Namespace) error

func (*VarExpression) UniversalExpressionNames

func (t *VarExpression) UniversalExpressionNames(ns Namespace) error

func (*VarExpression) Walk

func (t *VarExpression) Walk(fn WalkFunc) error

func (*VarExpression) WriteExpression

func (t *VarExpression) WriteExpression() string

type VarStatement

type VarStatement struct {
	TokenData
	// contains filtered or unexported fields
}

func NewVarStatement

func NewVarStatement(varType VarType, exprs []Expression, typeExprs []*TypeExpression,
	ctx context.Context) (*VarStatement, error)

func (*VarStatement) AddStatement

func (t *VarStatement) AddStatement(st Statement)

func (*VarStatement) Dump

func (t *VarStatement) Dump(indent string) string

func (*VarStatement) EvalStatement

func (t *VarStatement) EvalStatement() error

func (*VarStatement) GetVariables

func (t *VarStatement) GetVariables() map[string]Variable

func (*VarStatement) HoistNames

func (t *VarStatement) HoistNames(scope Scope) error

func (*VarStatement) ResolveStatementActivity

func (t *VarStatement) ResolveStatementActivity(usage Usage) error

func (*VarStatement) ResolveStatementNames

func (t *VarStatement) ResolveStatementNames(scope Scope) error

func (*VarStatement) UniqueStatementNames

func (t *VarStatement) UniqueStatementNames(ns Namespace) error

func (*VarStatement) UniversalStatementNames

func (t *VarStatement) UniversalStatementNames(ns Namespace) error

func (*VarStatement) Walk

func (t *VarStatement) Walk(fn WalkFunc) error

func (*VarStatement) WriteStatement

func (t *VarStatement) WriteStatement(usage Usage, indent string, nl string, tab string) string

type VarType

type VarType int
const (
	CONST VarType = iota
	LET
	VAR
	AUTOLET
)

func StringToVarType

func StringToVarType(s string, ctx context.Context) (VarType, error)

type Variable

type Variable interface {
	Context() context.Context
	Dump(indent string) string

	Name() string
	Rename(newName string)

	Constant() bool
	SetConstant()

	GetValue() values.Value
	SetValue(values.Value)

	// anything that can be evaluated during the resolve names stage (eg. class statement)
	GetObject() interface{}
	SetObject(interface{})
}

a Package also implements the Variable interface

type VariableData

type VariableData struct {
	TokenData
	// contains filtered or unexported fields
}

func NewVariable

func NewVariable(name string, constant bool, ctx context.Context) *VariableData

func (*VariableData) Constant

func (t *VariableData) Constant() bool

func (*VariableData) Dump

func (t *VariableData) Dump(indent string) string

func (*VariableData) GetObject

func (t *VariableData) GetObject() interface{}

func (*VariableData) GetValue

func (t *VariableData) GetValue() values.Value

func (*VariableData) Name

func (t *VariableData) Name() string

func (*VariableData) Rename

func (t *VariableData) Rename(newName string)

TODO: do this directly in the Namespace

func (*VariableData) SetConstant

func (t *VariableData) SetConstant()

func (*VariableData) SetObject

func (t *VariableData) SetObject(ptr interface{})

func (*VariableData) SetValue

func (t *VariableData) SetValue(v values.Value)

type Void

type Void struct {
	TokenData
	// contains filtered or unexported fields
}

func NewVoidStatement

func NewVoidStatement(expr Expression, ctx context.Context) *Void

func (*Void) AddStatement

func (t *Void) AddStatement(st Statement)

func (*Void) Dump

func (t *Void) Dump(indent string) string

func (*Void) EvalStatement

func (t *Void) EvalStatement() error

func (*Void) HoistNames

func (t *Void) HoistNames(scope Scope) error

func (*Void) ResolveStatementActivity

func (t *Void) ResolveStatementActivity(usage Usage) error

func (*Void) ResolveStatementNames

func (t *Void) ResolveStatementNames(scope Scope) error

func (*Void) UniqueStatementNames

func (t *Void) UniqueStatementNames(ns Namespace) error

func (*Void) UniversalStatementNames

func (t *Void) UniversalStatementNames(ns Namespace) error

func (*Void) Walk

func (t *Void) Walk(fn WalkFunc) error

func (*Void) WriteStatement

func (t *Void) WriteStatement(usage Usage, indent string, nl string, tab string) string

type WalkFunc

type WalkFunc func(interface{}) error

type While

type While struct {
	Block
	// contains filtered or unexported fields
}

func NewWhile

func NewWhile(cond Expression, ctx context.Context) (*While, error)

func (*While) Dump

func (t *While) Dump(indent string) string

func (*While) EvalStatement

func (t *While) EvalStatement() error

func (*While) HoistNames

func (t *While) HoistNames(scope Scope) error

func (*While) ResolveStatementActivity

func (t *While) ResolveStatementActivity(usage Usage) error

func (*While) ResolveStatementNames

func (t *While) ResolveStatementNames(scope Scope) error

func (*While) UniqueStatementNames

func (t *While) UniqueStatementNames(ns Namespace) error

func (*While) UniversalStatementNames

func (t *While) UniversalStatementNames(ns Namespace) error

func (*While) Walk

func (t *While) Walk(fn WalkFunc) error

func (*While) WriteStatement

func (t *While) WriteStatement(usage Usage, indent string, nl string, tab string) string

type Word

type Word struct {
	TokenData
	// contains filtered or unexported fields
}

eg. for key of dict essentially a string-context pair

func AssertWord

func AssertWord(t Token) (*Word, error)

func NewWord

func NewWord(value string, ctx context.Context) *Word

func (*Word) Dump

func (t *Word) Dump(indent string) string

func (*Word) Value

func (t *Word) Value() string

func (*Word) Walk

func (t *Word) Walk(fn WalkFunc) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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