class Ameba::AST::Branch

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.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(node : Crystal::ASTNode, parent : Ameba::AST::Branchable) #

Creates a new branch.

Branch.new(if_node)

[View source]

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)

[View source]
def self.of(node : Crystal::ASTNode, scope : Scope) #

Constructs a new branch based on the node in scope.

Branch.of(assign_node, scope)

[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def end_location(*args, **options) #

[View source]
def end_location(*args, **options, &) #

[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


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

[View source]
def location(*args, **options) #

[View source]
def location(*args, **options, &) #

[View source]
def node : Crystal::ASTNode #

The actual branch node.


[View source]
def parent : Branchable #

The parent branchable.


[View source]
def to_s(*args, **options) #

[View source]
def to_s(*args, **options, &) #

[View source]