aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
authorAlon Zakai <azakai@mozilla.com>2010-11-13 18:50:15 -0800
committerAlon Zakai <azakai@mozilla.com>2010-11-13 18:50:15 -0800
commit268226c46c7f10d303d121e228f4798ad7c630a2 (patch)
treeef7976f5a2dc2943d10a9280851bef28fdc10903 /src/jsifier.js
parent0d1ff8042b13df96ae0b67c126b7637cd46dfd5f (diff)
string constants inside struct constants +test
Diffstat (limited to 'src/jsifier.js')
-rw-r--r--src/jsifier.js10
1 files changed, 8 insertions, 2 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);
}