ListOfMatchExpression.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. "use strict";
  2. var MatchExpression = require('./MatchExpression');
  3. // Autogenerated by cport.py on 2013-09-17 14:37
  4. var ListOfMatchExpression = module.exports = function ListOfMatchExpression(matchType){
  5. this._expressions = [];
  6. this._matchType = matchType;
  7. }, klass = ListOfMatchExpression, base = MatchExpression, proto = klass.prototype = Object.create(base.prototype, {constructor:{value:klass}});
  8. // File: expression_tree.h lines: 56-56
  9. proto._expressions = undefined;
  10. /**
  11. *
  12. * Print the debug info from each expression in the list
  13. * @method _debugList
  14. * @param level
  15. *
  16. */
  17. proto._debugList = function _debugList(level){
  18. // File: expression_tree.cpp lines: 40-42
  19. for (var i = 0; i < this._expressions.length; i++ )
  20. this._expressions[i].debugString(level + 1); // debug only takes level now
  21. };
  22. /**
  23. *
  24. * Append a new expression to our list
  25. * @method add
  26. * @param Expression
  27. *
  28. */
  29. proto.add = function add(Expression){
  30. // File: expression_tree.cpp lines: 34-36
  31. // verify(expression)
  32. if(!Expression)
  33. throw new Error(Expression + " failed verify on ListOfMatchExpression:34");
  34. this._expressions.push(Expression);
  35. };
  36. /**
  37. *
  38. * Empty us out
  39. * @method clearAndRelease
  40. *
  41. */
  42. proto.clearAndRelease = function clearAndRelease(){
  43. // File: expression_tree.h lines: 45-44
  44. this._expressions = []; // empty the expressions
  45. };
  46. /**
  47. *
  48. * Check if the input list is considered the same as this one
  49. * @method equivalent
  50. * @param other
  51. *
  52. */
  53. proto.equivalent = function equivalent(other){
  54. // File: expression_tree.cpp lines: 45-59
  55. if (this._matchType != other._matchType)
  56. return false;
  57. var realOther = new ListOfMatchExpression(other);
  58. if (this._expressions.length != realOther._expressions.length)
  59. return false;
  60. // TODO: order doesn't matter
  61. for (var i = 0; i < this._expressions.length; i++ )
  62. if (!this._expressions[i].equivalent(realOther._expressions[i]))
  63. return false;
  64. return true;
  65. };
  66. /**
  67. *
  68. * Get an item from the expressions
  69. * @method getChild
  70. * @param
  71. *
  72. */
  73. proto.getChild = function getChild(i){
  74. // File: expression_tree.h lines: 48-47
  75. return this._expressions[i];
  76. };
  77. /**
  78. *
  79. * Get the length of the list
  80. * @method numChildren
  81. * @param
  82. *
  83. */
  84. proto.numChildren = function numChildren(){
  85. // File: expression_tree.h lines: 47-46
  86. return this._expressions.length;
  87. };