invoke method
dynamic
invoke(})
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.
Implementation
dynamic invoke(String funcName,
{String? moduleName,
bool isConstructorCall = false,
List<dynamic> positionalArgs = const [],
Map<String, dynamic> namedArgs = const {},
List<HTType> typeArgs = const []}) {
try {
stackTraceList.clear();
final savedModuleName = _currentBytecodeModule.id;
HTNamespace nsp = globalNamespace;
if (moduleName != null) {
if (_currentBytecodeModule.id != moduleName) {
_currentBytecodeModule = cachedModules[moduleName]!;
}
assert(_currentBytecodeModule.namespaces.isNotEmpty);
nsp = _currentBytecodeModule.namespaces.values.last;
}
final callee = nsp.memberGet(funcName, isRecursive: false);
final result = _call(
callee,
positionalArgs: positionalArgs,
namedArgs: namedArgs,
typeArgs: typeArgs,
);
if (_currentBytecodeModule.id != savedModuleName) {
_currentBytecodeModule = cachedModules[savedModuleName]!;
}
return result;
} catch (error, stackTrace) {
if (config.processError) {
processError(error, stackTrace);
} else {
rethrow;
}
}
}