HTInterpreter class
A bytecode implementation of Hetu Script interpreter
Constructors
-
HTInterpreter({InterpreterConfig? config, required HTResourceContext<
HTSource> sourceContext, HTLexicon? lexicon}) - A bytecode interpreter.
Properties
-
cachedModules
→ Map<
String, HTBytecodeModule> -
final
- config ↔ InterpreterConfig
-
getter/setter pair
- currentBytecodeModule → HTBytecodeModule
-
no setter
- currentColumn → int
-
no setter
- currentFileName → String
-
no setter
- currentLine → int
-
no setter
- currentNamespace → HTNamespace
-
no setter
- errorConfig → ErrorHandlerConfig
-
no setter
-
externClasses
→ Map<
String, HTExternalClass> -
final
-
externFunctions
→ Map<
String, Function> -
final
-
externFunctionTypedefs
→ Map<
String, HTExternalFunctionTypedef> -
final
-
externTypeReflection
→ List<
HTExternalTypeReflection> -
final
- globalNamespace ↔ HTNamespace
-
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
- lexicon → HTLexicon
-
no setter
- localSymbol → String?
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
sourceContext
↔ HTResourceContext<
HTSource> -
getter/setter pair
-
stackTraceList
→ List<
String> -
final
Methods
-
assign(
String varName, dynamic value, {String? moduleName, String? sourceName}) → void - Assign value to a top level variable defined in a certain namespace in the interpreter.
-
bindExternalClass(
HTExternalClass externalClass, {bool override = false}) → void - Register a external class into scrfipt. For acessing static members and constructors of this class, there must also be a declaraction in script
-
bindExternalFunction(
String id, Function function, {bool override = false}) → void - Register a external function into scrfipt there must be a declaraction also in script for using this
-
bindExternalFunctionType(
String id, HTExternalFunctionTypedef function, {bool override = false}) → void - Register a external function typedef into scrfipt
-
bindExternalReflection(
HTExternalTypeReflection reflection) → void - Bind a external class name to a abstract class name for interpreter get dart class name by reflection
-
containsExternalClass(
String id) → bool - Wether the interpreter has a certain external class binding.
-
createStructfromJson(
Map jsonData) → HTStruct -
encapsulate(
dynamic object) → HTEntity - Encapsulate any value to a Hetu object, for members accessing and type check.
-
execute(
{bool retractStackFrame = true, HTContext? context, dynamic localValue}) → dynamic -
Interpret a loaded module with the key of
moduleName
Starting from the instruction pointer ofip
This function will return current expression value when encountered HTOpCode.endOfExec or HTOpCode.endOfFunc. -
fetch(
String varName, {String? moduleName, String? sourceName}) → dynamic - Get a top level variable defined in a certain namespace.
-
fetchExternalClass(
String id) → HTExternalClass - Fetch a external class instance
-
fetchExternalFunction(
String id) → Function - Fetch a external function
-
getBytecode(
String moduleName) → HTBytecodeModule? -
getContext(
{bool filename = true, bool moduleName = true, bool namespace = true, bool ip = true, bool line = true, bool column = true}) → HTContext - Get the current context of the interpreter, parameter determines wether to store certain items. For example, if you set ip to false, the context you get from this method will leave ip as null.
-
invoke(
String funcName, {String? moduleName, String? sourceName, bool isConstructorCall = false, List positionalArgs = const [], Map< String, dynamic> namedArgs = const {}, List<HTType> typeArgs = const []}) → dynamic - Invoke a top level function defined in a certain namespace. It's possible to use this method to invoke a HTClass or HTNamedStruct name as a contruct call, you will get a HTInstance or HTStruct as return value.
-
loadBytecode(
{required Uint8List bytes, required String moduleName, bool globallyImport = false, String? invokeFunc, List positionalArgs = const [], Map< String, dynamic> namedArgs = const {}, List<HTType> typeArgs = const [], bool debugPerformance = false}) → dynamic -
Load a pre-compiled bytecode file as a module.
If
invokeFunc
is true, execute the bytecode immediately. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
processError(
Object error, [Object? externalStackTrace]) → void - Catch errors throwed by other code, and wrap them with detailed informations.
-
setContext(
{StackFrameStrategy stackFrameStrategy = StackFrameStrategy.none, HTContext? context}) → void - Change the current context of the bytecode interpreter to a new one.
-
stringify(
dynamic object) → String -
switchModule(
String moduleName) → void -
toString(
) → String -
A string representation of this object.
inherited
-
toStructValue(
dynamic value) → dynamic -
unwrapExternalFunctionType(
HTFunction func) → Function - Using unwrapper to turn a script function into a external function
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- rootClass ↔ HTClass?
-
getter/setter pair
- rootStruct ↔ HTStruct?
-
getter/setter pair