aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-09-04 14:26:31 -0700
committeralon@honor <none@none>2010-09-04 14:26:31 -0700
commita21a2fcf89e3f19ff004b0656c4737f999e1563a (patch)
treeeef19455c426fc8c60be56946e83334b759edeaf /src
parent03f2bdb99ecbd69698622fec859b883ff57d02b8 (diff)
cleanup for mathops, function and error reporting
Diffstat (limited to 'src')
-rw-r--r--src/enzymatic.js16
-rw-r--r--src/parser.js28
2 files changed, 27 insertions, 17 deletions
diff --git a/src/enzymatic.js b/src/enzymatic.js
index 419cc73e..ae677829 100644
--- a/src/enzymatic.js
+++ b/src/enzymatic.js
@@ -150,13 +150,25 @@ Zyme.prototype = {
},
process: function(items) {
var ret = [];
- items.forEach(function(item) { ret = ret.concat(this.processItem(item)) }, this);
+ items.forEach(function(item) {
+ try {
+ ret = ret.concat(this.processItem(item));
+ } catch (e) {
+ print("Exception in process(), current item is: " + dump(item));
+ throw e;
+ }
+ }, this);
return ret;
},
processPairs: function(items, func) {
var ret = [];
for (var i = 0; i < items.length; i += 2) {
- ret = ret.concat(func(items[i], items[i+1]));
+ try {
+ ret = ret.concat(func(items[i], items[i+1]));
+ } catch (e) {
+ print("Exception in processPairs(), current items are: " + dump(items[i]) + ' :::: ' + dump(items[i+1]));
+ throw e;
+ }
}
return ret;
},
diff --git a/src/parser.js b/src/parser.js
index 7bba170d..82af3337 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -540,18 +540,15 @@ function intertyper(data) {
selectItem: function(item) { return item.tokens && item.tokens.length >= 4 && item.indent === 0 && item.tokens[0].text == 'define' &&
item.tokens.slice(-1)[0].text == '{' },
processItem: function(item) {
- if (item.tokens.slice(-3,-2)[0].text == 'align')
- item.tokens.splice(-3,2);
- if (item.tokens.slice(-2,-1)[0].text == 'nounwind')
- item.tokens.splice(-2,1);
- while (item.tokens.length > 5)
- item.tokens.splice(1, 1);
+ item.tokens = item.tokens.filter(function(token) {
+ return ['internal', 'signext', 'nounwind', 'define', 'linkonce_odr', 'inlinehint', '{'].indexOf(token.text) == -1;
+ });
return [{
__result__: true,
intertype: 'function',
- ident: item.tokens[2].text,
- returnType: item.tokens[1],
- params: item.tokens[3],
+ ident: item.tokens[1].text,
+ returnType: item.tokens[0],
+ params: item.tokens[2],
lineNum: item.lineNum,
}];
},
@@ -2238,6 +2235,7 @@ function JSify(data) {
}
});
makeFuncLineZyme('mathop', function(item) { with(item) {
+ dprint('mathop', 'mathop: ' + dump(item));
switch (item.op) {
case 'add': return ident + ' + ' + ident2;
case 'sub': return ident + ' - ' + ident2;
@@ -2268,12 +2266,12 @@ function JSify(data) {
}
case 'fcmp': {
switch (variant) {
- case 'uge': case 'sge': return '0+(' + ident + ' >= ' + ident2 + ')';
- case 'ule': case 'sle': return '0+(' + ident + ' <= ' + ident2 + ')';
- case 'ugt': case 'sgt': case 'ogt': return '0+(' + ident + ' > ' + ident2 + ')';
- case 'ult': case 'slt': case 'olt': return '0+(' + ident + ' < ' + ident2 + ')';
- case 'ne': case 'une': return '0+(' + ident + ' != ' + ident2 + ')';
- case 'eq': return '0+(' + ident + ' == ' + ident2 + ')';
+ case 'uge': case 'oge': return '0+(' + ident + ' >= ' + ident2 + ')';
+ case 'ule': case 'ole': return '0+(' + ident + ' <= ' + ident2 + ')';
+ case 'ugt': case 'ogt': return '0+(' + ident + ' > ' + ident2 + ')';
+ case 'ult': case 'olt': return '0+(' + ident + ' < ' + ident2 + ')';
+ case 'une': case 'one': return '0+(' + ident + ' != ' + ident2 + ')';
+ case 'ueq': case 'oeq': return '0+(' + ident + ' == ' + ident2 + ')';
default: throw 'Unknown fcmp variant: ' + variant
}
}