1
0
forked from GitHub/gf-core

JavaScript: fixed bug when linearization overwrote the children of the abstract syntax node, since getChildren now returned the actual array of children.

This commit is contained in:
bringert
2007-01-07 18:31:48 +00:00
parent 3220f75dcb
commit bb7eb9f78d

View File

@@ -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);
}