BaseRuntime class abstract
Implements common Lua runtime logic. Extend with mixin ReturnStmtCallStackUnwind or ReturnStmtDoNotUnwind.
The reason the return statement behavior is omitted is
b/c this library can be used to perform static analysis
as well. In such cases it's desirable to anaylze all
control flows instead of aborting early on return.
This decision allows the users of this library to choose
how to configure their desired runtime.
- Inheritance
- Implementers
Constructors
- BaseRuntime(BaseResults results)
- Only constructor.
Properties
- context → LuaObject?
-
Shorthand for
scope.context.no setter - debugPath ↔ String?
-
For diagnostics or debugging, what the current
script path is. See onRequireImpl.
getter/setter pair
- global → Scope
-
The global scope.
final
- hasContext → bool
-
Shorthand for
scope.hasContext.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- onRequireImpl ↔ LuaRequireCallback?
-
Describes to do when lua processes the
require()function.getter/setter pair - results → BaseResults
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scope ↔ Scope
-
The current scope.
getter/setter pair
Methods
-
addDiagnostic(
String info) → void -
Build a meaningful diagnostic message from the current
runtime information and original message
info. -
addError(
String err) → void -
Build a meaningful error message from the current
runtime information and original message
err. -
addWarning(
String warn) → void -
Build a meaningful warning message from the current
runtime information and original message
warn. -
callLuaFunction(
LuaObject obj, {List< Object?> args = const []}) → LuaObject? -
Given a callable lua
objand a list ofargs, configure a new scope with the providedargsas parameters based on the LuaObject.funcDef record. Args exceeding the parameter list will be dropped. Any remaining parameters will be filled by LuaObject.nil values. Any exceptions are caught and tracked for the trace back later. The scope is popped and any return result LuaObject is returned. -
debugSetPath(
String? path) → void - Setter for debugPath.
-
defGlobal(
LuaObject value) → LuaObject -
Defines a global variable in the global scope with
lua object
value. -
defLocal(
LuaObject value) → LuaObject -
Defines a local variable in the current scope with
lua object
value. -
findOnSelf(
String field, {Object? or}) → LuaObject? -
First finds
fieldinside object "self" in the current scope. If neither can be found,oris returned cast toLua. Iforis not provided, null is returned. -
findVar(
String id) → LuaObject? -
Searches for a variable with the identifier
idin the current scope. The implementation details also searches the parents in order if not found locally until such anidis found. -
findVarArgs(
) → List< LuaObject> ? -
Search the current scope for the special
...identifier. -
lineInfo(
Token token) → String - Given a Token, return that token's line information. This is useful for debugging.
-
lineTag(
Token token) → String - For variables, return (row, col) as a virtual identifier stub. This is useful for debugging.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
popScope(
) → void - If there exists Scope.parent, then tail adopts that. This effectively pops the scope of execution. Otherwise nothing happens.
-
pushScope(
{LuaObject? context}) → void - A reverse linked list implementation where tail points towards head (the parent chain). Calling this function adds a new Scope node in the linked list as the new tail and sets scope to point to the latest tail node. Every node points to its Scope.parent.
-
tokenId(
Token token, {String? prefix}) → String -
Given a Token, construct a lua identifier stub.
If
prefixis non null, then the stub will have that prefix. -
toString(
) → String -
A string representation of this object.
inherited
-
visitAssignExpr(
AssignExpr assignExpr) → Object? -
override
-
visitAssignMultiExpr(
AssignMultiExpr assignMultiExpr) → Object? -
override
-
visitAST(
AST ast) → Object? -
The starting point of all lua programs.
This will visit every node in the tree.
The default result will be a program which
ran to completion.
override
-
visitBinaryExpr(
BinaryExpr expr) → Object? -
override
-
visitBooleanLiteral(
BooleanLiteral boolean) → Object? -
override
-
visitBreakStmt(
BreakStmt stmt) → Object? -
override
-
visitDeclArg(
DeclArg declArg) → Object? -
override
-
visitDeclMultiVar(
DeclMultiVar declMultiVar) → Object? -
override
-
visitDeclVar(
DeclVar declVar) → Object? -
override
-
visitForIterLoopStmt(
ForIterLoopStmt forIterLoopStmt) → Object? -
override
-
visitForLoopStmt(
ForLoopStmt forLoopStmt) → Object? -
override
-
visitFuncExpr(
FuncExpr expr) → Object? -
override
-
visitGotoLabelStmt(
GotoLabelStmt stmt) → Object? -
override
-
visitGotoStmt(
GotoStmt stmt) → Object? -
override
-
visitGroupExpr(
GroupExpr groupExpr) → Object? -
override
-
visitIfStmt(
IfStmt stmt) → Object? -
override
-
visitKeyValStmt(
KeyValStmt keyval) → Object? -
override
-
visitMemoryAccess(
MemoryAccess memoryAccess) → Object? -
override
-
visitNilLiteral(
NilLiteral nil) → Object? -
override
-
visitNotExpr(
NotExpr notExpr) → Object? -
override
-
visitNumberLiteral(
NumberLiteral number) → Object? -
override
-
visitRawExpr(
RawExpr rawExpr) → Object? -
override
-
visitRepeatUntilLoopStmt(
RepeatUntilLoopStmt repeatUntilLoopStmt) → Object? -
override
-
visitReturnStmt(
ReturnStmt expr) → Object? -
inherited
-
visitSelfExpr(
SelfExpr selfExpr) → Object? -
override
-
visitStringLiteral(
StringLiteral string) → Object? -
override
-
visitTableLiteral(
TableLiteral table) → Object? -
override
-
visitUnaryExpr(
UnaryExpr expr) → Object? -
override
-
visitWhileLoopStmt(
WhileLoopStmt whileLoopStmt) → Object? -
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited