Rework has_directive

It's now available during tree walking, i.e. walker.has_directive("use
asm"), rather than as part of the scope.  It's thus no longer necessary
to call `figure_out_scope` before codegen.  Added special bits in the
code generator to overcome the fact that it doesn't inherit from
TreeWalker.

Fix #861
This commit is contained in:
Mihai Bazon
2015-11-11 22:15:25 +02:00
parent 3c4346728e
commit 7691bebea5
8 changed files with 60 additions and 59 deletions

View File

@@ -285,6 +285,9 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
nlb : S.newline_before,
file : filename
};
if (/^(?:num|string|regexp)$/i.test(type)) {
ret.literal = $TEXT.substring(ret.pos, ret.endpos);
}
if (!is_comment) {
ret.comments_before = S.comments_before;
S.comments_before = [];
@@ -335,11 +338,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
if (prefix) num = prefix + num;
var valid = parse_js_number(num);
if (!isNaN(valid)) {
var tok = token("num", valid);
if (num.indexOf('.') >= 0) {
tok.literal = num;
}
return tok;
return token("num", valid);
} else {
parse_error("Invalid syntax: " + num);
}
@@ -1152,7 +1151,7 @@ function parse($TEXT, options) {
ret = _make_symbol(AST_SymbolRef);
break;
case "num":
ret = new AST_Number({ start: tok, end: tok, value: tok.value, literal: tok.literal });
ret = new AST_Number({ start: tok, end: tok, value: tok.value });
break;
case "string":
ret = new AST_String({