scope

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCurrentScope added in v1.0.1

func NewCurrentScope(isFunc bool, isLoop bool)

NewBaseScope create current scope on top of another

func NewGlobalScope added in v1.0.1

func NewGlobalScope()

NewGlobalScope initializes global scope

Types

type Scope

type Scope struct {
	// contains filtered or unexported fields
}
var CurrentScope *Scope

current scope

var GlobalScope *Scope

global scope

func NewScope

func NewScope(
	parent *Scope,
	depth int,
	isFunc bool,
	isLoop bool,
	objects map[string]object.Object,
	functions map[string]*object.RuntimeFunc,
) *Scope

NewScope creates new scope

func (*Scope) Depth

func (s *Scope) Depth() int

Depth returns current depth of scopes

func (*Scope) Functions added in v1.0.1

func (s *Scope) Functions() map[string]*object.RuntimeFunc

Functions returns map with functions registered in current scope

func (*Scope) Get

func (s *Scope) Get(n string, stopOnFunc bool) object.Object

Get returns value of variable from storage (with search inside of parent scope and checking is scope function)

func (*Scope) GetFunction added in v1.0.1

func (s *Scope) GetFunction(name string) object.Object

GetFunction returns runtime function by name (search in parent scopes)

func (*Scope) IsBreak

func (s *Scope) IsBreak() bool

IsBreak returns true if break necessary

func (*Scope) IsContinue

func (s *Scope) IsContinue() bool

IsContinue returns true if continue necessary

func (*Scope) IsFunc

func (s *Scope) IsFunc() bool

IsFunc returns true if scope is function

func (*Scope) IsGlobal

func (s *Scope) IsGlobal() bool

IsGLobal returns true if scope is global

func (*Scope) IsInFunc

func (s *Scope) IsInFunc() bool

IsInFunc returns true if scope inside of function

func (*Scope) IsInLoop

func (s *Scope) IsInLoop() bool

IsInLoop returns true if scope inside of loop

func (*Scope) Parent

func (s *Scope) Parent() *Scope

Parent returns parent scope

func (*Scope) Put

func (s *Scope) Put(n string, o object.Object)

Put saves variable in scope

func (*Scope) SetLoopBreak

func (s *Scope) SetLoopBreak()

SetLoopBreak sets flag for break necessity

func (*Scope) SetLoopContinue

func (s *Scope) SetLoopContinue()

SetLoopContinue sets flag for continue necessity

func (*Scope) UnsetLoopBreak

func (s *Scope) UnsetLoopBreak()

UnsetLoopBreak unsets flag for break necessity

func (*Scope) UnsetLoopContinue

func (s *Scope) UnsetLoopContinue()

UnsetLoopContinue unsets flag for continue necessity

Jump to

Keyboard shortcuts

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