Class: Rubinius::InstructionSet::OpCode

Inherits:
Object
  • Object
show all
Defined in:
lib/rubinius/code/compiler/iseq.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opcode, bytecode, params) ⇒ OpCode

Returns a new instance of OpCode.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rubinius/code/compiler/iseq.rb', line 17

def initialize(opcode, bytecode, params)
  @opcode         = opcode
  @bytecode       = bytecode
  @args           = params[:args]
  @arg_count      = @args.size
  @size           = @arg_count + 1
  @position       = nil
  @produced_position = nil

  @stack_consumed, @stack_produced = params[:stack]
  if @stack_consumed.kind_of? Fixnum
    if @stack_produced.kind_of? Fixnum
      @variable_stack = false
      @stack_difference = @stack_produced - @stack_consumed
    else
      @variable_stack = true
      produced_extra, @produced_position, @produced_times = @stack_produced
      @stack_difference = produced_extra -  @stack_consumed
    end
  else
    @variable_stack = true
    extra, @position = @stack_consumed

    if @stack_produced.kind_of? Fixnum
      @stack_difference = @stack_produced - extra
    else
      produced_extra, @produced_position, @produced_times = @stack_produced
      @stack_difference = produced_extra - extra
    end
  end

  @control_flow = params[:control_flow]
end

Instance Attribute Details

#arg_countObject (readonly)

Returns the value of attribute arg_count.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def arg_count
  @arg_count
end

#argsObject (readonly)

Returns the value of attribute args.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def args
  @args
end

#bytecodeObject (readonly)

Returns the value of attribute bytecode.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def bytecode
  @bytecode
end

#control_flowObject (readonly)

Returns the value of attribute control_flow.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def control_flow
  @control_flow
end

#opcodeObject (readonly) Also known as: name

Returns the value of attribute opcode.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def opcode
  @opcode
end

#positionObject (readonly)

Returns the value of attribute position.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def position
  @position
end

#produced_positionObject (readonly)

Returns the value of attribute produced_position.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def produced_position
  @produced_position
end

#sizeObject (readonly) Also known as: width

Returns the value of attribute size.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def size
  @size
end

#stackObject (readonly)

Returns the value of attribute stack.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def stack
  @stack
end

#stack_consumedObject (readonly)

Returns the value of attribute stack_consumed.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def stack_consumed
  @stack_consumed
end

#stack_differenceObject (readonly)

Returns the value of attribute stack_difference.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def stack_difference
  @stack_difference
end

#stack_producedObject (readonly)

Returns the value of attribute stack_produced.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def stack_produced
  @stack_produced
end

#variable_stackObject (readonly)

Returns the value of attribute variable_stack.



10
11
12
# File 'lib/rubinius/code/compiler/iseq.rb', line 10

def variable_stack
  @variable_stack
end

Instance Method Details

#to_sObject



55
56
57
# File 'lib/rubinius/code/compiler/iseq.rb', line 55

def to_s
  @opcode.to_s
end

#variable_stack?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/rubinius/code/compiler/iseq.rb', line 51

def variable_stack?
  @variable_stack
end