aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-12-13 16:03:40 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-13 16:03:40 -0800
commit595191902fc7ac0d64b1a65182189873f7b47dfe (patch)
treee2f437e99b1df72712e0dee6114ada5077a6b463 /src/jsifier.js
parent0cef1b4432d180e747c88a75680d9ece78bcc50a (diff)
treat externals as globals in asm
Diffstat (limited to 'src/jsifier.js')
-rw-r--r--src/jsifier.js14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 7568c088..9c3109ad 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -277,7 +277,7 @@ function JSify(data, functionsOnly, givenFunctions) {
item.JS = makeGlobalDef(item.ident);
}
- if (item.external) {
+ if (item.external && !ASM_JS) { // ASM_JS considers externs to be globals
// Import external global variables from the library if available.
var shortident = item.ident.slice(1);
if (LibraryManager.library[shortident] &&
@@ -307,7 +307,17 @@ function JSify(data, functionsOnly, givenFunctions) {
index = makeGlobalUse(item.ident); // index !== null indicates we are indexing this
allocator = 'ALLOC_NONE';
}
- constant = parseConst(item.value, item.type, item.ident);
+ if (item.external) {
+ assert(ASM_JS);
+ if (Runtime.isNumberType(item.type) || isPointerType(item.type)) {
+ constant = zeros(Runtime.getNativeFieldSize(item.type));
+ } else {
+ constant = makeEmptyStruct(item.type);
+ }
+ constant = JSON.stringify(constant);
+ } else {
+ constant = parseConst(item.value, item.type, item.ident);
+ }
if (typeof constant === 'string' && constant[0] != '[') {
constant = [constant]; // A single item. We may need a postset for it.
}