diff --git a/src/jsifier.js b/src/jsifier.js index f8fa0e0f7..3f41c1792 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -520,7 +520,7 @@ function JSify(data, functionsOnly, givenFunctions) { 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', null, 1) + ';\n'; + makeCopyValues(param.ident, 'tempParam', typeInfo.flatSize, 'null', null, param.byVal) + ';\n'; } }); diff --git a/src/parseTools.js b/src/parseTools.js index 3a88fc255..0601045d4 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -314,12 +314,14 @@ function parseParamTokens(params) { var segment = params.slice(0, i); params = params.slice(i+1); segment = cleanSegment(segment); - var byVal = false; + var byVal = 0; if (segment[1] && segment[1].text === 'byval') { - // handle 'byval' and 'byval align X' - byVal = true; + // handle 'byval' and 'byval align X'. We store the alignment in 'byVal' + byVal = QUANTUM_SIZE; segment.splice(1, 1); if (segment[1] && segment[1].text === 'align') { + assert(isNumber(segment[2].text)); + byVal = parseInt(segment[2].text); segment.splice(1, 2); } }