Class ScopeStack<T>
Simple implementation of common Variable scoping
Inheritance
Inherited Members
Namespace: Ubiquity.NET.Llvm
Assembly: Ubiquity.NET.Llvm.dll
Syntax
public class ScopeStack<T>
Type Parameters
T
Type of the values to associate with the symbol name |
Remarks
In essence, this is a stack of Dictionaries that is intended for use in code generation. Most languages have some sort of notion of symbol scopes and name lookups. This implements the common case of nested scopes where a new 'local scope' may override some of the symbols in a parent scope. Any values in any parent not overridden by the child are visible to the child scope.
Usually, though not required, the type T
is Value
or Alloca to allow a code generator to track a value or mutable variable
with the source name in multiple scope layers.
Constructors
ScopeStack() | Initializes a new instance of the ScopeStack<T> class. |
Properties
Depth | Gets the depth of the stack |
Item[String] | Gets or sets the value of a symbol in scope |
Methods
EnterScope() | Starts a new scope |
TryGetValue(String, out T) | Attempts to retrieve a value from the stack |