class Ikra::AST::BeginNode

Attributes

body_stmts[R]

Public Class Methods

new(body_stmts: []) click to toggle source
# File lib/ast/nodes.rb, line 602
def initialize(body_stmts: [])
    @body_stmts = body_stmts

    body_stmts.each do |stmt|
        stmt.parent = self
    end
end

Public Instance Methods

accept(visitor) click to toggle source
# File lib/ast/visitor.rb, line 176
def accept(visitor)
    return visitor.visit_begin_node(self)
end
add_statement(node) click to toggle source
# File lib/ast/nodes.rb, line 615
def add_statement(node)
    body_stmts.push(node)
    node.parent = self
end
clone() click to toggle source
# File lib/ast/nodes.rb, line 610
def clone
    return BeginNode.new(
        body_stmts: @body_stmts.map do |s| s.clone end)
end
is_begin_node?() click to toggle source
# File lib/ast/nodes.rb, line 631
def is_begin_node?
    true
end
replace_child(node, another_node) click to toggle source
# File lib/ast/nodes.rb, line 620
def replace_child(node, another_node)
    @body_stmts = @body_stmts.map do |stmt|
        if node.equal?(stmt)
            another_node.parent = self
            another_node
        else
            stmt
        end
    end
end
to_s() click to toggle source
# File lib/ast/printer.rb, line 172
def to_s
    stmts = body_stmts.map do |stmt|
        stmt.to_s
    end.join(";\n")

    return "[BeginNode: {#{stmts}}]"
end