Class: Ikra::AST::VarDefNode

Inherits:
Node show all
Defined in:
lib/ast/nodes.rb,
lib/ast/printer.rb,
lib/ast/visitor.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#parent

Instance Method Summary collapse

Methods inherited from Node

#eql?, #hash

Constructor Details

#initialize(name:, read: false, written: false) ⇒ VarDefNode

Returns a new instance of VarDefNode.



116
117
118
119
120
# File 'lib/ast/nodes.rb', line 116

def initialize(name:, read: false, written: false)
    @name = name
    @read = read
    @written = written
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



112
113
114
# File 'lib/ast/nodes.rb', line 112

def name
  @name
end

#readObject

Returns the value of attribute read.



113
114
115
# File 'lib/ast/nodes.rb', line 113

def read
  @read
end

#writtenObject

Returns the value of attribute written.



114
115
116
# File 'lib/ast/nodes.rb', line 114

def written
  @written
end

Instance Method Details

#==(other) ⇒ Object



129
130
131
132
133
134
# File 'lib/ast/nodes.rb', line 129

def ==(other)
    return super(other) &&
        name == other.name &&
        read == other.read &&
        written == other.written
end

#accept(visitor) ⇒ Object



26
27
28
# File 'lib/ast/visitor.rb', line 26

def accept(visitor)
    return visitor.visit_var_def_node(self)
end

#cloneObject



122
123
124
125
126
127
# File 'lib/ast/nodes.rb', line 122

def clone
    return VarDefNode.new(
        name: @name,
        read: @read,
        written: @written)
end

#to_sObject



22
23
24
# File 'lib/ast/printer.rb', line 22

def to_s
    return "[VarDefNode: #{name}, read = #{read}, written = #{written}]"
end