Skip to content
This repository has been archived by the owner on Nov 2, 2019. It is now read-only.

Commit

Permalink
Remove old post/pre inc/dec matchers.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Aug 18, 2012
1 parent 9357dfb commit e9d0c5b
Showing 1 changed file with 0 additions and 69 deletions.
69 changes: 0 additions & 69 deletions lib/furnace-avm2/transform/nf_normalize.rb
Expand Up @@ -6,7 +6,6 @@ class NFNormalize
def transform(nf)
@nf = nf

remove_useless_return
visit @nf

@nf
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e9d0c5b

Please sign in to comment.