From a47a95b4e2262aba01752a1937430a8e0f698cdd Mon Sep 17 00:00:00 2001 From: bringert Date: Thu, 4 Jan 2007 22:27:38 +0000 Subject: [PATCH] JavaScript lib: fixed bug where an integer was returned by print(). --- lib/javascript/gflib.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/javascript/gflib.js b/lib/javascript/gflib.js index ed57fe443..2097e53ae 100644 --- a/lib/javascript/gflib.js +++ b/lib/javascript/gflib.js @@ -66,15 +66,15 @@ Fun.prototype.isComplete = function() { /* Concrete syntax terms */ -function Arr() { this.values = copy_arguments(arguments, 0); } -Arr.prototype.print = function() { return this.values[0].print(); }; -Arr.prototype.sel = function(i) { return this.values[i.toIndex()]; }; +function Arr() { this.arr = copy_arguments(arguments, 0); } +Arr.prototype.print = function() { return this.arr[0].print(); }; +Arr.prototype.sel = function(i) { return this.arr[i.toIndex()]; }; -function Seq() { this.values = copy_arguments(arguments, 0); } -Seq.prototype.print = function() { return join_print(this.values, " "); }; +function Seq() { this.seq = copy_arguments(arguments, 0); } +Seq.prototype.print = function() { return join_print(this.seq, " "); }; -function Variants() { this.values = copy_arguments(arguments, 0); } -Variants.prototype.print = function() { return /*join_print(this.values, "/");*/ this.values[0].print(); }; +function Variants() { this.variants = copy_arguments(arguments, 0); } +Variants.prototype.print = function() { return this.variants[0].print(); }; function Rp(index,value) { this.index = index; this.value = value; } Rp.prototype.print = function() { return this.index; }; @@ -93,7 +93,7 @@ function Str(value) { this.value = value; } Str.prototype.print = function() { return this.value; }; function Int(value) { this.value = value; } -Int.prototype.print = function() { return this.value; }; +Int.prototype.print = function() { return this.value.toString(); }; Int.prototype.toIndex = function() { return this.value; }; /* Type annotation */ @@ -192,6 +192,7 @@ function isArray(a) { return a && typeof a == 'object' && a.constructor == Array function isUndefined(a) { return typeof a == 'undefined'; } function isBoolean(a) { return typeof a == 'boolean'; } function isNumber(a) { return typeof a == 'number' && isFinite(a); } +function isFunction(a) { return typeof a == 'function'; } function dumpObject (obj) { if (isUndefined(obj)) {