From bb7eb9f78dcc4ed69ecc633660241c830c041fc0 Mon Sep 17 00:00:00 2001 From: bringert Date: Sun, 7 Jan 2007 18:31:48 +0000 Subject: [PATCH] JavaScript: fixed bug when linearization overwrote the children of the abstract syntax node, since getChildren now returned the actual array of children. --- lib/javascript/gflib.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/lib/javascript/gflib.js b/lib/javascript/gflib.js index 5c05259f0..583d9087e 100644 --- a/lib/javascript/gflib.js +++ b/lib/javascript/gflib.js @@ -17,7 +17,7 @@ Fun.prototype.show = function (prec) { } } else { var s = this.name; - var cs = this.getChildren(); + var cs = this.children; for (var i in cs) { s += " " + cs[i].show(1); } @@ -33,9 +33,6 @@ Fun.prototype.getChild = function (i) { Fun.prototype.setChild = function (i,c) { this.children[i] = c; }; -Fun.prototype.getChildren = function () { - return this.children; -} ; Fun.prototype.isMeta = function() { return this.name == '?'; } ; @@ -43,9 +40,8 @@ Fun.prototype.isComplete = function() { if (this.isMeta()) { return false; } else { - var cs = this.getChildren(); - for (var i in cs) { - if (!cs[i].isComplete()) { + for (var i in tree.children) { + if (!tree.children[i].isComplete()) { return false; } } @@ -98,9 +94,8 @@ Abstract.prototype.annotate = function(tree, type) { tree.type = type; } else { var typ = this.types[tree.name]; - var cs = tree.getChildren(); - for (var i in cs) { - this.annotate(cs[i], typ.args[i]); + for (var i in tree.children) { + this.annotate(tree.children[i], typ.args[i]); } } return tree; @@ -166,9 +161,9 @@ Concrete.prototype.linearizeToTerm = function (tree) { return this.lindef(tree.type, tree.name); } } else { - var cs = tree.getChildren(); - for (var i in cs) { - cs[i] = this.linearizeToTerm(cs[i]); + var cs = new Array(); + for (var i in tree.children) { + cs.push(this.linearizeToTerm(tree.children[i])); } return this.rule(tree.name, cs); }