Class: SyntaxTree::YARV::DupArray

Inherits:
Object
  • Object
show all
Defined in:
lib/syntax_tree/yarv/instructions.rb

Overview

### Summary

duparray dups an Array literal and pushes it onto the stack.

### Usage

~~~ruby

true

~~~

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ DupArray

Returns a new instance of DupArray.



1281
1282
1283
# File 'lib/syntax_tree/yarv/instructions.rb', line 1281

def initialize(object)
  @object = object
end

Instance Attribute Details

#objectObject (readonly)

Returns the value of attribute object.



1279
1280
1281
# File 'lib/syntax_tree/yarv/instructions.rb', line 1279

def object
  @object
end

Instance Method Details

#==(other) ⇒ Object



1297
1298
1299
# File 'lib/syntax_tree/yarv/instructions.rb', line 1297

def ==(other)
  other.is_a?(DupArray) && other.object == object
end

#call(vm) ⇒ Object



1317
1318
1319
# File 'lib/syntax_tree/yarv/instructions.rb', line 1317

def call(vm)
  vm.push(object.dup)
end

#canonicalObject



1313
1314
1315
# File 'lib/syntax_tree/yarv/instructions.rb', line 1313

def canonical
  self
end

#deconstruct_keys(_keys) ⇒ Object



1293
1294
1295
# File 'lib/syntax_tree/yarv/instructions.rb', line 1293

def deconstruct_keys(_keys)
  { object: object }
end

#disasm(fmt) ⇒ Object



1285
1286
1287
# File 'lib/syntax_tree/yarv/instructions.rb', line 1285

def disasm(fmt)
  fmt.instruction("duparray", [fmt.object(object)])
end

#lengthObject



1301
1302
1303
# File 'lib/syntax_tree/yarv/instructions.rb', line 1301

def length
  2
end

#popsObject



1305
1306
1307
# File 'lib/syntax_tree/yarv/instructions.rb', line 1305

def pops
  0
end

#pushesObject



1309
1310
1311
# File 'lib/syntax_tree/yarv/instructions.rb', line 1309

def pushes
  1
end

#to_a(_iseq) ⇒ Object



1289
1290
1291
# File 'lib/syntax_tree/yarv/instructions.rb', line 1289

def to_a(_iseq)
  [:duparray, object]
end