aboutsummaryrefslogtreecommitdiff
path: root/lib/mozilla-ast.js
diff options
context:
space:
mode:
authorMihai Bazon <mihai.bazon@gmail.com>2015-11-12 12:18:25 +0200
committerMihai Bazon <mihai.bazon@gmail.com>2015-11-12 12:18:25 +0200
commit08623aa6a700f62e6b096917d31b0b7a2705d281 (patch)
treeec3e9a3b4cff9e061c323030c2cf888a61d3c441 /lib/mozilla-ast.js
parentc898a26117c2687d5707a4e80d6058d5c8601165 (diff)
downloadtracifyjs-08623aa6a700f62e6b096917d31b0b7a2705d281.tar.gz
tracifyjs-08623aa6a700f62e6b096917d31b0b7a2705d281.zip
Fix output for "use asm" code from SpiderMonkey AST
(will only work properly if the SM tree contains "raw" properties for Literal number nodes)
Diffstat (limited to 'lib/mozilla-ast.js')
-rw-r--r--lib/mozilla-ast.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/mozilla-ast.js b/lib/mozilla-ast.js
index 2bb469fb..c1b2b683 100644
--- a/lib/mozilla-ast.js
+++ b/lib/mozilla-ast.js
@@ -363,13 +363,15 @@
prefix: true,
argument: {
type: "Literal",
- value: -value
+ value: -value,
+ raw: M.start.raw
}
};
}
return {
type: "Literal",
- value: value
+ value: value,
+ raw: M.start.raw
};
});
@@ -389,6 +391,12 @@
/* -----[ tools ]----- */
+ function raw_token(moznode) {
+ if (moznode.type == "Literal") {
+ return moznode.raw != null ? moznode.raw : moznode.value + "";
+ }
+ }
+
function my_start_token(moznode) {
var loc = moznode.loc, start = loc && loc.start;
var range = moznode.range;
@@ -399,7 +407,8 @@
pos : range ? range[0] : moznode.start,
endline : start && start.line,
endcol : start && start.column,
- endpos : range ? range[0] : moznode.start
+ endpos : range ? range[0] : moznode.start,
+ raw : raw_token(moznode),
});
};
@@ -413,7 +422,8 @@
pos : range ? range[1] : moznode.end,
endline : end && end.line,
endcol : end && end.column,
- endpos : range ? range[1] : moznode.end
+ endpos : range ? range[1] : moznode.end,
+ raw : raw_token(moznode),
});
};