aboutsummaryrefslogtreecommitdiff
path: root/src/parser.js
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-09-06 15:25:17 -0700
committeralon@honor <none@none>2010-09-06 15:25:17 -0700
commite5847048c36de42ca50284f956f5747b67de09c5 (patch)
tree88f885ee9ecd0cc652bddd301c10eea96dfbbafd /src/parser.js
parent3c5c095e6542f6c9f56fbdce7a1bfa698a78fe34 (diff)
fixes for null vs 0, and support for assert +test
Diffstat (limited to 'src/parser.js')
-rw-r--r--src/parser.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/parser.js b/src/parser.js
index 6da567db..40bffff0 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -68,6 +68,7 @@ function pointingLevels(type) {
function toNiceIdent(ident) {
if (parseFloat(ident) == ident) return ident;
+ if (ident == 'null') return '0'; // see parseNumerical
return ident.replace(/[" \.@%:<>,\*]/g, '_');
}
@@ -325,6 +326,10 @@ function parseNumerical(value, type) {
// "The one non-intuitive notation for constants is the hexadecimal form of floating point constants."
return IEEEUnHex(value);
}
+ if (value == 'null') {
+ // NULL *is* 0, in C/C++. No JS null! (null == 0 is false, etc.)
+ return '0';
+ }
return value;
}
@@ -2139,12 +2144,11 @@ function JSify(data) {
item.JS = (item.overrideSSA ? '' : 'var ') + toNiceIdent(item.ident);
var type = item.value.type.text;
- var value = item.value.JS;
+ var value = parseNumerical(item.value.JS);
//print("zz var: " + item.JS);
var impl = getVarData(item.funcData, item.ident);
switch (impl) {
case VAR_NATIVE: {
- value = parseNumerical(value, type);
break;
}
case VAR_NATIVIZED: {