class

Mint::Scope

Inherits Reference < Object

The class is responsible for keeping track of which variable is pointing to which node.

The data structure is a tree where leaves are the levels of the child nodes of an AST node and a level is a container for the possible targets.

When resolving a variable we traverse it's tree upwards to find the target which matches the value of the variable.

Constructors

new(ast : Ast)
Source

Instance methods

add(node : Ast::Node, key : String, value : Ast::Node)

Adds a target to the level of the given node.

Source
build(node : Ast::Node | Nil, parent : Ast::Node)
Source
build(nodes : Array(Ast::Node), parent : Ast::Node, *, stack : Bool = false)

Builds an array of nodes. If stack is true then each node will be the child of the previous nodes.

Source
build(node : Ast::Node)

Builds the scope for the given node and it's child nodes.

Source
create(node : Ast::Node, parent : Ast::Node | Nil = nil)

Builds a level for the node and yields the parents scope.

Source
find_parent_by_class(node, classes)
Source
nodes

We track the level of a node in here.

Source
resolve(target : String, base : Ast::Node)
Source
resolve(node : Ast::Variable)

Tries to find the target of the given variable.

Source
resolve

Resolves the targets which can be statically resolved, currently only the exposed variables of a connected entity in a component.

Source
resolve_qualified(qualified : String)
Source
root
Source
scopes

We track the level stack of a node in here.

Source
top_level

We track top level nodes.

Source

Nested types