executeFunction method

Future<ASTValue> executeFunction(
  1. String namespace,
  2. String functionName, {
  3. List? positionalParameters,
  4. Map? namedParameters,
  5. bool allowClassMethod = false,
})

Executes a function in namespace and with name functionName.

  • positionalParameters Positional parameters to pass to the function.
  • namedParameters Named parameters to pass to the function.

Implementation

Future<ASTValue> executeFunction(String namespace, String functionName,
    {List? positionalParameters,
    Map? namedParameters,
    bool allowClassMethod = false}) async {
  var r = await getFunctionCodeUnit(namespace, functionName,
      allowClassMethod: allowClassMethod);

  var codeUnit = r.codeUnit;
  if (codeUnit == null) {
    throw StateError(
        "Can't find function to execute> functionName: $functionName ; language: $language");
  }

  var className = r.className;
  if (className != null) {
    return executeClassMethod(namespace, className, functionName,
        positionalParameters: positionalParameters,
        namedParameters: namedParameters);
  }

  var result = await codeUnit.root!.execute(
      functionName, positionalParameters, namedParameters,
      externalFunctionMapper: externalFunctionMapper, typeResolver: this);

  return result;
}