Class: RubyVM::Instruction

Inherits:
Object show all
Includes:
Internal::ByteDecoder
Defined in:
lib/internal/vm/bytedecoder.rb,
ext/internal/vm/instruction/instruction.c

Defined Under Namespace

Classes: CONCATARRAY, CONCATSTRINGS, DEFINED, DUP, GETCONSTANT, GETDYNAMIC, GETINLINECACHE, GETLOCAL, GETSPECIAL, LEAVE, NEWARRAY, NEWHASH, NOP, POP, PUTOBJECT, PUTSELF, SEND, SETCONSTANT, SETDYNAMIC, SETINLINECACHE, SETLOCAL, SETN, THROW, TOPN, TOREGEXP, TOSTRING, TRACE

Constant Summary collapse

INFIX_OPCODES =
{
  OPT_PLUS  => '+'.intern,
  OPT_MINUS => '-'.intern,
  OPT_MULT  => :*,
  OPT_DIV   => :/,
  OPT_MOD   => :%,
  OPT_LTLT  => :<<,
  # OPT_GTGT  => :>>,
  OPT_EQ    => :==,
  OPT_NEQ   => :!=,
  OPT_GT    => :>,
  OPT_GE    => :>=,
  OPT_LT    => :<,
  OPT_LE    => :<=,
}
INFIX_OPERATORS =
INFIX_OPCODES.values + [ :===, :>> ]
PREFIX_OPCODES =
{
  OPT_NOT   => :!,
}
PREFIX_OPERATORS =
PREFIX_OPCODES.values + [ :~, :+@, :-@ ]
LITERAL_OPCODES =
[
  PUTNIL,
  DUPARRAY,
  PUTSTRING,
]
GET_VARIABLE_OPCODES =
[
  GETCLASSVARIABLE,
  GETINSTANCEVARIABLE,
  GETGLOBAL,
]
SET_VARIABLE_OPCODES =
[
  SETCLASSVARIABLE,
  SETINSTANCEVARIABLE,
  SETGLOBAL,
]

Instance Method Summary collapse

Constructor Details

#new(*operands) ⇒ Instruction

Create a new instruction with the given operands.



21
22
23
24
25
26
# File 'ext/internal/vm/instruction/instruction.c', line 21

static VALUE instruction_initialize(int argc, VALUE * argv, VALUE self)
{
  VALUE operands = rb_ary_new4(argc, argv);
  rb_iv_set(self, "@operands", operands);
  return Qnil;
}

Instance Method Details

#operandsArray

Returns the instructions operands.

Returns:

  • (Array)


34
35
36
37
# File 'ext/internal/vm/instruction/instruction.c', line 34

static VALUE instruction_operands(VALUE self)
{
  return rb_iv_get(self, "@operands");
}