matchCondition method

  1. @override
bool matchCondition (List<MixinArgs> args, Contexts context)
override

Implementation

@override
bool matchCondition(List<MixinArgs> args, Contexts context) {
  final List<Node> thisFrames = <Node>[
    ...this.frames ?? <Node>[],
    ...context.frames
  ];

  final List<Node> frames = <Node>[
    // the parameter variables
    evalParams(context, Contexts.eval(context, thisFrames), args, <Node>[]),
    // the parent namespace/mixin frames
    ...this.frames ?? <Node>[],
    // the current environment frames
    ...context.frames
  ];

  if (condition != null &&
      !condition.eval(Contexts.eval(context, frames)).evaluated) {
    return false;
  }

  return true;

//2.5.0 20150419
//  Definition.prototype.matchCondition = function (args, context) {
//      if (this.condition && !this.condition.eval(
//          new contexts.Eval(context,
//              [this.evalParams(context, /* the parameter variables*/
//                  new contexts.Eval(context, this.frames ? this.frames.concat(context.frames) : context.frames), args, [])]
//              .concat(this.frames || []) // the parent namespace/mixin frames
//              .concat(context.frames)))) { // the current environment frames
//          return false;
//      }
//      return true;
//  };
}