Context class
TAC.Context keeps track of the runtime environment, including local variables. Context objects form a linked list via a "parent" reference, with a new context formed on each function call (this is known as the call stack).
Properties
-
args
↔ List<
Value?> ? -
pushed arguments for upcoming calls
getter/setter pair
-
code
↔ List<
Line> -
TAC lines we're executing
getter/setter pair
- done → bool
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- implicitResultCounter ↔ int
-
how many times we have stored an implicit result
getter/setter pair
- interpreter → Interpreter?
-
no setter
- lineNum ↔ int
-
next line to be executed
getter/setter pair
- outerVars ↔ ValMap?
-
variables of the context where this function was defined
getter/setter pair
- parent ↔ Context?
-
parent (calling) context
getter/setter pair
- partialResult ↔ IntrinsicResult?
-
work-in-progress of our current intrinsic
getter/setter pair
- resultStorage ↔ Value?
-
where to store the return value (in the calling context)
getter/setter pair
- root → Context
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- self ↔ Value?
-
value of self in this context
getter/setter pair
-
temps
↔ List<
Value?> ? -
values of temporaries; temps
0is always return valuegetter/setter pair - variables ↔ ValMap?
-
local variables for this call frame
getter/setter pair
- vm ↔ Machine?
-
virtual machine
getter/setter pair
Methods
-
clearCodeAndTemps(
) → void -
dump(
) → void - This function prints the three-address code to the console, for debugging purposes.
-
getLocal(
String identifier, [Value? defaultValue]) → Value? - Get the value of a local variable ONLY -- does not check any other scopes, nor check for special built-in identifiers like "globals". Used mainly by host apps to easily look up an argument to an intrinsic function call by the parameter name.
-
getLocalBool(
String identifier, [bool defaultValue = false]) → bool? -
getLocalDouble(
String identifier, [double defaultValue = 0]) → double? -
getLocalInt(
String identifier, [int defaultValue = 0]) → int? -
getLocalString(
String identifier, [String? defaultValue]) → String? -
getSourceLoc(
) → SourceLoc? -
getTemp(
int tempNum, [Value? defaultValue]) → Value? -
getVar(
String identifier, {LocalOnlyMode localOnly = LocalOnlyMode.off}) → Value? - Get the value of a variable available in this context (including locals, globals, and intrinsics). Raise an exception if no such identifier can be found.
-
jumpToEnd(
) → void -
nextCallContext(
VFunction func, int argCount, bool gotSelf, Value? resultStorage) → Context - Get a context for the next call, which includes any parameter arguments that have been set.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pushParamArgument(
Value? arg) → void - Store a parameter argument in preparation for an upcoming call (which should be executed in the context returned by NextCallContext).
-
reset(
[bool clearVariables = true]) → void - Reset this context to the first line of code, clearing out any temporary variables, and optionally clearing out all variables.
-
setTemp(
int tempNum, Value? value) → void -
setVar(
String identifier, Value? value) → void -
storeValue(
Value? lhs, Value? value) → void -
toString(
) → String -
A string representation of this object.
override
-
valueInContext(
Value? value) → Value?
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited