diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-10-12 17:51:18 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-10-12 17:51:18 -0700 |
commit | fb7dc56a0ffa505ec8a18cfe6a99291adf02dc58 (patch) | |
tree | 410ce5ff353109ffdea88c8e852a5d539a329e54 /src/parseTools.js | |
parent | 37347e52fc6b7110783efba5fad19c195dd375ec (diff) |
handle LLVM structures in phi
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index 7d62b34d..f9ef419a 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -1074,6 +1074,10 @@ function handleOverflow(text, bits) { } } +function makeLLVMStruct(values) { // TODO: Use this everywhere + return '{ ' + values.map(function(value, i) { return 'f' + i + ': ' + value }).join(', ') + ' }' +} + // From parseLLVMSegment function finalizeLLVMParameter(param, noIndexizeFunctions) { var ret; @@ -1083,10 +1087,16 @@ function finalizeLLVMParameter(param, noIndexizeFunctions) { return toNiceIdentCarefully(param); } else if (param.intertype in PARSABLE_LLVM_FUNCTIONS) { ret = finalizeLLVMFunctionCall(param, noIndexizeFunctions); + } else if (param.ident == 'zeroinitializer') { + if (isStructType(param.type)) { + return makeLLVMStruct(zeros(Types.types[param.type].fields.length)); + } else { + return '0'; + } } else if (param.intertype == 'value') { ret = parseNumerical(param.ident); } else if (param.intertype == 'structvalue') { - ret = param.values.map(function(value) { return finalizeLLVMParameter(value, noIndexizeFunctions) }); + ret = makeLLVMStruct(param.values.map(function(value) { return finalizeLLVMParameter(value, noIndexizeFunctions) })); } else if (param.intertype === 'blockaddress') { return finalizeBlockAddress(param); } else if (param.intertype === 'type') { |