diff options
author | alon@honor <none@none> | 2010-09-06 19:02:30 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-09-06 19:02:30 -0700 |
commit | 883237a187d1097987b26c6ba10bbeea6d8c03e5 (patch) | |
tree | bc9f3e18a709dbfe334fd08ce614d7bf2f37a632 /src/parser.js | |
parent | c3cb5a541e44c7ab6746be03c56bd3f0c2f4e77d (diff) |
fixes for null instead of 0, and makePointer on raw values instead of arrays
Diffstat (limited to 'src/parser.js')
-rw-r--r-- | src/parser.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/parser.js b/src/parser.js index 40b4b98f..b12abfad 100644 --- a/src/parser.js +++ b/src/parser.js @@ -1850,6 +1850,9 @@ function JSify(data) { function makePointer(slab, pos) { // XXX hardcoded ptr impl if (slab == 'HEAP') return pos; + if (slab[0] != '[') { + slab = '[' + slab + ']'; + } return 'Pointer_make(' + slab + ', ' + (pos ? pos : 0) + ')'; // return '{ slab: ' + slab + ', pos: ' + (pos ? pos : 0) + ' }'; // return '[' + slab + ', ' + (pos ? pos : 0) + ']'; @@ -1913,10 +1916,8 @@ function JSify(data) { // Gets an entire constant expression function parseConst(value, type) { dprint('gconst', '//yyyyy ' + JSON.stringify(value) + ',' + type); - if (isNumberType(type)) { - return makePointer(value.text); - } else if (pointingLevels(type) == 1) { - return makePointer(value.text); + if (isNumberType(type) || pointingLevels(type) == 1) { + return makePointer(parseNumerical(value.text)); } else if (value.text == 'zeroinitializer') { return JSON.stringify(makeEmptyStruct(type)); } else if (value.text[0] == '"') { @@ -1929,7 +1930,7 @@ function JSify(data) { function handleSegment(segment) { //print('// seggg: ' + JSON.stringify(segment) + '\n') if (segment[1].text == 'null') { - return 'null'; + return '0'; } else if (segment[1].text == 'zeroinitializer') { return JSON.stringify(makeEmptyStruct(segment[0].text)); } else if (segment[1].text == 'getelementptr') { @@ -1951,7 +1952,7 @@ function JSify(data) { return '???!???'; } }; - return splitTokenList(tokens).map(handleSegment).join(', '); + return splitTokenList(tokens).map(handleSegment).map(parseNumerical).join(', '); } if (value.item) { // list of items @@ -2066,7 +2067,7 @@ function JSify(data) { }).filter(function(param) { return param != null }).join(', '); func.JS = '\nfunction ' + func.ident + '(' + params + ') {\n'; - if (LABEL_DEBUG) func.JS += " print(INDENT + 'Entering: " + func.ident + "'); INDENT += ' ';\n"; + if (LABEL_DEBUG) func.JS += " print(INDENT + ' Entering: " + func.ident + "'); INDENT += ' ';\n"; // Walk function blocks and generate JS function walkBlock(block, indent) { @@ -2084,7 +2085,7 @@ function JSify(data) { ret += indent + 'var __label__ = ' + getLabelId(block.entry) + '; /* ' + block.entry + ' */\n'; ret += indent + 'while(1) switch(__label__) {\n'; ret += block.labels.map(function(label) { - return indent + ' case ' + getLabelId(label.ident) + ':\n' + getLabelLines(label, indent + ' '); + return indent + ' case ' + getLabelId(label.ident) + ': // ' + label.ident + '\n' + getLabelLines(label, indent + ' '); }).join('\n'); ret += '\n' + indent + '}'; } else { |