aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/intertyper.js4
-rw-r--r--src/jsifier.js6
-rw-r--r--src/postamble.js5
3 files changed, 11 insertions, 4 deletions
diff --git a/src/intertyper.js b/src/intertyper.js
index 99a7d76f..6b52d5c7 100644
--- a/src/intertyper.js
+++ b/src/intertyper.js
@@ -352,7 +352,11 @@ function intertyper(data, parseFunctions) {
if (item.tokens[3].text == 'c')
item.tokens.splice(3, 1);
+
ret.value = item.tokens[3];
+ if (ret.value.text in PARSABLE_LLVM_FUNCTIONS) {
+ ret.value = parseLLVMFunctionCall(item.tokens.slice(2));
+ }
}
return [ret];
}
diff --git a/src/jsifier.js b/src/jsifier.js
index bac2038d..4c02cf26 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -147,7 +147,9 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) {
// Gets an entire constant expression
function parseConst(value, type) {
//dprint('gconst', '//yyyyy ' + JSON.stringify(value) + ',' + type + '\n');
- if (Runtime.isNumberType(type) || pointingLevels(type) >= 1) {
+ if (value.intertype) {
+ return makePointer(finalizeLLVMFunctionCall(value), null, 'ALLOC_STATIC', type);
+ } else if (Runtime.isNumberType(type) || pointingLevels(type) >= 1) {
return makePointer(indexizeFunctions(parseNumerical(toNiceIdent(value.text))), null, 'ALLOC_STATIC', type);
} else if (value.text == 'zeroinitializer') {
return makePointer(JSON.stringify(makeEmptyStruct(type)), null, 'ALLOC_STATIC', type);
@@ -222,7 +224,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) {
item.JS = 'var ' + item.ident + ';';
return [item, {
intertype: 'GlobalVariable',
- JS: 'globalFuncs.push(function() { ' + item.ident + ' = ' + parseConst(item.value, item.type) + ' });',
+ JS: 'globalFuncs.push(function() { return ' + item.ident + ' = ' + parseConst(item.value, item.type) + ' });',
__result__: true,
}];
}
diff --git a/src/postamble.js b/src/postamble.js
index 066b83e3..010e6e66 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -13,13 +13,14 @@ function run(args) {
counter--;
var func = globalFuncs.pop();
try {
- func();
+ var x = func();
+ if (x == undefined) throw 'undefined';
} catch (e) {
globalFuncs.unshift(func);
// We will try again later. The global vars we depend on should be resolved by then
- // XXX: We leak here, as we malloc, then fail and catch...
}
}
+ assert(counter > 0);
var argc = args.length+1;
function pad() {