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
compilerVersion ↔ Version
getter/setter pair
config InterpreterConfig
getter/setter pair
currentBytecodeModule HTBytecodeModule
no setter
currentColumn int
no setter
currentFile String
no setter
currentLine int
no setter
currentNamespace HTNamespace
getter/setter pair
errorConfig ErrorHandlerConfig
no setter
externalClasses Map<String, HTExternalClass>
final
externalFunctions Map<String, Function>
final
externalFunctionTypedefs Map<String, HTExternalFunctionTypedef>
final
externalMethods Map<String, Function>
final
externalTypeReflection List<HTExternalTypeReflection>
final
globallyImport bool
getter/setter pair
globalNamespace HTNamespace
latefinal
hashCode int
The hash code for this object.
no setterinherited
isInitted bool
getter/setter pair
lexicon HTLexicon
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scriptMode bool
getter/setter pair
sourceContext HTResourceContext<HTSource>
getter/setter pair
stack HTStackFrame
no setter
stackTraceList List<String>
getter/setter pair

Methods

assign(String id, dynamic value, {String? namespace, String? module, bool defineIfAbsent = false}) → 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 = true}) → void
Register an external function in script there must be a declaraction also in script for using this the function here can be either a pure dart function or a HTExternalFunction we use a conventions to distinguish different types of functions here:
bindExternalFunctionType(String id, HTExternalFunctionTypedef function, {bool override = true}) → void
Register a external function typedef into scrfipt
bindExternalMethod(String id, Function method, {bool override = true}) → void
Register a external method in scrfipt there must be a declaraction also in script for using this the function here must be a HTExternalMethod use id like '$classId::$functionId'
bindExternalReflection(HTExternalTypeReflection reflection) → void
Bind an external class name to a abstract class name for interpreter getting dart class name by reflection
containsExternalClass(String id) bool
Wether the interpreter has a certain external class binding.
createStructfromJSON(Map jsonData) HTStruct
decltypeof(String id) HTType
define(String id, dynamic value, {bool isMutable = false, bool override = false, bool throws = true, String? module, String? namespace}) → void
Add a declaration to certain namespace. if the value is not a declaration, will create one with isMutable value. if not, the isMutable will be ignored.
encapsulate(dynamic object) HTObject?
Encapsulate any value to a Hetu object, for members accessing and type check.
execute({bool createStackFrame = true, bool propagateValue = true, HTContext? context, HTStackFrame? stackFrame, dynamic localValue}) → dynamic
Interpret a loaded module with the key of module Starting from the instruction pointer of ip This function will return current expression value when encountered OpCode.endOfExec or OpCode.endOfFunc.
fetch(String id, {String? namespace, String? module, bool ignoreUndefined = false}) → 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 an external function or a method
fetchExternalMethod(String id) Function
Fetch an external method
getBytecode(String module) HTBytecodeModule?
getContext() HTContext
Get the current context of the interpreter,
help(dynamic object, {String? module}) String?
Get the documentation of a declaration in a certain namespace.
invoke(String func, {bool ignoreUndefined = false, String? namespace, String? module, bool isConstructor = false, List positionalArgs = const [], Map<String, dynamic> namedArgs = 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 module, bool globallyImport = false, String? invoke, List positionalArgs = const [], Map<String, dynamic> namedArgs = const {}}) → dynamic
Load a pre-compiled bytecode module. If invoke is true, run 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(HTContext? context) → void
Change the current context of the bytecode interpreter to a new one.
stringify(dynamic object) String
switchModule(String module) → void
toString() String
A string representation of this object.
inherited
toStructValue(dynamic value) → dynamic
truthy(dynamic condition) bool
inexpicit type conversion for truthy values
typeOf(dynamic object) HTType
Get a object's type value at runtime.
unwrapExternalFunctionType(HTFunction func) Function
Using unwrapper to turn a script function into a external function
waitFutureExucution(FutureExecution futureExecution) Future
warmUpNamespaces() → void
Trigger eager initialization for all HTVariables and HTNamedStructs within nsp that have lazy-initialization bytecode (ip != null) but haven't been initialized yet (_value == null).

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

classRoot HTClass?
getter/setter pair
structRoot HTStruct?
getter/setter pair