Class: Ikra::AST::LVarReadNode

Inherits:
TreeNode show all
Defined in:
lib/ast/nodes.rb,
lib/ast/printer.rb,
lib/ast/visitor.rb,
lib/translator/variable_classifier_visitor.rb

Constant Summary

Constants inherited from TreeNode

TreeNode::TYPE_INFO_VARS

Instance Attribute Summary collapse

Attributes inherited from Node

#parent

Instance Method Summary collapse

Methods inherited from TreeNode

#==, #enclosing_class, #find_behavior_node, #get_type, #is_begin_node?, #merge_union_type, #register_type_change, #replace, #replace_child, #symbol_table

Methods inherited from Node

#==, #eql?, #hash

Constructor Details

#initialize(identifier:) ⇒ LVarReadNode

Returns a new instance of LVarReadNode.



334
335
336
# File 'lib/ast/nodes.rb', line 334

def initialize(identifier:)
    @identifier = identifier
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



332
333
334
# File 'lib/ast/nodes.rb', line 332

def identifier
  @identifier
end

#variable_kindObject

Returns the value of attribute variable_kind.



8
9
10
# File 'lib/translator/variable_classifier_visitor.rb', line 8

def variable_kind
  @variable_kind
end

Instance Method Details

#accept(visitor) ⇒ Object



74
75
76
# File 'lib/ast/visitor.rb', line 74

def accept(visitor)
    visitor.visit_lvar_read_node(self)
end

#cloneObject



338
339
340
# File 'lib/ast/nodes.rb', line 338

def clone
    return LVarReadNode.new(identifier: @identifier)
end

#mangled_identifierObject



10
11
12
13
14
15
16
# File 'lib/translator/variable_classifier_visitor.rb', line 10

def mangled_identifier
    if variable_kind == :lexical
        return Translator::Constants::LEXICAL_VAR_PREFIX + identifier.to_s
    else
        return identifier
    end
end

#to_sObject



72
73
74
# File 'lib/ast/printer.rb', line 72

def to_s
    return "[LVarReadNode: #{identifier.to_s}]"
end