eval method

dynamic eval(
  1. String content, {
  2. String? fileName,
  3. String? moduleName,
  4. bool globallyImport = false,
  5. HTResourceType type = HTResourceType.hetuLiteralCode,
  6. String? invokeFunc,
  7. List positionalArgs = const [],
  8. Map<String, dynamic> namedArgs = const {},
  9. List<HTType> typeArgs = const [],
})

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

Implementation

dynamic eval(String content,
    {String? fileName,
    String? moduleName,
    bool globallyImport = false,
    HTResourceType type = HTResourceType.hetuLiteralCode,
    String? invokeFunc,
    List<dynamic> positionalArgs = const [],
    Map<String, dynamic> namedArgs = const {},
    List<HTType> typeArgs = const []}) {
  if (content.trim().isEmpty) return null;
  final source = HTSource(content, fullName: fileName, type: type);
  final result = evalSource(source,
      moduleName: moduleName,
      globallyImport: globallyImport,
      invokeFunc: invokeFunc,
      positionalArgs: positionalArgs,
      namedArgs: namedArgs,
      typeArgs: typeArgs);
  return result;
}