diff options
author | kzc <kzc@users.noreply.github.com> | 2017-09-20 12:52:48 -0400 |
---|---|---|
committer | alexlamsl <alexlamsl@gmail.com> | 2017-09-21 04:42:40 +0800 |
commit | 7e3e9da860d9da4fa3d5e37bea4d3bd399194c02 (patch) | |
tree | 942fd6473ff7792be4d07da7296c7cedb7244246 /lib/output.js | |
parent | 00f509405b44882bab5d63d97caacb21691cdad6 (diff) | |
download | tracifyjs-7e3e9da860d9da4fa3d5e37bea4d3bd399194c02.tar.gz tracifyjs-7e3e9da860d9da4fa3d5e37bea4d3bd399194c02.zip |
fix "use asm" numeric output (#2328)
fixes #2324
Diffstat (limited to 'lib/output.js')
-rw-r--r-- | lib/output.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/output.js b/lib/output.js index 315bfafd..1aa63450 100644 --- a/lib/output.js +++ b/lib/output.js @@ -482,13 +482,17 @@ function OutputStream(options) { nodetype.DEFMETHOD("_codegen", generator); }; - var use_asm = false; var in_directive = false; + var active_scope = null; + var use_asm = null; AST_Node.DEFMETHOD("print", function(stream, force_parens){ - var self = this, generator = self._codegen, prev_use_asm = use_asm; - if (self instanceof AST_Directive && self.value == "use asm" && stream.parent() instanceof AST_Scope) { - use_asm = true; + var self = this, generator = self._codegen; + if (self instanceof AST_Scope) { + active_scope = self; + } + else if (!use_asm && self instanceof AST_Directive && self.value == "use asm") { + use_asm = active_scope; } function doit() { self.add_comments(stream); @@ -502,8 +506,8 @@ function OutputStream(options) { doit(); } stream.pop_node(); - if (self instanceof AST_Scope) { - use_asm = prev_use_asm; + if (self === use_asm) { + use_asm = null; } }); AST_Node.DEFMETHOD("_print", AST_Node.prototype.print); |