callCommon method

  1. @internal
Object? callCommon(
  1. Function function,
  2. List<Object?> positional,
  3. Map<Symbol, Object?> named,
  4. Context? context,
)

Common filter and test caller.

Implementation

@internal
Object? callCommon(
  Function function,
  List<Object?> positional,
  Map<Symbol, Object?> named,
  Context? context,
) {
  var pass = PassArgument.types[function];

  if (pass == PassArgument.context) {
    if (context == null) {
      throw TemplateRuntimeError(
          'Attempted to invoke context function without context.');
    }

    positional = <Object?>[context, ...positional];
  } else if (pass == PassArgument.environment) {
    positional = <Object?>[this, ...positional];
  }

  return Function.apply(function, positional, named);
}