ListOfMatchExpression.js 2.2 KB

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