aboutsummaryrefslogtreecommitdiff
path: root/src/modules.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules.js')
-rw-r--r--src/modules.js63
1 files changed, 48 insertions, 15 deletions
diff --git a/src/modules.js b/src/modules.js
index ba9f9482..60b4ff87 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -205,31 +205,35 @@ var Types = {
}, this);
},
- needAnalysis: {} // Types noticed during parsing, that need analysis
+ needAnalysis: {}, // Types noticed during parsing, that need analysis
+
+ preciseI64MathUsed: false // Set to true if we actually use precise i64 math: If PRECISE_I64_MATH is set, and also such math is actually
+ // needed (+,-,*,/,% - we do not need it for bitops)
};
var Functions = {
- // The list of function datas which are being processed in the jsifier, currently
- currFunctions: [],
-
// All functions that will be implemented in this file
- implementedFunctions: null,
-
- // All the function idents seen so far
- allIdents: [],
+ implementedFunctions: {},
indexedFunctions: {},
nextIndex: 2, // Start at a non-0 (even, see below) value
- // Mark a function as needing indexing, and returns the index
+ blockAddresses: {}, // maps functions to a map of block labels to label ids
+
+ // Mark a function as needing indexing. Python will coordinate them all
getIndex: function(ident) {
- var ret = this.indexedFunctions[ident];
- if (!ret) {
- ret = this.nextIndex;
- this.nextIndex += 2; // Need to have indexes be even numbers, see |polymorph| test
- this.indexedFunctions[ident] = ret;
+ if (phase != 'post') {
+ this.indexedFunctions[ident] = 0; // tell python we need this indexized
+ return '{{{ FI_' + ident + ' }}}'; // something python will replace later
+ } else {
+ var ret = this.indexedFunctions[ident];
+ if (!ret) {
+ ret = this.nextIndex;
+ this.nextIndex += 2; // Need to have indexes be even numbers, see |polymorph| test
+ this.indexedFunctions[ident] = ret;
+ }
+ return ret.toString();
}
- return ret.toString();
},
// Generate code for function indexing
@@ -296,3 +300,32 @@ function cDefine(key) {
return key in C_DEFINES ? C_DEFINES[key] : ('0 /* XXX missing C define ' + key + ' */');
}
+var PassManager = {
+ serialize: function() {
+ print('\n//FORWARDED_DATA:' + JSON.stringify({
+ Types: Types,
+ Variables: Variables,
+ Functions: Functions
+ }));
+ },
+ load: function(json) {
+ var data = JSON.parse(json);
+ for (var i in data.Types) {
+ Types[i] = data.Types[i];
+ }
+ for (var i in data.Variables) {
+ Variables[i] = data.Variables[i];
+ }
+ for (var i in data.Functions) {
+ Functions[i] = data.Functions[i];
+ }
+ /*
+ print('\n//LOADED_DATA:' + phase + ':' + JSON.stringify({
+ Types: Types,
+ Variables: Variables,
+ Functions: Functions
+ }));
+ */
+ }
+};
+