Class: Ikra::AST::LVarWriteNode

Inherits:
TreeNode show all
Defined in:
lib/ast/nodes.rb,
lib/ast/printer.rb,
lib/ast/visitor.rb,
lib/types/inference/ast_inference.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:, value:) ⇒ LVarWriteNode

Returns a new instance of LVarWriteNode.



347
348
349
350
351
352
# File 'lib/ast/nodes.rb', line 347

def initialize(identifier:, value:)
    @identifier = identifier
    @value = value

    value.parent = self
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



344
345
346
# File 'lib/ast/nodes.rb', line 344

def identifier
  @identifier
end

#valueObject (readonly)

Returns the value of attribute value.



345
346
347
# File 'lib/ast/nodes.rb', line 345

def value
  @value
end

#variable_kindObject

Returns the value of attribute variable_kind.



20
21
22
# File 'lib/translator/variable_classifier_visitor.rb', line 20

def variable_kind
  @variable_kind
end

#variable_typeObject

Returns the value of attribute variable_type.



48
49
50
# File 'lib/types/inference/ast_inference.rb', line 48

def variable_type
  @variable_type
end

Instance Method Details

#accept(visitor) ⇒ Object



80
81
82
# File 'lib/ast/visitor.rb', line 80

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

#cloneObject



354
355
356
357
358
# File 'lib/ast/nodes.rb', line 354

def clone
    return LVarWriteNode.new(
        identifier: @identifier,
        value: @value.clone)
end

#mangled_identifierObject



22
23
24
25
26
27
28
# File 'lib/translator/variable_classifier_visitor.rb', line 22

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

#to_sObject



78
79
80
# File 'lib/ast/printer.rb', line 78

def to_s
    return "[LVarWriteNode: #{identifier.to_s} := #{value.to_s}]"
end