Class: Ikra::AST::HashNode

Inherits:
TreeNode show all
Defined in:
lib/ast/nodes.rb,
lib/ast/printer.rb,
lib/ast/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?

Constructor Details

#initialize(hash:) ⇒ HashNode

Returns a new instance of HashNode.



309
310
311
# File 'lib/ast/nodes.rb', line 309

def initialize(hash:)
    @hash = hash
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



307
308
309
# File 'lib/ast/nodes.rb', line 307

def hash
  @hash
end

Instance Method Details

#accept(visitor) ⇒ Object



62
63
64
# File 'lib/ast/visitor.rb', line 62

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

#cloneObject



313
314
315
316
# File 'lib/ast/nodes.rb', line 313

def clone
    # TODO: Clone properly
    return HashNode.new(hash: @hash.clone)
end

#to_sObject



58
59
60
61
62
# File 'lib/ast/printer.rb', line 58

def to_s
    return "[HashNode: {" + hash.map do |key, value|
        "#{key.to_s} => #{value.to_s}"
    end.join(", ") + "}]"
end