evalSource method

dynamic evalSource(
  1. HTSource source, {
  2. String? module,
  3. bool globallyImport = false,
  4. String? invoke,
  5. List positionalArgs = const [],
  6. Map<String, dynamic> namedArgs = const {},
})

Evaluate a HTSource. If invoke is provided, will immediately call the function after evaluation completed.

Implementation

dynamic evalSource(
  HTSource source, {
  String? module,
  bool globallyImport = false,
  String? invoke,
  List<dynamic> positionalArgs = const [],
  Map<String, dynamic> namedArgs = const {},
  // List<HTType> typeArgs = const [],
}) {
  if (source.content.trim().isEmpty) {
    return null;
  }
  final bytes = _compileSource(source);
  final savedContext = interpreter.getContext();
  final result = interpreter.loadBytecode(
    bytes: bytes,
    module: module ?? source.fullName,
    globallyImport: globallyImport,
    invoke: invoke,
    positionalArgs: positionalArgs,
    namedArgs: namedArgs,
    // typeArgs: typeArgs,
  );
  interpreter.setContext(savedContext);
  return result;
}