aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-09-29 12:30:52 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-10-02 17:31:36 -0700
commit435f17d4955c75e9ccef3fccd991c0da7756d7f0 (patch)
tree78eb2ec5d6b8be7ac3ca18139675c235b9b5bc07
parentc41746de750ddea1d69955fd17ee85f06c0aeed1 (diff)
chunk label init with the rest
-rw-r--r--src/jsifier.js7
-rw-r--r--src/parseTools.js15
2 files changed, 20 insertions, 2 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index c51f2854..efebab62 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -537,6 +537,7 @@ function JSify(data, functionsOnly, givenFunctions) {
default: throw 'what is this line? ' + dump(line);
}
assert(line.JS);
+ //assert(line.JS.indexOf('var ') < 0, [line.JS, line.intertype]);
if (line.assignTo) makeAssign(line);
Framework.currItem = null;
});
@@ -596,6 +597,8 @@ function JSify(data, functionsOnly, givenFunctions) {
func.JS += INDENTATION + param.ident + '=' + deParen(asmCoercion(param.ident, param.type)) + ';\n';
});
+ addVariable('label', 'i32', func);
+
// spell out local variables
var vars = values(func.variables).filter(function(v) { return v.origin != 'funcparam' });
if (vars.length > 0) {
@@ -621,8 +624,8 @@ function JSify(data, functionsOnly, givenFunctions) {
}
}
- if (true) { // TODO: optimize away when not needed
- if (CLOSURE_ANNOTATIONS) func.JS += '/** @type {number} */';
+ if (CLOSURE_ANNOTATIONS) func.JS += '/** @type {number} */';
+ if (!ASM_JS) {
func.JS += INDENTATION + 'var label=0;\n';
}
diff --git a/src/parseTools.js b/src/parseTools.js
index d749fb0a..f60c0cc1 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -2558,3 +2558,18 @@ function deParen(text) {
return text;
}
+function addVariable(ident, type, funcData) {
+ funcData = funcData || Framework.currItem.funcData;
+ funcData.variables[ident] = {
+ ident: ident,
+ type: type,
+ origin: 'added',
+ lineNum: 0,
+ rawLinesIndex: 0,
+ hasValueTaken: false,
+ pointingLevels: 0,
+ uses: 0,
+ impl: "native"
+ };
+}
+