Module: Rubinius::ToolSet.current::TS::Compiler::Runtime

Defined in:
lib/rubinius/compiler/runtime.rb

Class Method Summary collapse

Class Method Details

.find_constant_for_op_asign_or(name, scope) ⇒ Object



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
# File 'lib/rubinius/compiler/runtime.rb', line 19

def self.find_constant_for_op_asign_or(name, scope)
  name = Rubinius::Type.coerce_to_constant_name name

  current, constant = scope.module, undefined

  while current
    if entry = current.constant_table.lookup(name)
      constant = entry.constant
      constant = constant.call if constant.kind_of?(Autoload)
      return constant
    end

    current = current.direct_superclass
  end

  if instance_of?(Module)
    if entry = Object.constant_table.lookup(name)
      constant = entry.constant
      constant = constant.call if constant.kind_of?(Autoload)
      return constant
    end
  end

  nil
end

.get_encoding(name) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/rubinius/compiler/runtime.rb', line 59

def self.get_encoding(name)
  if defined?(Encoding)
    Encoding.find name
  else
    name
  end
end

.get_flip_flop(scope, index) ⇒ Object



45
46
47
48
# File 'lib/rubinius/compiler/runtime.rb', line 45

def self.get_flip_flop(scope, index)
  scope.flip_flops ||= {}
  scope.flip_flops[index]
end

.matches_when(array, receiver) ⇒ Object



5
6
7
8
# File 'lib/rubinius/compiler/runtime.rb', line 5

def self.matches_when(array, receiver)
  array.each { |x| return true if x === receiver }
  false
end

.pre_exeObject



67
68
69
# File 'lib/rubinius/compiler/runtime.rb', line 67

def self.pre_exe
  yield
end

.rbx_marshal_constantObject



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

def self.rbx_marshal_constant
  name
end

.set_flip_flop(scope, index, value) ⇒ Object



50
51
52
53
# File 'lib/rubinius/compiler/runtime.rb', line 50

def self.set_flip_flop(scope, index, value)
  scope.flip_flops ||= {}
  scope.flip_flops[index] = value
end

.unwrap_block_arg(arg) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/rubinius/compiler/runtime.rb', line 10

def self.unwrap_block_arg(arg)
  if arg.size == 1
    elem = arg.at(0)
    return elem if elem.kind_of?(Array)
  end

  arg
end