Skip to content

Commit

Permalink
Refactor in_defs
Browse files Browse the repository at this point in the history
  • Loading branch information
makenowjust committed Dec 27, 2016
1 parent 5357534 commit 8eb3d72
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/compiler/crystal/tools/expand.cr
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ module Crystal
class ExpandVisitor < Visitor
def initialize(@target_location : Location)
@nodes = [] of ASTNode
@in_def_instance = false
@in_defs = false
@message = "no expansion found"
end

Expand All @@ -83,9 +83,7 @@ module Crystal
if type.is_a?(DefInstanceContainer)
type.def_instances.values.try do |typed_defs|
typed_defs.each do |typed_def|
@in_def_instance = true
typed_def.accept(self)
@in_def_instance = false
end
end
end
Expand All @@ -98,15 +96,15 @@ module Crystal
end

def process(result : Compiler::Result)
@in_defs = true
result.program.def_instances.each_value do |typed_def|
@in_def_instance = true
typed_def.accept(self)
@in_def_instance = false
end

result.program.types?.try &.values.each do |type|
process_type type
end
@in_defs = false

result.node.accept(self)

Expand All @@ -120,7 +118,7 @@ module Crystal
end

def visit(node : Def | FunDef)
@in_def_instance && contains_target(node)
@in_defs && contains_target(node)
end

def visit(node : Call)
Expand Down

0 comments on commit 8eb3d72

Please sign in to comment.