aboutsummaryrefslogtreecommitdiff
path: root/src/jsifier.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-12-03 21:22:03 -0800
committerAlon Zakai <alonzakai@gmail.com>2011-12-03 21:22:03 -0800
commit122b5bba34dd024a54b790caf5aabeec42a779d3 (patch)
tree9b2d6419684f23fc07f8944e591c78d0579f8291 /src/jsifier.js
parent556decb19a4bcb32daad1569402fcc385d49b1d4 (diff)
various minor compiler optimizations
Diffstat (limited to 'src/jsifier.js')
-rw-r--r--src/jsifier.js11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 2cb4dee9..df2ae43f 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -3,7 +3,12 @@
// Convert analyzed data to javascript. Everything has already been calculated
// before this stage, which just does the final conversion to JavaScript.
-// Main function
+// Handy sets
+
+var STRUCT_LIST = set('struct', 'list');
+var UNDERSCORE_OPENPARENS = set('_', '(');
+
+// JSifier
function JSify(data, functionsOnly, givenFunctions) {
var mainPass = !functionsOnly;
@@ -195,7 +200,7 @@ function JSify(data, functionsOnly, givenFunctions) {
ret = makeEmptyStruct(segment.type);
} else if (segment.intertype in PARSABLE_LLVM_FUNCTIONS) {
ret = finalizeLLVMFunctionCall(segment);
- } else if (segment.intertype in set('struct', 'list')) {
+ } else if (segment.intertype in STRUCT_LIST) {
ret = alignStruct(handleSegments(segment.contents), segment.type);
} else if (segment.intertype === 'string') {
ret = parseLLVMString(segment.text); // + ' /* ' + text + '*/';
@@ -237,7 +242,7 @@ function JSify(data, functionsOnly, givenFunctions) {
substrate.addActor('GlobalVariable', {
processItem: function(item) {
function needsPostSet(value) {
- return value[0] in set('_', '(') || value.substr(0, 14) === 'CHECK_OVERFLOW';
+ return value[0] in UNDERSCORE_OPENPARENS || value.substr(0, 14) === 'CHECK_OVERFLOW';
}
item.intertype = 'GlobalVariableStub';