diff options
author | alon@honor <none@none> | 2010-09-03 23:04:23 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-09-03 23:04:23 -0700 |
commit | 8181e238184e170ec31bab865859e7c9294824a4 (patch) | |
tree | 6987f555d57d2dfa1a53a924bbe38958a0b9986b /src/parser.js | |
parent | c1f71fad78b739ee6963735c00fd336375c3b117 (diff) |
support for global consts
Diffstat (limited to 'src/parser.js')
-rw-r--r-- | src/parser.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/parser.js b/src/parser.js index 802a049a..9908b0a5 100644 --- a/src/parser.js +++ b/src/parser.js @@ -1845,7 +1845,7 @@ function JSify(data) { item.JS += makePointer(JSON.stringify(makeEmptyStruct(item.type))); } else { // Generate a constant - item.JS += parseConst(value); + item.JS += parseConst(value, item.type); } item.JS += ';'; item.__result__ = true; @@ -1854,9 +1854,11 @@ function JSify(data) { }); // Gets an entire constant expression - function parseConst(value) { - //print('//yyyyy ' + JSON.stringify(value)); - if (value.text[0] == '"') { + function parseConst(value, type) { + //print('//yyyyy ' + JSON.stringify(value) + ',' + type); + if (isNumberType(type)) { + return makePointer(value.text); + } else if (value.text[0] == '"') { value.text = value.text.substr(1, value.text.length-2); return makePointer('intArrayFromString("' + value.text + '")'); } else { |