evalSource method

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

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

Implementation

dynamic evalSource(HTSource source,
    {String? moduleName,
    bool globallyImport = false,
    String? invokeFunc,
    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 result = interpreter.loadBytecode(
    bytes: bytes,
    moduleName: moduleName ?? source.fullName,
    globallyImport: globallyImport,
    invokeFunc: invokeFunc,
    positionalArgs: positionalArgs,
    namedArgs: namedArgs,
    typeArgs: typeArgs,
    printPerformanceStatistics: config.printPerformanceStatistics,
  );
  return result;
}