diff options
author | Alon Zakai <azakai@mozilla.com> | 2010-11-13 18:50:15 -0800 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2010-11-13 18:50:15 -0800 |
commit | 268226c46c7f10d303d121e228f4798ad7c630a2 (patch) | |
tree | ef7976f5a2dc2943d10a9280851bef28fdc10903 | |
parent | 0d1ff8042b13df96ae0b67c126b7637cd46dfd5f (diff) |
string constants inside struct constants +test
-rw-r--r-- | src/jsifier.js | 10 | ||||
-rw-r--r-- | tests/runner.py | 14 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 277aed42..ab4df579 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -136,7 +136,7 @@ function JSify(data) { // Gets an entire constant expression function parseConst(value, type) { - dprint('gconst', '//yyyyy ' + JSON.stringify(value) + ',' + type + '\n'); + //dprint('gconst', '//yyyyy ' + JSON.stringify(value) + ',' + type + '\n'); if (Runtime.isNumberType(type) || pointingLevels(type) == 1) { return makePointer(indexizeFunctions(parseNumerical(toNiceIdent(value.text))), null, 'ALLOC_STATIC', type); } else if (value.text == 'zeroinitializer') { @@ -147,9 +147,10 @@ function JSify(data) { } else { // Gets an array of constant items, separated by ',' tokens function handleSegments(tokens) { + //dprint('gconst', '// segggS: ' + JSON.stringify(tokens) + '\n' + '\n') // Handle a single segment (after comma separation) function handleSegment(segment) { - dprint('gconst', '// seggg: ' + JSON.stringify(segment) + '\n' + '\n') + //dprint('gconst', '// seggg: ' + JSON.stringify(segment) + '\n' + '\n') if (segment[1].text == 'null') { return '0'; } else if (segment[1].text == 'zeroinitializer') { @@ -171,6 +172,11 @@ function JSify(data) { return '[' + alignStruct(handleSegments(segment[1].item.tokens), type).join(', ') + ']'; } else if (segment.length == 2) { return parseNumerical(toNiceIdent(segment[1].text)); + } else if (segment[1].text === 'c') { + // string + var text = segment[2].text; + text = text.substr(1, text.length-2); + return JSON.stringify(parseLLVMString(text)) + ' /* ' + text + '*/'; } else { throw 'Invalid segment: ' + dump(segment); } diff --git a/tests/runner.py b/tests/runner.py index 9c0db5f2..ecabe9eb 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -596,12 +596,22 @@ if 'benchmark' not in sys.argv: { 't', 0.27, 2 }, }; + const unsigned char faceedgesidx[6][4] = + { + { 4, 5, 8, 10 }, + { 6, 7, 9, 11 }, + { 0, 2, 8, 9 }, + { 1, 3, 10,11 }, + { 0, 1, 4, 6 }, + { 2, 3, 5, 7 }, + }; + int main( int argc, const char *argv[] ) { - printf("*%d,%d,%d*\\n", iub[0].c, int(iub[1].p*100), iub[2].pi); + printf("*%d,%d,%d,%d*\\n", iub[0].c, int(iub[1].p*100), iub[2].pi, faceedgesidx[3][2]); return 0; } ''' - self.do_test(src, '*97,15,3*') + self.do_test(src, '*97,15,3,10*') def test_conststructs(self): src = ''' |