MixinDefinition constructor

MixinDefinition(String name, List<MixinArgs> params, List<Node> rules, Node condition, { bool variadic, int index, FileInfo currentFileInfo, List<Node> frames, VisibilityInfo visibilityInfo })

Implementation

//index, currentFileInfo not in original. See order when calling with frames.
MixinDefinition(String name, this.params, this.rules, this.condition,
    {this.variadic,
    int index,
    FileInfo currentFileInfo,
    this.frames,
    VisibilityInfo visibilityInfo}) {
  this.name = name ??= 'anonymous mixin';
  evalFirst = true;
  isRuleset = true;
  // ignore: prefer_initializing_formals
  this.currentFileInfo = currentFileInfo;
  this.index = index;

  selectors = <Selector>[
    Selector(<Element>[
      Element(null, name,
          isVariable: false, index: _index, currentFileInfo: _fileInfo)
    ])
  ];

  arity = params.length;

  optionalParameters = <String>[];

  required = params.fold(0, (int count, MixinArgs p) {
    if (p.name == null || (p.name != null && p.value == null)) {
      return count + 1;
    } else {
      optionalParameters.add(p.name);
      return count;
    }
  });

  copyVisibilityInfo(visibilityInfo);
  allowRoot = true;

  //this._lookups = {}; //inside VariableMixin

// 3.5.3 20180708
//  var Definition = function (name, params, rules, condition, variadic, frames, visibilityInfo) {
//      this.name = name || 'anonymous mixin';
//      this.selectors = [new Selector([new Element(null, name, false, this._index, this._fileInfo)])];
//      this.params = params;
//      this.condition = condition;
//      this.variadic = variadic;
//      this.arity = params.length;
//      this.rules = rules;
//      this._lookups = {};
//      var optionalParameters = [];
//      this.required = params.reduce(function (count, p) {
//          if (!p.name || (p.name && !p.value)) {
//              return count + 1;
//          }
//          else {
//              optionalParameters.push(p.name);
//              return count;
//          }
//      }, 0);
//      this.optionalParameters = optionalParameters;
//      this.frames = frames;
//      this.copyVisibilityInfo(visibilityInfo);
//      this.allowRoot = true;
//  };
}