Class: SyntaxTree::YARV::DupHash
Overview
Summary
duphash dups a Hash literal and pushes it onto the stack.
Usage
{ a: 1 }
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Instruction
#branch_targets, #canonical, #falls_through?, #leaves?, #pops, #side_effects?
Constructor Details
#initialize(object) ⇒ DupHash
Returns a new instance of DupHash.
1352
1353
1354
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1352
def initialize(object)
@object = object
end
|
Instance Attribute Details
#object ⇒ Object
Returns the value of attribute object.
1350
1351
1352
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1350
def object
@object
end
|
Instance Method Details
#==(other) ⇒ Object
1368
1369
1370
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1368
def ==(other)
other.is_a?(DupHash) && other.object == object
end
|
#call(vm) ⇒ Object
1380
1381
1382
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1380
def call(vm)
vm.push(object.dup)
end
|
#deconstruct_keys(_keys) ⇒ Object
1364
1365
1366
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1364
def deconstruct_keys(_keys)
{ object: object }
end
|
#disasm(fmt) ⇒ Object
1356
1357
1358
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1356
def disasm(fmt)
fmt.instruction("duphash", [fmt.object(object)])
end
|
#length ⇒ Object
1372
1373
1374
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1372
def length
2
end
|
#pushes ⇒ Object
1376
1377
1378
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1376
def pushes
1
end
|
#to_a(_iseq) ⇒ Object
1360
1361
1362
|
# File 'lib/syntax_tree/yarv/instructions.rb', line 1360
def to_a(_iseq)
[:duphash, object]
end
|