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)
- Configures _ENV and _ENV._G in the global scope.
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 top-most scope.
Note globals are actually written to globalEnv.
final
- globalEnv → LuaObject
-
_ENV variable.
final
- globalG ↔ LuaObject
-
Legacy _G variable points to _ENV.
latefinal
- 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 [], LuaExceptionCallback? onException}) → List<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 LuaObjects are returned as an argpack. -
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
-
pushScope(
{LuaObject? context, Scope? parent}) → 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.
-
restoreScope(
Scope next) → void -
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
-
visitAssignMultiStmt(
AssignMultiStmt assignMultiStmt) → Object? -
override
-
visitAssignStmt(
AssignStmt assignStmt) → Object? -
Visits rhs first and then evaluate lhs.
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