Permalink
Browse files

Remove old post/pre inc/dec matchers.

  • Loading branch information...
1 parent 9357dfb commit e9d0c5bfa86583d9ace4fc35fd92ec22da2d09af @whitequark committed Aug 18, 2012
Showing with 0 additions and 69 deletions.
  1. +0 −69 lib/furnace-avm2/transform/nf_normalize.rb
@@ -6,7 +6,6 @@ class NFNormalize
def transform(nf)
@nf = nf
- remove_useless_return
visit @nf
@nf
@@ -39,74 +38,6 @@ def on_r(node)
end
end
- def remove_useless_return
- if @nf.children.last.type == :return_void
- @nf.children.slice! -1
- end
- end
-
- LocalIncDecMatcher = AST::Matcher.new do
- [ either_multi[
- [:set_slot, capture(:index), capture(:scope)],
- [:set_local, capture(:index)],
- ],
- either[
- [:convert, any,
- capture(:inner)],
- [:coerce, :any,
- capture(:inner)],
- capture(:inner)
- ]
- ]
- end
-
- LocalIncDecInnerMatcher = AST::Matcher.new do
- [capture(:operator),
- either[
- [:convert, any,
- capture(:getter)],
- capture(:getter),
- ]
- ]
- end
-
- LocalIncDecGetterMatcher = AST::Matcher.new do
- either[
- [:get_slot, backref(:index), backref(:scope)],
- [:get_local, backref(:index)],
- ]
- end
-
- IncDecOperators = [
- :pre_increment, :post_increment,
- :pre_decrement, :post_decrement
- ]
-
- def on_set_local(node)
- captures = {}
- if LocalIncDecMatcher.match(node, captures) &&
- LocalIncDecInnerMatcher.match(captures[:inner], captures) &&
- IncDecOperators.include?(captures[:operator])
- if captures[:getter].is_a?(AST::Node) &&
- LocalIncDecGetterMatcher.match(captures[:getter], captures)
- if captures[:scope]
- node.update(:"#{captures[:operator]}_slot", [ captures[:index], captures[:scope] ])
- else
- node.update(:"#{captures[:operator]}_local", [ captures[:index] ])
- end
- else
- node.update(:add, [
- AST::Node.new(:set_local, [
- captures[:index],
- captures[:getter]
- ]),
- AST::Node.new(:integer, [ 1 ])
- ])
- end
- end
- end
- alias :on_set_slot :on_set_local
-
ExpandedForInMatcher = AST::Matcher.new do
[:if, [:has_next2, skip], skip]
end

0 comments on commit e9d0c5b

Please sign in to comment.