Class: Rubinius::CompiledCode

Inherits:
Object
  • Object
show all
Defined in:
lib/rubinius/bridge/compiled_code.rb

Constant Summary collapse

KernelMethodSerial =
47

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#arityObject

Integer

number of arguments, negative if variadic.



21
22
23
# File 'lib/rubinius/bridge/compiled_code.rb', line 21

def arity
  @arity
end

#block_indexObject

Returns the value of attribute block_index.



23
24
25
# File 'lib/rubinius/bridge/compiled_code.rb', line 23

def block_index
  @block_index
end

#fileObject

Symbol

the file where this comes from



17
18
19
# File 'lib/rubinius/bridge/compiled_code.rb', line 17

def file
  @file
end

#hintsObject

added by the VM to indicate how it’s being used.



5
6
7
# File 'lib/rubinius/bridge/compiled_code.rb', line 5

def hints
  @hints
end

#iseqObject

Tuple

instructions to execute



8
9
10
# File 'lib/rubinius/bridge/compiled_code.rb', line 8

def iseq
  @iseq
end

#keywordsObject

Tuple

pairs of Symbol name, required flag



20
21
22
# File 'lib/rubinius/bridge/compiled_code.rb', line 20

def keywords
  @keywords
end

#linesObject

Tuple

tuple of the lines where its found



16
17
18
# File 'lib/rubinius/bridge/compiled_code.rb', line 16

def lines
  @lines
end

#literalsObject

Tuple

tuple of the literals



15
16
17
# File 'lib/rubinius/bridge/compiled_code.rb', line 15

def literals
  @literals
end

#local_countObject

Integer

number of local vars



10
11
12
# File 'lib/rubinius/bridge/compiled_code.rb', line 10

def local_count
  @local_count
end

#local_namesObject

Array<Symbol>

names of the local vars



18
19
20
# File 'lib/rubinius/bridge/compiled_code.rb', line 18

def local_names
  @local_names
end

#metadataObject

Tuple

extra data



6
7
8
# File 'lib/rubinius/bridge/compiled_code.rb', line 6

def 
  @metadata
end

#nameObject

Symbol

name of the method



7
8
9
# File 'lib/rubinius/bridge/compiled_code.rb', line 7

def name
  @name
end

#post_argsObject

Integer

number of args after splat



12
13
14
# File 'lib/rubinius/bridge/compiled_code.rb', line 12

def post_args
  @post_args
end

#primitiveObject

Returns the value of attribute primitive.



22
23
24
# File 'lib/rubinius/bridge/compiled_code.rb', line 22

def primitive
  @primitive
end

#required_argsObject

Integer

number of required args



11
12
13
# File 'lib/rubinius/bridge/compiled_code.rb', line 11

def required_args
  @required_args
end

#scopeObject

ConstantScope

scope for looking up constants



19
20
21
# File 'lib/rubinius/bridge/compiled_code.rb', line 19

def scope
  @scope
end

#splatObject

Integer

POSITION of the splat arg



14
15
16
# File 'lib/rubinius/bridge/compiled_code.rb', line 14

def splat
  @splat
end

#stack_sizeObject

Integer

size of stack at compile time



9
10
11
# File 'lib/rubinius/bridge/compiled_code.rb', line 9

def stack_size
  @stack_size
end

#total_argsObject

Integer

number of total args



13
14
15
# File 'lib/rubinius/bridge/compiled_code.rb', line 13

def total_args
  @total_args
end

Instance Method Details

#add_metadata(key, val) ⇒ Object

Raises:

  • (TypeError)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rubinius/bridge/compiled_code.rb', line 29

def (key, val)
  raise TypeError, "key must be a symbol" unless key.kind_of? Symbol

  case val
  when true, false, Symbol, Fixnum, String
    # ok
  else
    raise TypeError, "invalid type of value"
  end

  @metadata ||= nil # to deal with MRI seeing @metadata as not set

  unless @metadata
    @metadata = Tuple.new(2)
    @metadata[0] = key
    @metadata[1] = val
    return val
  end

  i = 0
  fin = @metadata.size

  while i < fin
    if @metadata[i] == key
      @metadata[i + 1] = val
      return val
    end

    i += 2
  end

  tup = Tuple.new(fin + 2)
  tup.copy_from @metadata, 0, fin, 0
  tup[fin] = key
  tup[fin + 1] = val

  @metadata = tup

  return val
end

#decode(bytecodes = @iseq) ⇒ Object



25
26
27
# File 'lib/rubinius/bridge/compiled_code.rb', line 25

def decode(bytecodes = @iseq)
  # TODO
end