Permalink
Browse files

Improve prologue recognition.

  • Loading branch information...
1 parent dabf885 commit 2e69feca69101e69659b676e193ec0e0ab94c61a @whitequark committed Apr 14, 2012
Showing with 11 additions and 5 deletions.
  1. +11 −5 lib/furnace-avm2/source/decompiler.rb
@@ -22,7 +22,7 @@ def initialize(body, options)
[:get_local, 0]],
[:set_local, -1,
[:new_activation]],
- [:set_local, 1,
+ [:set_local, capture(:activation_local),
[:get_local, -1]],
[:push_scope,
[:get_local, -1]],
@@ -45,19 +45,25 @@ def decompile
@nf = @body.code_to_nf
- if ActivationPrologue.match @nf
+ if captures = ActivationPrologue.match(@nf)
@has_closure = true
+ @activation_local = captures[:activation_local]
@slots = {}
@body.traits.map do |trait|
@slots[trait.idx] = trait
end
@nf.children.slice! 0...4
- elsif RegularPrologue.match @nf
- @nf.children.slice! 0...1
else
- # No prologue; probably a closure.
+ @has_closure = false
+ @activation_local = nil
+
+ if RegularPrologue.match @nf
+ @nf.children.slice! 0...1
+ else
+ # No prologue; probably a closure.
+ end
end
stmt_block @nf, function: true

0 comments on commit 2e69fec

Please sign in to comment.