aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-11-25 21:19:53 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-11-25 21:19:53 -0800
commit06b58cbbe006f77471ca08e88e08c019641750be (patch)
tree3c4cf7a3fb91265e54c0eb3b3e2cf2802a96ee9a /src/jsifier.js
parentebe8a3a0c9662271ccdde5c05bd59a5e98964574 (diff)
fix for passing structs by value, and warning for unfixable case of passing structs by value between C and C++ calling conventions
Diffstat (limited to 'src/jsifier.js')
-rw-r--r--src/jsifier.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 92668595..67221c97 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -449,6 +449,16 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
func.JS += ' ' + RuntimeGenerator.stackEnter(func.initialStack) + ';\n';
+ // Make copies of by-value params
+ func.params.forEach(function(param) {
+ if (param.byVal) {
+ var type = removePointing(param.type);
+ var typeInfo = Types.types[type];
+ func.JS += ' var tempParam = ' + param.ident + '; ' + param.ident + ' = ' + RuntimeGenerator.stackAlloc(typeInfo.flatSize) + ';' +
+ makeCopyValues(param.ident, 'tempParam', typeInfo.flatSize, 'null') + ';\n';
+ }
+ });
+
if (LABEL_DEBUG) func.JS += " print(INDENT + ' Entering: " + func.ident + "'); INDENT += ' ';\n";
if (true) { // TODO: optimize away when not needed