resolver

package
v0.0.0-...-e98e1b7 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Resolver

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

static analysis. resolve variables to solve the problem of dynamic changing environments that apperas with closures. after the parser produces the syntax tree, but before the interpreter starts executing, it’ll do a single walk over the tree to resolve all of the variables it contains aka persisting static scope. implements statements and expressions visitor interface.

func New

func New(inter *interpreter.Interpreter) *Resolver

func (*Resolver) Resolve

func (resolver *Resolver) Resolve(stmts []statements.Statement)

walks the statements and resolves each one.

func (*Resolver) VisitAssgin

func (resolver *Resolver) VisitAssgin(expr expressions.Assgin) (interface{}, error)

First, it resolve the expression for the assigned value in case it also contains references to other variables. Then it resolve the variable that’s being assigned to.

func (*Resolver) VisitBinary

func (resolver *Resolver) VisitBinary(expr expressions.Binary) (interface{}, error)

func (*Resolver) VisitBlockStmt

func (resolver *Resolver) VisitBlockStmt(stmt statements.BlockStatement) error

resolving blocks

func (*Resolver) VisitCall

func (resolver *Resolver) VisitCall(expr expressions.Call) (interface{}, error)

func (*Resolver) VisitClassStmt

func (resolver *Resolver) VisitClassStmt(stmt statements.ClassStatement) error

func (*Resolver) VisitExprStmt

func (resolver *Resolver) VisitExprStmt(stmt statements.ExperssionStatement) error

func (*Resolver) VisitFunctionStmt

func (resolver *Resolver) VisitFunctionStmt(stmt statements.FunctionStatement) error

func (*Resolver) VisitGrouping

func (resolver *Resolver) VisitGrouping(expr expressions.Grouping) (interface{}, error)

func (*Resolver) VisitIfStmt

func (resolver *Resolver) VisitIfStmt(stmt statements.IfStatement) error

func (*Resolver) VisitLiteral

func (resolver *Resolver) VisitLiteral(expr expressions.Literal) (interface{}, error)

func (*Resolver) VisitLogical

func (resolver *Resolver) VisitLogical(expr expressions.Logical) (interface{}, error)

func (*Resolver) VisitPrintStmt

func (resolver *Resolver) VisitPrintStmt(stmt statements.PrintStatement) error

func (*Resolver) VisitPropertyAccess

func (resolver *Resolver) VisitPropertyAccess(expr expressions.PropertyAccess) (interface{}, error)

Since properties are looked up dynamically, they don’t get resolved. During resolution, it recurse only into the expression to the left of the dot. The actual property access happens in the interpreter.

func (*Resolver) VisitPropertyAssignment

func (resolver *Resolver) VisitPropertyAssignment(expr expressions.PropertyAssignment) (interface{}, error)

func (*Resolver) VisitReturnStmt

func (resolver *Resolver) VisitReturnStmt(stmt statements.ReturnStatement) error

func (*Resolver) VisitSuper

func (resolver *Resolver) VisitSuper(expr expressions.Super) (interface{}, error)

func (*Resolver) VisitThis

func (resolver *Resolver) VisitThis(expr expressions.This) (interface{}, error)

func (*Resolver) VisitUnary

func (resolver *Resolver) VisitUnary(expr expressions.Unary) (interface{}, error)

func (*Resolver) VisitVairable

func (resolver *Resolver) VisitVairable(expr expressions.Variable) (interface{}, error)

func (*Resolver) VisitVarDecStmt

func (resolver *Resolver) VisitVarDecStmt(stmt statements.VarDecStatement) error

func (*Resolver) VisitWhileStmt

func (resolver *Resolver) VisitWhileStmt(stmt statements.WhileStatement) error

Jump to

Keyboard shortcuts

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