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:
@@ -17,7 +17,7 @@ Fun.prototype.show = function (prec) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var s = this.name;
|
var s = this.name;
|
||||||
var cs = this.getChildren();
|
var cs = this.children;
|
||||||
for (var i in cs) {
|
for (var i in cs) {
|
||||||
s += " " + cs[i].show(1);
|
s += " " + cs[i].show(1);
|
||||||
}
|
}
|
||||||
@@ -33,9 +33,6 @@ Fun.prototype.getChild = function (i) {
|
|||||||
Fun.prototype.setChild = function (i,c) {
|
Fun.prototype.setChild = function (i,c) {
|
||||||
this.children[i] = c;
|
this.children[i] = c;
|
||||||
};
|
};
|
||||||
Fun.prototype.getChildren = function () {
|
|
||||||
return this.children;
|
|
||||||
} ;
|
|
||||||
Fun.prototype.isMeta = function() {
|
Fun.prototype.isMeta = function() {
|
||||||
return this.name == '?';
|
return this.name == '?';
|
||||||
} ;
|
} ;
|
||||||
@@ -43,9 +40,8 @@ Fun.prototype.isComplete = function() {
|
|||||||
if (this.isMeta()) {
|
if (this.isMeta()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
var cs = this.getChildren();
|
for (var i in tree.children) {
|
||||||
for (var i in cs) {
|
if (!tree.children[i].isComplete()) {
|
||||||
if (!cs[i].isComplete()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,9 +94,8 @@ Abstract.prototype.annotate = function(tree, type) {
|
|||||||
tree.type = type;
|
tree.type = type;
|
||||||
} else {
|
} else {
|
||||||
var typ = this.types[tree.name];
|
var typ = this.types[tree.name];
|
||||||
var cs = tree.getChildren();
|
for (var i in tree.children) {
|
||||||
for (var i in cs) {
|
this.annotate(tree.children[i], typ.args[i]);
|
||||||
this.annotate(cs[i], typ.args[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tree;
|
return tree;
|
||||||
@@ -166,9 +161,9 @@ Concrete.prototype.linearizeToTerm = function (tree) {
|
|||||||
return this.lindef(tree.type, tree.name);
|
return this.lindef(tree.type, tree.name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var cs = tree.getChildren();
|
var cs = new Array();
|
||||||
for (var i in cs) {
|
for (var i in tree.children) {
|
||||||
cs[i] = this.linearizeToTerm(cs[i]);
|
cs.push(this.linearizeToTerm(tree.children[i]));
|
||||||
}
|
}
|
||||||
return this.rule(tree.name, cs);
|
return this.rule(tree.name, cs);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user