Class: Rubinius::CompiledCode
- Defined in:
- lib/rubinius/bridge/compiled_code.rb
Constant Summary collapse
- KernelMethodSerial =
47
- CODE_ID_BYTES =
32
Instance Attribute Summary collapse
-
#arity ⇒ Object
- Integer
-
number of arguments, negative if variadic.
-
#block_index ⇒ Object
Returns the value of attribute block_index.
-
#file ⇒ Object
- Symbol
-
the file where this comes from.
-
#hints ⇒ Object
added by the VM to indicate how it’s being used.
-
#iseq ⇒ Object
- Tuple
-
instructions to execute.
-
#keywords ⇒ Object
- Tuple
-
pairs of Symbol name, required flag.
-
#lines ⇒ Object
- Tuple
-
tuple of the lines where its found.
-
#literals ⇒ Object
- Tuple
-
tuple of the literals.
-
#local_count ⇒ Object
- Integer
-
number of local vars.
-
#local_names ⇒ Object
- Array<Symbol>
-
names of the local vars.
-
#metadata ⇒ Object
- Tuple
-
extra data.
-
#name ⇒ Object
- Symbol
-
name of the method.
-
#post_args ⇒ Object
- Integer
-
number of args after splat.
-
#primitive ⇒ Object
Returns the value of attribute primitive.
-
#required_args ⇒ Object
- Integer
-
number of required args.
-
#scope ⇒ Object
- ConstantScope
-
scope for looking up constants.
-
#splat ⇒ Object
- Integer
-
POSITION of the splat arg.
-
#stack_size ⇒ Object
- Integer
-
size of stack at compile time.
-
#total_args ⇒ Object
- Integer
-
number of total args.
Instance Method Summary collapse
- #add_metadata(key, val) ⇒ Object
- #code_id ⇒ Object
- #decode(bytecodes = @iseq) ⇒ Object
-
#initialize ⇒ CompiledCode
constructor
A new instance of CompiledCode.
Constructor Details
#initialize ⇒ CompiledCode
Returns a new instance of CompiledCode.
27 28 29 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 27 def initialize @code_id = nil end |
Instance Attribute Details
#arity ⇒ Object
- Integer
-
number of arguments, negative if variadic.
23 24 25 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 23 def arity @arity end |
#block_index ⇒ Object
Returns the value of attribute block_index.
25 26 27 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 25 def block_index @block_index end |
#file ⇒ Object
- Symbol
-
the file where this comes from
19 20 21 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 19 def file @file end |
#hints ⇒ Object
added by the VM to indicate how it’s being used.
7 8 9 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 7 def hints @hints end |
#iseq ⇒ Object
- Tuple
-
instructions to execute
10 11 12 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 10 def iseq @iseq end |
#keywords ⇒ Object
- Tuple
-
pairs of Symbol name, required flag
22 23 24 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 22 def keywords @keywords end |
#lines ⇒ Object
- Tuple
-
tuple of the lines where its found
18 19 20 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 18 def lines @lines end |
#literals ⇒ Object
- Tuple
-
tuple of the literals
17 18 19 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 17 def literals @literals end |
#local_count ⇒ Object
- Integer
-
number of local vars
12 13 14 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 12 def local_count @local_count end |
#local_names ⇒ Object
- Array<Symbol>
-
names of the local vars
20 21 22 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 20 def local_names @local_names end |
#metadata ⇒ Object
- Tuple
-
extra data
8 9 10 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 8 def @metadata end |
#name ⇒ Object
- Symbol
-
name of the method
9 10 11 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 9 def name @name end |
#post_args ⇒ Object
- Integer
-
number of args after splat
14 15 16 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 14 def post_args @post_args end |
#primitive ⇒ Object
Returns the value of attribute primitive.
24 25 26 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 24 def primitive @primitive end |
#required_args ⇒ Object
- Integer
-
number of required args
13 14 15 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 13 def required_args @required_args end |
#scope ⇒ Object
- ConstantScope
-
scope for looking up constants
21 22 23 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 21 def scope @scope end |
#splat ⇒ Object
- Integer
-
POSITION of the splat arg
16 17 18 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 16 def splat @splat end |
#stack_size ⇒ Object
- Integer
-
size of stack at compile time
11 12 13 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 11 def stack_size @stack_size end |
#total_args ⇒ Object
- Integer
-
number of total args
15 16 17 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 15 def total_args @total_args end |
Instance Method Details
#add_metadata(key, val) ⇒ Object
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 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 41 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 |
#code_id ⇒ Object
37 38 39 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 37 def code_id @code_id || (@code_id = SecureRandom.hex(CODE_ID_BYTES)) end |
#decode(bytecodes = @iseq) ⇒ Object
31 32 33 |
# File 'lib/rubinius/bridge/compiled_code.rb', line 31 def decode(bytecodes = @iseq) # TODO end |