aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/intertyper.js16
-rw-r--r--src/jsifier.js16
-rw-r--r--src/parseTools.js13
3 files changed, 31 insertions, 14 deletions
diff --git a/src/intertyper.js b/src/intertyper.js
index 22a953f1..75d8bce8 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -490,18 +490,18 @@ function intertyper(data) {
substrate.addZyme('Store', {
processItem: function(item) {
if (item.tokens[0].text == 'volatile') item.tokens.shift(0);
- var commaIndex = 3;
- while (item.tokens[commaIndex].text != ',') commaIndex ++;
- return [{
+ var segments = splitTokenList(item.tokens.slice(1));
+ var ret = {
__result__: true,
intertype: 'store',
valueType: item.tokens[1],
- value: commaIndex == 3 ? addIdent(item.tokens[2]) : parseLLVMFunctionCall(item.tokens.slice(1, commaIndex)),
- pointerType: item.tokens[commaIndex+1],
- pointer: item.tokens[commaIndex+2],
- ident: item.tokens[commaIndex+2].text,
+ value: parseLLVMSegment(segments[0]), // TODO: Make everything use this method, with finalizeLLVMParameter too
+ pointer: parseLLVMSegment(segments[1]),
lineNum: item.lineNum,
- }];
+ };
+ ret.ident = ret.pointer.ident;
+ ret.pointerType = { text: ret.pointer.type }; // TODO: unobject this
+ return [ret];
},
});
// 'br'
diff --git a/src/jsifier.js b/src/jsifier.js
index 3fd6506a..7df0ba86 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -384,14 +384,9 @@ function JSify(data) {
});
}
makeFuncLineZyme('store', function(item) {
- //print('// zzqqzz ' + dump(item.value) + ' :::: ' + dump(item.pointer) + ' :::: ');
var ident = toNiceIdent(item.ident);
var value;
- if (item.value.intertype in PARSABLE_LLVM_FUNCTIONS) {
- value = finalizeLLVMFunctionCall(item.value);
- } else {
- value = toNiceIdent(item.value.ident);
- }
+ value = finalizeLLVMParameter(item.value);
if (pointingLevels(item.pointerType.text) == 1) {
value = parseNumerical(value, removePointing(item.pointerType.text));
}
@@ -639,6 +634,15 @@ function JSify(data) {
}
}
+ // From parseLLVMSegment
+ function finalizeLLVMParameter(param) {
+ if (param.intertype in PARSABLE_LLVM_FUNCTIONS) {
+ return finalizeLLVMFunctionCall(param);
+ } else {
+ return parseNumerical(param.ident);
+ }
+ }
+
makeFuncLineZyme('bitcast', function(item) {
// XXX Don't we need to copy ptr - i.e. create new ones (at least if uses > just the next line)?
// XXX hardcoded ptr impl - as ptrs are ints, we don't need to copy
diff --git a/src/parseTools.js b/src/parseTools.js
index d27ef071..e7796b12 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -265,6 +265,19 @@ function parseParamTokens(params) {
return ret;
}
+// Segment ==> Parameter
+function parseLLVMSegment(segment) {
+ if (segment[1].text in PARSABLE_LLVM_FUNCTIONS) {
+ return parseLLVMFunctionCall(segment);
+ } else {
+ return {
+ intertype: 'value',
+ ident: segment[1].text,
+ type: segment[0].text,
+ };
+ }
+}
+
function cleanSegment(segment) {
if (segment.length == 1) return segment;
while (['noalias', 'sret', 'nocapture', 'nest', 'zeroext', 'signext'].indexOf(segment[1].text) != -1) {