diff options
-rw-r--r-- | src/analyzer.js | 42 | ||||
-rw-r--r-- | src/compiler.js | 4 | ||||
-rw-r--r-- | src/enzymatic.js | 4 | ||||
-rw-r--r-- | src/experimental/enzymatic2.js | 160 | ||||
-rw-r--r-- | src/intertyper.js | 96 | ||||
-rw-r--r-- | src/jsifier.js | 32 | ||||
-rw-r--r-- | src/library.js | 2 | ||||
-rw-r--r-- | src/library_sdl.js | 4 | ||||
-rw-r--r-- | src/parseTools.js | 20 | ||||
-rw-r--r-- | src/runtime.js | 2 | ||||
-rw-r--r-- | src/utility.js | 2 |
11 files changed, 104 insertions, 264 deletions
diff --git a/src/analyzer.js b/src/analyzer.js index 6dd781c2..3924b4aa 100644 --- a/src/analyzer.js +++ b/src/analyzer.js @@ -19,7 +19,7 @@ function analyzer(data, givenTypes) { processItem: function(item) { item.items.sort(function (a, b) { return a.lineNum - b.lineNum }); this.forwardItem(item, 'Gatherer'); - }, + } }); // Gatherer @@ -36,7 +36,7 @@ function analyzer(data, givenTypes) { item.items = temp.leftIn; }); // Functions & labels - item.functions = [] + item.functions = []; for (var i = 0; i < item.items.length; i++) { var subItem = item.items[i]; if (subItem.intertype == 'function') { @@ -50,7 +50,7 @@ function analyzer(data, givenTypes) { item.items.splice(i+1, 0, { intertype: 'label', ident: '%entry', - lineNum: subItem.lineNum + '.5', + lineNum: subItem.lineNum + '.5' }); } } else if (subItem.intertype == 'functionEnd') { @@ -68,7 +68,7 @@ function analyzer(data, givenTypes) { } delete item.items; this.forwardItem(item, 'Identinicer'); - }, + } }); // IdentiNicer @@ -106,7 +106,7 @@ function analyzer(data, givenTypes) { data.types[nonPointing] = { name_: nonPointing, fields: range(num).map(function() { return subType }), - lineNum: '?', + lineNum: '?' }; // Also add a |[0 x type]| type var zerod = '[0 x ' + subType + ']'; @@ -114,7 +114,7 @@ function analyzer(data, givenTypes) { data.types[zerod] = { name_: zerod, fields: [subType, subType], // Two, so we get the flatFactor right. We care about the flatFactor, not the size here - lineNum: '?', + lineNum: '?' }; } return; @@ -126,7 +126,7 @@ function analyzer(data, givenTypes) { name_: type, fields: [ 'i32' ], // XXX flatSize: 1, - lineNum: '?', + lineNum: '?' }; } @@ -211,7 +211,7 @@ function analyzer(data, givenTypes) { } this.forwardItem(item, 'VariableAnalyzer'); - }, + } }); // Variable analyzer @@ -233,7 +233,7 @@ function analyzer(data, givenTypes) { type: param.type, origin: 'funcparam', lineNum: func.lineNum, - uses: null, + uses: null }; } }); @@ -246,7 +246,7 @@ function analyzer(data, givenTypes) { type: item.value.type, origin: item.value.intertype, // XXX should say something in the case of fastgetelementptrload lineNum: item.lineNum, - uses: parseInt(item.value.tokens.slice(-1)[0].item.tokens[0].text.split('=')[1]), + uses: parseInt(item.value.tokens.slice(-1)[0].item.tokens[0].text.split('=')[1]) }; } }); @@ -312,7 +312,7 @@ function analyzer(data, givenTypes) { } }); this.forwardItem(item, 'LabelAnalyzer'); - }, + } }); // Label analyzer @@ -345,7 +345,7 @@ function analyzer(data, givenTypes) { }); }); this.forwardItem(item, 'StackAnalyzer'); - }, + } }); // Stack analyzer - calculate the base stack usage @@ -374,7 +374,7 @@ function analyzer(data, givenTypes) { } }); this.forwardItem(data, 'Relooper'); - }, + } }); var BRANCH_INVOKE = searchable('branch', 'invoke'); @@ -564,7 +564,7 @@ function analyzer(data, givenTypes) { type: 'emulated', id: blockId, labels: labels, - entries: entries.slice(0), + entries: entries.slice(0) }; if (!RELOOP) return emulated; @@ -612,7 +612,7 @@ function analyzer(data, givenTypes) { id: blockId, labels: [entryLabel], entries: entries, - next: makeBlock(others, keys(entryLabel.outLabels), labelsDict), + next: makeBlock(others, keys(entryLabel.outLabels), labelsDict) }; } @@ -623,12 +623,12 @@ function analyzer(data, givenTypes) { type: 'reloop', id: blockId, entries: entries, - labels: labels, + labels: labels }; // Find internal and external labels var split_ = splitter(labels, function(label) { - return !(label.ident in s_entries) && values(setIntersect(s_entries, label.allOutLabels)).length == 0 + return !(label.ident in s_entries) && values(setIntersect(s_entries, label.allOutLabels)).length == 0; }); var externals = split_.splitOut; var internals = split_.leftIn; @@ -752,7 +752,7 @@ function analyzer(data, givenTypes) { entries: actualEntries, entryLabels: actualEntryLabels, labels: handlingNow, - next: makeBlock(labels.filter(function(label) { return handlingNow.indexOf(label) == -1 }), keys(postEntryLabels), labelsDict), + next: makeBlock(labels.filter(function(label) { return handlingNow.indexOf(label) == -1 }), keys(postEntryLabels), labelsDict) }; } @@ -763,7 +763,7 @@ function analyzer(data, givenTypes) { }); return finish(); - }, + } }); // LoopOptimizer. The Relooper generates native loop structures, that are @@ -862,11 +862,11 @@ function analyzer(data, givenTypes) { optimizeBlock(func.block); }); return finish(); - }, + } }); substrate.addItem({ - items: data, + items: data }, 'Sorter'); return substrate.solve(); diff --git a/src/compiler.js b/src/compiler.js index 395c7acd..3a21de33 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -2,10 +2,10 @@ // Prep - allow this to run in both SpiderMonkey and V8 if (!this['load']) { - load = function(f) { eval(snarf(f)) } + load = function(f) { eval(snarf(f)) }; } if (!this['read']) { - read = function(f) { snarf(f) } + read = function(f) { snarf(f) }; } load('settings.js'); diff --git a/src/enzymatic.js b/src/enzymatic.js index b0fd4619..8b936a23 100644 --- a/src/enzymatic.js +++ b/src/enzymatic.js @@ -128,7 +128,7 @@ Substrate.prototype = { } midComment(); } - }, + } }; Zyme = function() { }; @@ -160,6 +160,6 @@ Zyme.prototype = { } } return ret; - }, + } }; diff --git a/src/experimental/enzymatic2.js b/src/experimental/enzymatic2.js deleted file mode 100644 index fb929d25..00000000 --- a/src/experimental/enzymatic2.js +++ /dev/null @@ -1,160 +0,0 @@ -/** - * A 2nd implementation of an 'enzymatic programming' paradigm. - */ - -Zyme2 = function(reqs, func) { - //! List of items that we want. Each element in this list is - //! a list of features, we want elements that have them all. - //! We will only call this Zyme if we find *all* of the items - //! it wants. - this.reqs = reqs; - this.process = func; -}; - -Substrate2 = function(name_) { - this.name_ = name_; - this.elems = {}; - this.currUid = 1; -}; - -Substrate2.prototype = { - _addElement: function(elem) { - elem.__uid__ = this.currUid; - this.elems[elem.__uid__] = elem; - this.currUid ++; - }, - - _removeElement: function(elem) { - assertTrue(!!this.elems[elem.__uid__]); - this.elems[elem.__uid__] = null; - delete elem.__uid__; - }, - - _getElement: function(uid) { return this.elems[uid]; }, - - getItems: function() { - return values(this.elems).filter(function(elem) { return elem.isItem }); - }, - - getZymes: function() { - return values(this.elems).filter(function(elem) { return elem.isZyme }); - }, - - addItem: function(item) { - this._addElement(item); - item.isItem = true; - - this.getZymes().forEach(function(zyme) { this.noticeItem(zyme, item) }); - }, - - addZyme: function(zyme) { - this._addElement(zyme); - zyme.isZyme = true; - zyme.potentials = zyme.reqs.map(function() { return [] }); // for each required item, a list of matching items - - this.getItems().forEach(function(item) { this.noticeItem(zyme, item); }); - }, - - removeItem: function(item) { - this.getZymes().forEach(function(zyme) { this.forgetItem(zyme, item) }); - - this._removeElement(item); - delete item.__result__; - delete item.__finalResult__; - }, - - removeZyme: function(zyme) { - this._removeElement(zyme); - }, - - _getFits: function(zyme, item) { - return fits = zyme.reqs.map(function(req) { - return req.filter(function(feat) { return !item[feat] }).length == 0; - }); - }, - - noticeItem: function(zyme, item) { - loopOn(this._getFits(zyme, item), function(i, fit) { - if (fit) { - zyme.potentials[i].push(item); - } - }); - }, - - forgetItem: function(zyme, item) { - loopOn(this._getFits(zyme, item), function(i, fit) { - if (fit) { - zyme.potentials = zyme.potentials.filter(function(item2) { return item2 !== item }); - } - }); - }, - - processAction: function(zyme, items) { - items.forEach(this.removeItem, this); - var splat = splitter(items.length > 1 ? zyme.process(items) : zyme.process(items[0]), function(item) { - return item.__result__ || item.__finalResult__; - }); - splat.leftIn.forEach(this.addItem, this); - return splat.splitOut; - }, - - solve: function() { - print("// Solving " + this.name_ + "..."); - - var startTime = Date.now(); - var midTime = startTime; - var that = this; - function midComment() { - var curr = Date.now(); - if (curr - midTime > 1000) { - print('// Working on ' + that.name_ + ', so far ' + ((curr-startTime)/1000).toString().substr(0,10) + ' seconds. Have ' + that.items.length + ' items.'); - midTime = curr; - } - } - function finalComment() { - print('// Completed ' + that.name_ + ' in ' + ((Date.now() - startTime)/1000).toString().substr(0,10) + ' seconds.'); - } - - var results = []; - var done = false; - while (!done) { - var hadProcessing = false; - this.getZymes().forEach(function(zyme) { - while (!done) { - midComment(); - var selected = zyme.potentials.map(function(potential) { return potential[0] }); - if (sumTruthy(selected) == zyme.reqs.length) { - var outputs = this.processAction(zyme, selected); - hadProcessing = true; - if (outputs.length === 1 && outputs[0].__finalResult__) { - results = outputs; - done = true; - } else { - results = results.concat(outputs); - } - } else { - break; - } - } - }, this); - if (this.items.length === 0) { - finalComment(); - done = true; - } - if (!hadProcessing) { - print("Reached a dead end."); - this.getItems().forEach(function(item) { - print("remaining item:" + dump(item)); - }); - throw "failure"; - } - midComment(); - } - if (results[0].__finalResult__) { - return results[0]; - } else { - return results; - } - }, -}; - diff --git a/src/intertyper.js b/src/intertyper.js index b4c009f5..7f4ae864 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -5,7 +5,7 @@ var LLVM_STYLE = null; var LLVM = { LINKAGES: set('private', 'linker_private', 'linker_private_weak', 'linker_private_weak_def_auto', 'internal', 'available_externally', 'linkonce', 'common', 'weak', 'appending', 'extern_weak', 'linkonce_odr', - 'weak_odr', 'externally_visible', 'dllimport', 'dllexport'), + 'weak_odr', 'externally_visible', 'dllimport', 'dllexport') }; //! @param parseFunctions We parse functions only on later passes, since we do not @@ -52,7 +52,7 @@ function intertyper(data, parseFunctions, baseLineNum) { } else { ret.push({ lineText: line, - lineNum: i + 1 + baseLineNum, + lineNum: i + 1 + baseLineNum }); if (new RegExp(/^\ +switch\ .*/g).test(line)) { // beginning of llvm switch @@ -74,7 +74,7 @@ function intertyper(data, parseFunctions, baseLineNum) { params: func.params, hasVarArgs: func.hasVarArgs, lineNum: currFunctionLineNum, - lines: currFunctionLines, + lines: currFunctionLines }); currFunctionLines = []; } @@ -82,14 +82,14 @@ function intertyper(data, parseFunctions, baseLineNum) { } this.forwardItems(ret.filter(function(item) { return item.lineText; }), 'Tokenizer'); return unparsedFunctions; - }, + } }); var ENCLOSER_STARTERS = set('[', '(', '<'); var ENCLOSER_ENDERS = { '[': ']', '(': ')', - '<': '>', + '<': '>' }; // Line tokenizer @@ -108,7 +108,7 @@ function intertyper(data, parseFunctions, baseLineNum) { '(': 0, ')': '(', '<': 0, - '>': '<', + '>': '<' }; var totalEnclosing = 0; var that = this; @@ -122,7 +122,7 @@ function intertyper(data, parseFunctions, baseLineNum) { } var token = { - text: text, + text: text }; if (text[0] in enclosers) { token.item = that.processItem({ @@ -225,14 +225,14 @@ function intertyper(data, parseFunctions, baseLineNum) { var item = { tokens: tokens, indent: lineText.search(/[^ ]/), - lineNum: item.lineNum, + lineNum: item.lineNum }; if (inner) { return item; } else { this.forwardItem(item, 'Triager'); } - }, + } }); MATHOPS = set(['add', 'sub', 'sdiv', 'udiv', 'mul', 'icmp', 'zext', 'urem', 'srem', 'fadd', 'fsub', 'fmul', 'fdiv', 'fcmp', 'uitofp', 'sitofp', 'fpext', 'fptrunc', 'fptoui', 'fptosi', 'trunc', 'sext', 'select', 'shl', 'shr', 'ashl', 'ashr', 'lshr', 'lshl', 'xor', 'or', 'and', 'ptrtoint', 'inttoptr']); @@ -303,7 +303,7 @@ function intertyper(data, parseFunctions, baseLineNum) { throw 'Invalid token, cannot triage: ' + dump(item); } this.forwardItem(item, triage(item)); - }, + } }); // Line parsers to intermediate form @@ -337,8 +337,8 @@ function intertyper(data, parseFunctions, baseLineNum) { intertype: 'type', name_: item.tokens[0].text, fields: fields, - lineNum: item.lineNum, - }] + lineNum: item.lineNum + }]; } else { // variable var ident = item.tokens[0].text; @@ -355,7 +355,7 @@ function intertyper(data, parseFunctions, baseLineNum) { ident: ident, type: item.tokens[2].text, external: external, - lineNum: item.lineNum, + lineNum: item.lineNum }; if (ident == '@llvm.global_ctors') { ret.ctors = []; @@ -380,7 +380,7 @@ function intertyper(data, parseFunctions, baseLineNum) { } return [ret]; } - }, + } }); // function header funcHeader = substrate.addZyme('FuncHeader', { @@ -394,7 +394,7 @@ function intertyper(data, parseFunctions, baseLineNum) { ident: item.tokens[1].text, returnType: item.tokens[0], params: parseParamTokens(item.tokens[2].item.tokens), - lineNum: item.lineNum, + lineNum: item.lineNum }; ret.hasVarArgs = false; ret.paramIdents = ret.params.map(function(param) { @@ -405,7 +405,7 @@ function intertyper(data, parseFunctions, baseLineNum) { return toNiceIdent(param.ident); }).filter(function(param) { return param != null });; return [ret]; - }, + } }); // label substrate.addZyme('Label', { @@ -416,9 +416,9 @@ function intertyper(data, parseFunctions, baseLineNum) { ident: item.tokens[0].text.substr(-1) == ':' ? '%' + item.tokens[0].text.substr(0, item.tokens[0].text.length-1) : '%' + item.tokens[2].text.substr(1), - lineNum: item.lineNum, + lineNum: item.lineNum }]; - }, + } }); // assignment @@ -428,14 +428,14 @@ function intertyper(data, parseFunctions, baseLineNum) { var pair = splitItem({ intertype: 'assign', ident: combineTokens(item.tokens.slice(0, opIndex)).text, - lineNum: item.lineNum, + lineNum: item.lineNum }, 'value'); this.forwardItem(pair.parent, 'Reintegrator'); this.forwardItem(mergeInto(pair.child, { // Additional token, to be triaged and later re-integrated indent: -1, - tokens: item.tokens.slice(opIndex+1), + tokens: item.tokens.slice(opIndex+1) }), 'Triager'); - }, + } }); substrate.addZyme('Reintegrator', makeReintegrator(function(parent, child) { @@ -471,7 +471,7 @@ function intertyper(data, parseFunctions, baseLineNum) { } item.ident = item.pointer; this.forwardItem(item, 'Reintegrator'); - }, + } }); // 'extractvalue' substrate.addZyme('ExtractValue', { @@ -482,7 +482,7 @@ function intertyper(data, parseFunctions, baseLineNum) { item.ident = item.tokens[2].text; item.indexes = splitTokenList(item.tokens.slice(4, last)); this.forwardItem(item, 'Reintegrator'); - }, + } }); // 'bitcast' substrate.addZyme('Bitcast', { @@ -492,7 +492,7 @@ function intertyper(data, parseFunctions, baseLineNum) { item.ident = item.tokens[2].text; item.type2 = item.tokens[4].text; this.forwardItem(item, 'Reintegrator'); - }, + } }); // 'getelementptr' substrate.addZyme('GEP', { @@ -509,7 +509,7 @@ function intertyper(data, parseFunctions, baseLineNum) { item.params = data.params; item.ident = data.ident; this.forwardItem(item, 'Reintegrator'); - }, + } }); // 'call' substrate.addZyme('Call', { @@ -548,7 +548,7 @@ function intertyper(data, parseFunctions, baseLineNum) { return [item]; } this.forwardItem(item, 'Reintegrator'); - }, + } }); // 'invoke' substrate.addZyme('Invoke', { @@ -573,7 +573,7 @@ function intertyper(data, parseFunctions, baseLineNum) { return [item]; } this.forwardItem(item, 'Reintegrator'); - }, + } }); // 'alloca' @@ -585,7 +585,7 @@ function intertyper(data, parseFunctions, baseLineNum) { item.type = addPointing(item.tokens[1].text); // type of pointer we will get item.type2 = item.tokens[1].text; // value we will create, and get a pointer to this.forwardItem(item, 'Reintegrator'); - }, + } }); // 'phi' substrate.addZyme('Phi', { @@ -597,11 +597,11 @@ function intertyper(data, parseFunctions, baseLineNum) { var subSegments = splitTokenList(segment[0].item.tokens); return { label: toNiceIdent(subSegments[1][0].text), - value: parseLLVMSegment(subSegments[0]), + value: parseLLVMSegment(subSegments[0]) }; }); this.forwardItem(item, 'Reintegrator'); - }, + } }); // mathops substrate.addZyme('Mathops', { @@ -630,7 +630,7 @@ function intertyper(data, parseFunctions, baseLineNum) { item.type = item.param1.type; } this.forwardItem(item, 'Reintegrator'); - }, + } }); // 'store' substrate.addZyme('Store', { @@ -643,12 +643,12 @@ function intertyper(data, parseFunctions, baseLineNum) { valueType: item.tokens[1].text, value: parseLLVMSegment(segments[0]), // TODO: Make everything use this method, with finalizeLLVMParameter too pointer: parseLLVMSegment(segments[1]), - lineNum: item.lineNum, + lineNum: item.lineNum }; ret.ident = ret.pointer.ident; ret.pointerType = ret.pointer.type; return [ret]; - }, + } }); // 'br' substrate.addZyme('Branch', { @@ -658,7 +658,7 @@ function intertyper(data, parseFunctions, baseLineNum) { __result__: true, intertype: 'branch', label: toNiceIdent(item.tokens[2].text), - lineNum: item.lineNum, + lineNum: item.lineNum }]; } else { return [{ @@ -667,10 +667,10 @@ function intertyper(data, parseFunctions, baseLineNum) { ident: item.tokens[2].text, labelTrue: toNiceIdent(item.tokens[5].text), labelFalse: toNiceIdent(item.tokens[8].text), - lineNum: item.lineNum, + lineNum: item.lineNum }]; } - }, + } }); // 'ret' substrate.addZyme('Return', { @@ -680,9 +680,9 @@ function intertyper(data, parseFunctions, baseLineNum) { intertype: 'return', type: item.tokens[1].text, value: item.tokens[2] ? parseLLVMSegment(item.tokens.slice(2)) : null, - lineNum: item.lineNum, + lineNum: item.lineNum }]; - }, + } }); // 'switch' substrate.addZyme('Switch', { @@ -693,7 +693,7 @@ function intertyper(data, parseFunctions, baseLineNum) { while (tokens.length > 0) { ret.push({ value: tokens[1].text, - label: toNiceIdent(tokens[4].text), + label: toNiceIdent(tokens[4].text) }); tokens = tokens.slice(5); } @@ -706,9 +706,9 @@ function intertyper(data, parseFunctions, baseLineNum) { ident: item.tokens[2].text, defaultLabel: toNiceIdent(item.tokens[5].text), switchLabels: parseSwitchLabels(item.tokens[6]), - lineNum: item.lineNum, + lineNum: item.lineNum }]; - }, + } }); // function end substrate.addZyme('FuncEnd', { @@ -716,9 +716,9 @@ function intertyper(data, parseFunctions, baseLineNum) { return [{ __result__: true, intertype: 'functionEnd', - lineNum: item.lineNum, + lineNum: item.lineNum }]; - }, + } }); // external function stub substrate.addZyme('External', { @@ -732,9 +732,9 @@ function intertyper(data, parseFunctions, baseLineNum) { ident: item.tokens[2].text, returnType: item.tokens[1], params: item.tokens[3], - lineNum: item.lineNum, + lineNum: item.lineNum }]; - }, + } }); // 'unreachable' substrate.addZyme('Unreachable', { @@ -742,15 +742,15 @@ function intertyper(data, parseFunctions, baseLineNum) { return [{ __result__: true, intertype: 'unreachable', - lineNum: item.lineNum, + lineNum: item.lineNum }]; - }, + } }); // Input substrate.addItem({ - llvmLines: data, + llvmLines: data }, 'LineSplitter'); return substrate.solve(); diff --git a/src/jsifier.js b/src/jsifier.js index 17fe4fd3..3c758bff 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -12,7 +12,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { // XXX Save just what we need, to save memory - whether there are varargs, and the # of parameters FUNCTIONS[func.ident] = { hasVarArgs: func.hasVarArgs, - numParams: func.params.length, + numParams: func.params.length }; }); @@ -27,7 +27,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { substrate.addZyme('Type', { processItem: function(item) { var type = TYPES[item.name_]; - var niceName = toNiceIdent(item.name_) + var niceName = toNiceIdent(item.name_); // We might export all of TYPES, cleaner that way, but do not want slowdowns in accessing flatteners item.JS = 'var ' + niceName + '___SIZE = ' + TYPES[item.name_].flatSize + '; // ' + item.name_ + '\n'; if (type.needsFlattening && !type.flatFactor) { @@ -35,7 +35,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { } item.__result__ = true; return [item]; - }, + } }); function makePointer(slab, pos, allocator, type) { // type is FFU @@ -248,7 +248,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { ret.push({ intertype: 'GlobalVariablePostSet', JS: 'IHEAP[' + item.ident + '+' + i + '] = ' + value + ';', - __result__: true, + __result__: true }); constant[i] = '0'; } @@ -259,10 +259,10 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { return ret.concat({ intertype: 'GlobalVariable', JS: item.ident + ' = ' + constant + ';', - __result__: true, + __result__: true }); } - }, + } }); // functionStub @@ -282,7 +282,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { } item.__result__ = true; return [item]; - }, + } }); // function splitter @@ -301,7 +301,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { }); this.forwardItems(ret, 'FuncLineTriager'); - }, + } }); // function reconstructor & post-JS optimizer @@ -439,7 +439,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { func.JS += func.ident + '.__index__ = Runtime.getFunctionIndex(' + func.ident + ', "' + func.ident + '");\n'; func.__result__ = true; return func; - }, + } }); function getVarData(funcData, ident) { // XXX - need to check globals as well! @@ -468,7 +468,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { } else { this.forwardItem(item, 'Intertype:' + item.intertype); } - }, + } }); // assignment @@ -477,7 +477,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { var pair = splitItem(item, 'value', ['funcData']); this.forwardItem(pair.parent, 'AssignReintegrator'); this.forwardItem(pair.child, 'FuncLineTriager'); - }, + } }); substrate.addZyme('AssignReintegrator', makeReintegrator(function(item, child) { // 'var', since this is SSA - first assignment is the only assignment, and where it is defined @@ -515,7 +515,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { item.JS = func(item); if (!item.JS) throw "XXX - no JS generated for " + dump(item); this.forwardItem(item, 'FuncLineTriager'); - }, + } }); } makeFuncLineZyme('store', function(item) { @@ -730,7 +730,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { case 'ult': case 'slt': return ident1 + ' < ' + ident2; case 'ne': case 'une': return ident1 + ' != ' + ident2; case 'eq': return ident1 + ' == ' + ident2; - default: throw 'Unknown icmp variant: ' + variant + default: throw 'Unknown icmp variant: ' + variant; } } case 'fcmp': { @@ -746,7 +746,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { case 'ord': return '!isNaN(' + ident1 + ') && !isNaN(' + ident2 + ')'; case 'uno': return 'isNaN(' + ident1 + ') || isNaN(' + ident2 + ')'; case 'true': return '1'; - default: throw 'Unknown fcmp variant: ' + variant + default: throw 'Unknown fcmp variant: ' + variant; } } case 'zext': case 'fpext': case 'sext': case 'fptrunc': return ident1; @@ -767,7 +767,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { //print('// XXX Warning: inttoptr operation on line ' + lineNum); return ident1; } - default: throw 'Unknown mathcmp op: ' + item.op + default: throw 'Unknown mathcmp op: ' + item.op; } } }); /* @@ -909,7 +909,7 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions) { return 'IHEAP[' + params[0].ident + '] = ' + data; } } else if (ident == '_llvm_va_end') { - return ';' + return ';'; } var func = FUNCTIONS[ident]; diff --git a/src/library.js b/src/library.js index 78af28cd..166806ba 100644 --- a/src/library.js +++ b/src/library.js @@ -651,7 +651,7 @@ var Library = { me.ret = Pointer_make([0], 0, ALLOC_STATIC); } return me.ret; - }, + } }; load('library_sdl.js'); diff --git a/src/library_sdl.js b/src/library_sdl.js index c77a684c..533e69aa 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -2,7 +2,7 @@ mergeInto(Library, { SDL_Init: function(what) { SDL_INFO = { width: 320, - height: 240, + height: 240 }; SDL_SURFACES = {}; return 1; @@ -96,6 +96,6 @@ mergeInto(Library, { SDL_ShowCursor: function(toggle) { // TODO - }, + } }); diff --git a/src/parseTools.js b/src/parseTools.js index 968550e1..3f9a1481 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -35,7 +35,7 @@ function preprocess(text, constants) { function addPointing(type) { return type + '*' } function removePointing(type, num) { if (num === 0) return type; - return type.substr(0, type.length-(num ? num : 1)) + return type.substr(0, type.length-(num ? num : 1)); } function pointingLevels(type) { @@ -124,7 +124,7 @@ function combineTokens(tokens) { var ret = { lineNum: tokens[0].lineNum, text: '', - tokens: [], + tokens: [] }; tokens.forEach(function(token) { ret.text += token.text; @@ -191,7 +191,7 @@ function splitItem(parent, childSlot, copySlots) { copySlots.forEach(function(slot) { child[slot] = parent[slot] }); return { parent: parent, - child: child, + child: child }; } @@ -246,7 +246,7 @@ function parseParamTokens(params) { if (segment.length == 1) { if (segment[0].text == '...') { ret.push({ - intertype: 'varargs', + intertype: 'varargs' }); } else { // Clang sometimes has a parameter with just a type, @@ -255,7 +255,7 @@ function parseParamTokens(params) { intertype: 'value', type: segment[0].text, value: null, - ident: toNiceIdent('%') + absIndex, + ident: toNiceIdent('%') + absIndex }); } } else if (segment[1].text in PARSABLE_LLVM_FUNCTIONS) { @@ -272,7 +272,7 @@ function parseParamTokens(params) { intertype: 'value', type: segment[0].text, value: segment[1], - ident: parseNumerical(segment[1].text), + ident: parseNumerical(segment[1].text) }); // } else { // throw "what is this params token? " + JSON.stringify(segment); @@ -288,13 +288,13 @@ function parseLLVMSegment(segment) { return { intertype: 'value', ident: segment[0].text, - type: isType(segment[0].text) ? segment[0].text : '?', + type: isType(segment[0].text) ? segment[0].text : '?' }; } else if (segment[1].type == '{') { return { intertype: 'structvalue', values: splitTokenList(segment[1].tokens).map(parseLLVMSegment), - type: segment[0].text, + type: segment[0].text }; } else if (segment[0].text in PARSABLE_LLVM_FUNCTIONS) { return parseLLVMFunctionCall([{text: '?'}].concat(segment)); @@ -304,7 +304,7 @@ function parseLLVMSegment(segment) { return { intertype: 'value', ident: segment[1].text, - type: segment[0].text, + type: segment[0].text }; } } @@ -335,7 +335,7 @@ function parseLLVMFunctionCall(segment) { var ret = { intertype: segment[1].text, type: segment[0].text, - params: parseParamTokens(segment[2].item.tokens), + params: parseParamTokens(segment[2].item.tokens) }; ret.ident = toNiceIdent(ret.params[0].ident); return ret; diff --git a/src/runtime.js b/src/runtime.js index 0f9ef80a..455d8c0e 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -67,7 +67,7 @@ Run |