Module: Twostroke::Runtime::Lib

Defined in:
lib/twostroke/runtime/lib.rb

Constant Summary collapse

INITIALIZERS =
[]

Class Method Summary collapse

Class Method Details

.register(&bk) ⇒ Object



11
12
13
# File 'lib/twostroke/runtime/lib.rb', line 11

def self.register(&bk)
  INITIALIZERS << bk
end

.setup_environment(vm) ⇒ Object



5
6
7
8
9
# File 'lib/twostroke/runtime/lib.rb', line 5

def self.setup_environment(vm)
  scope = vm.global_scope
  INITIALIZERS.each { |i| i.arity == 1 ? i.(scope) : i.(scope, vm) }
  scope.get_var("Object").prototype = Types::Function.constructor_function.get("prototype")
end