Hetu class

A helper class wrapped sourceContext, lexicon, parser, bundler, analyzer, compiler, interpreter, logger... and make them work together.

Constructors

Hetu({HetuConfig? config, HTLogger? logger, HTResourceContext<HTSource>? sourceContext, HTLocale? locale, HTLexicon? lexicon, HTLexer? lexer, HTParser? parser})
Create a Hetu environment.

Properties

analyzer HTAnalyzer
latefinal
bundler HTBundler
latefinal
compiler HTCompiler
latefinal
config HetuConfig
getter/setter pair
console Console
latefinal
hashCode int
The hash code for this object.
no setterinherited
interpreter HTInterpreter
latefinal
isInitted bool
no setter
lexer HTLexer
no setter
lexicon HTLexicon
no setter
parser HTParser
latefinal
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 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.
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? filename, 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 id, dynamic value, {bool isMutable = false, bool override = false, bool throws = true, String? module}) → void
Add a declaration to certain namespace.
eval(String content, {String? filename, String? module, bool globallyImport = false, HTResourceType type = HTResourceType.hetuLiteralCode, String? invoke, List positionalArgs = const [], Map<String, dynamic> namedArgs = const {}}) → dynamic
Evaluate a string content. If invoke is provided, will immediately call the function after evaluation completed.
evalFile(String key, {String? module, bool globallyImport = false, String? invoke, List positionalArgs = const [], Map<String, dynamic> namedArgs = const {}}) → dynamic
Evaluate a file. key is a possibly relative path. file content will be searched by sourceContext. If invoke is provided, will immediately call the function after evaluation completed.
evalSource(HTSource source, {String? module, bool globallyImport = false, String? invoke, List positionalArgs = const [], Map<String, dynamic> namedArgs = const {}}) → dynamic
Evaluate a HTSource. If invoke is provided, will immediately call the function after evaluation completed.
fetch(String id, {String? namespace, String? module, bool ignoreUndefined = false}) → dynamic
Get a variable defined in a certain namespace in the interpreter.
help(dynamic id, {String? module}) String?
Get the documentational comment of an identifier within the soruce code.
init({bool useDefaultModuleAndBinding = true, Map<String, Function> externalFunctions = const {}, Map<String, HTExternalMethod> externalMethods = 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 func, {bool ignoreUndefined = false, String? namespace, String? module, List positionalArgs = const [], Map<String, dynamic> namedArgs = const {}}) → dynamic
Invoke a top level function defined in a certain namespace in the interpreter.
loadBytecode({required Uint8List bytes, required String module, bool globallyImport = false, String? invoke, List positionalArgs = const [], Map<String, dynamic> namedArgs = 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
Dynamically load a source into current bytecode.
stringify(dynamic dynamic) String
toString() String
A string representation of this object.
inherited

Operators

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