Hetu class

A wrapper class for sourceContext, lexicon, parser, bundler, analyzer, compiler and interpreter to make them work together.

Constructors

Hetu({HetuConfig? config, HTResourceContext<HTSource>? sourceContext, HTLexicon? lexicon, String parserName = 'default', HTParser? parser})
Create a Hetu environment.

Properties

analyzer HTAnalyzer
latefinal
bundler HTBundler
latefinal
compiler HTCompiler
latefinal
config HetuConfig
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
interpreter HTInterpreter
latefinal
isInitted bool
no setter
lexicon HTLexicon
latefinal
parser HTParser
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sourceContext HTResourceContext<HTSource>
final
verison ↔ Version?
getter/setter pair

Methods

assign(String varName, dynamic value, {String? moduleName}) → void
Assign value to a top level variable defined in a certain namespace in the interpreter.
bundle(HTSource source, {Version? version, bool errorHandled = false}) ASTCompilation
Process the import declaration within several sources, generate a single ASTCompilation for HTCompiler to compile.
compile(String content, {String? sourceName, CompilerConfig? config, bool isModuleEntryScript = false, Version? version}) Uint8List
Compile a string into bytecode. This won't execute the code, so runtime errors will not be reported.
compileFile(String key, {CompilerConfig? config, Version? version}) Uint8List
Compile a source within current sourceContext. This won't execute the code, so runtime errors will not be reported.
define(String varName, dynamic value, {bool isMutable = false, bool override = false, bool throws = true, String? moduleName, String? sourceName}) bool
Add a declaration to certain namespace.
eval(String content, {String? fileName, String? moduleName, bool globallyImport = false, HTResourceType type = HTResourceType.hetuLiteralCode, String? invokeFunc, List positionalArgs = const [], Map<String, dynamic> namedArgs = const {}, List<HTType> typeArgs = const []}) → dynamic
Evaluate a string content. If invokeFunc is provided, will immediately call the function after evaluation completed.
evalFile(String key, {String? moduleName, bool globallyImport = false, String? invokeFunc, List positionalArgs = const [], Map<String, dynamic> namedArgs = const {}, List<HTType> typeArgs = const []}) → dynamic
Evaluate a file. key is a possibly relative path. file content will be searched by sourceContext. If invokeFunc is provided, will immediately call the function after evaluation completed.
evalSource(HTSource source, {String? moduleName, bool globallyImport = false, String? invokeFunc, List positionalArgs = const [], Map<String, dynamic> namedArgs = const {}, List<HTType> typeArgs = const []}) → dynamic
Evaluate a HTSource. If invokeFunc is provided, will immediately call the function after evaluation completed.
fetch(String varName, {String? moduleName}) → dynamic
Get a top level variable defined in a certain namespace in the interpreter.
help(dynamic id, {String? moduleName}) String?
init({bool useDefaultModuleAndBinding = true, HTLocale? locale, Map<String, Function> externalFunctions = const {}, Map<String, HTExternalFunctionTypedef> externalFunctionTypedef = const {}, List<HTExternalClass> externalClasses = const [], List<HTExternalTypeReflection> externalTypeReflections = const []}) → void
Initialize the interpreter, prepare it with preincluded modules, bind it with HTExternalFunction, HTExternalFunctionTypedef, HTExternalClass, etc.
invoke(String funcName, {String? moduleName, List positionalArgs = const [], Map<String, dynamic> namedArgs = const {}, List<HTType> typeArgs = const []}) → dynamic
Invoke a top level function defined in a certain namespace in the interpreter.
loadBytecode({required Uint8List bytes, required String moduleName, bool globallyImport = false, String? invokeFunc, List positionalArgs = const [], Map<String, dynamic> namedArgs = const {}, List<HTType> typeArgs = const []}) → dynamic
Load a bytecode module and immediately run a function in it.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
require(String path) HTNamespace
Load a source into current bytecode dynamically.
setParser(String name) → void
Change the current parser.
toString() String
A string representation of this object.
inherited

Operators

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