| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- "use strict";
- var MatchExpression = require('./MatchExpression');
- // Autogenerated by cport.py on 2013-09-17 14:37
- var ListOfMatchExpression = module.exports = function ListOfMatchExpression(matchType){
- base.call(this);
- this._expressions = [];
- this._matchType = matchType;
- }, klass = ListOfMatchExpression, base = MatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
- // File: expression_tree.h lines: 56-56
- proto._expressions = undefined;
- /**
- *
- * Print the debug info from each expression in the list
- * @method _debugList
- * @param level
- *
- */
- proto._debugList = function _debugList(level){
- // File: expression_tree.cpp lines: 40-42
- for (var i = 0; i < this._expressions.length; i++ )
- this._expressions[i].debugString(level + 1); // debug only takes level now
- };
- /**
- *
- * Append a new expression to our list
- * @method add
- * @param Expression
- *
- */
- proto.add = function add( exp ){
- // File: expression_tree.cpp lines: 34-36
- // verify(expression)
- if(!exp)
- throw new Error(exp + " failed verify on ListOfMatchExpression:34");
- if(this._expressions) {
- this._expressions.push(exp);
- } else {
- this._expressions = [exp];
- }
- };
- /**
- *
- * Empty us out
- * @method clearAndRelease
- *
- */
- proto.clearAndRelease = function clearAndRelease(){
- // File: expression_tree.h lines: 45-44
- this._expressions = []; // empty the expressions
- };
- /**
- *
- * Check if the input list is considered the same as this one
- * @method equivalent
- * @param other
- *
- */
- proto.equivalent = function equivalent(other){
- // File: expression_tree.cpp lines: 45-59
- if (this._matchType != other._matchType)
- return false;
- var realOther = new ListOfMatchExpression(other);
- if (this._expressions.length != realOther._expressions.length)
- return false;
- // TODO: order doesn't matter
- for (var i = 0; i < this._expressions.length; i++ )
- if (!this._expressions[i].equivalent(realOther._expressions[i]))
- return false;
- return true;
- };
- /**
- *
- * Get an item from the expressions
- * @method getChild
- * @param
- *
- */
- proto.getChild = function getChild(i){
- // File: expression_tree.h lines: 48-47
- return this._expressions[i];
- };
- /**
- *
- * Get the length of the list
- * @method numChildren
- * @param
- *
- */
- proto.numChildren = function numChildren(){
- // File: expression_tree.h lines: 47-46
- return this._expressions.length;
- };
|