class Ameba::AST::Branch
- Ameba::AST::Branch
- Reference
- Object
Overview
Represents the branch in Crystal code. Branch is a part of a branchable statement. For example, the branchable if statement contains 3 branches:
if a = something # --> Branch A
a = 1 # --> Branch B
put a if out # --> Branch C
else
do_something a # --> Branch D
end
Defined in:
ameba/ast/branch.crConstructors
-
.new(node, parent)
Creates a new branch.
Class Method Summary
-
.of(node : Crystal::ASTNode, parent_node : Crystal::ASTNode)
Constructs a new branch based on the node some parent scope.
-
.of(node : Crystal::ASTNode, scope : Scope)
Constructs a new branch based on the node in scope.
Instance Method Summary
-
#==(other : self)
Returns
true
if this reference is the same as other. - #end_location(*args, **options)
- #end_location(*args, **options, &)
-
#hash(hasher)
See
Object#hash(hasher)
-
#in_loop?
Returns true if current branch is in a loop, false - otherwise.
- #location(*args, **options)
- #location(*args, **options, &)
-
#node : Crystal::ASTNode
The actual branch node.
-
#parent : Branchable
The parent branchable.
- #to_s(*args, **options)
- #to_s(*args, **options, &)
Constructor Detail
Class Method Detail
def self.of(node : Crystal::ASTNode, parent_node : Crystal::ASTNode)
#
Constructs a new branch based on the node some parent scope.
Branch.of(assign_node, def_node)
Constructs a new branch based on the node in scope.
Branch.of(assign_node, scope)
Instance Method Detail
def ==(other : self)
#
Description copied from class Reference
Returns true
if this reference is the same as other. Invokes same?
.
def in_loop?
#
Returns true if current branch is in a loop, false - otherwise. For example, this branch is in a loop:
while true
handle_input # this branch is in a loop
if wrong_input
show_message # this branch is also in a loop.
end
end