ListOfMatchExpression.js 2.2 KB

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