diff options
author | alon@honor <none@none> | 2010-10-01 20:58:15 -0700 |
---|---|---|
committer | alon@honor <none@none> | 2010-10-01 20:58:15 -0700 |
commit | 9a60dd64cdccc60d7a789ffa1f16536f8b106a0b (patch) | |
tree | e74085575573ccdcacc2a3b43f18c545eb265395 /src | |
parent | 73a87bedee8b225ed76c8efebe1a032d0bf91ec5 (diff) |
test+fix for modifying fields of global structures
Diffstat (limited to 'src')
-rw-r--r-- | src/analyzer.js | 3 | ||||
-rw-r--r-- | src/jsifier.js | 33 | ||||
-rw-r--r-- | src/library.js | 5 |
3 files changed, 24 insertions, 17 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 13c5c648..aa9a8031 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -682,6 +682,9 @@ function analyzer(data) { }); // Optimizer + // XXX: load, store and gep now have pointer/value/data from which we copy the ident into a toplevel ident. + // However, we later read the non-toplevel ident in some cases, so optimizer changes can lead to bugs. + // Need to remove the toplevel, work entirely with the non-toplevel. Single location. substrate.addZyme('Optimizer', { processItem: function(item) { var that = this; diff --git a/src/jsifier.js b/src/jsifier.js index 7f5a86cd..057130e8 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -384,27 +384,28 @@ function JSify(data) { }); } makeFuncLineZyme('store', function(item) { - var ident = toNiceIdent(item.ident); - var value; - value = finalizeLLVMParameter(item.value); + var value = finalizeLLVMParameter(item.value); if (pointingLevels(item.pointerType.text) == 1) { value = parseNumerical(value, removePointing(item.pointerType.text)); } - //print("// zz seek " + ident + ',' + dump(item)); - var impl = getVarData(item.funcData, item.ident); - var ret; - switch (impl) { - case VAR_NATIVIZED: ret = ident + ' = ' + value + ';'; break; // We have the actual value here - case VAR_EMULATED: ret = makeSetValue(ident, 0, value) + ';'; break; - default: print('zz unknown [store] impl: ' + impl); + var impl = VAR_EMULATED; + if (item.pointer.intertype == 'value') { + impl = getVarData(item.funcData, item.ident); } -/* - if (LINEDEBUG && value) { - ret += '\nprint(INDENT + "' + ident + ' == " + JSON.stringify(' + ident + '));'; - ret += '\nprint(INDENT + "' + ident + ' == " + (' + ident + ' && ' + ident + '.toString ? ' + ident + '.toString() : ' + ident + '));'; + switch (impl) { + case VAR_NATIVIZED: + return item.ident + ' = ' + value + ';'; // We have the actual value here + break; + case VAR_EMULATED: + if (item.pointer.intertype == 'value') { + return makeSetValue(item.ident, 0, value) + ';'; + } else { + return makeSetValue(0, getGetElementPtrIndexes(item.pointer), value) + ';'; + } + break; + default: + throw 'unknown [store] impl: ' + impl; } -*/ - return ret; }); var LABEL_IDs = {}; diff --git a/src/library.js b/src/library.js index a6fbcf02..72d7f599 100644 --- a/src/library.js +++ b/src/library.js @@ -139,7 +139,7 @@ var Library = { }, llvm_eh_exception: function() { - return Error(); + return 'code-generated exception'; }, llvm_eh_selector: function(exception, personality, num) { @@ -149,6 +149,9 @@ var Library = { throw exception; }, + __gxx_personality_v0: function() { + }, + // iostream _ZNSt8ios_base4InitC1Ev: function() { |