Module: Citrus::Runtime

Defined in:
lib/citrus/runtime.rb

Class Method Summary collapse

Class Method Details

.build_clibObject



11
12
13
14
15
16
# File 'lib/citrus/runtime.rb', line 11

def self.build_clib
  @ct.declare(:printf, [:string], :int, true)
  @ct.declare(:puts, [:string], :int)
  @ct.declare(:read, [:int, :string, :int], :int)
  @ct.declare(:exit, [:int], :int)
end

.build_globalsObject



18
19
20
21
# File 'lib/citrus/runtime.rb', line 18

def self.build_globals
  @ct.assign_global(ERR_GLOBAL, @ct.string(""))
  @ct.assign_global(STS_GLOBAL, @ct.number(0))
end

.build_lib(generator) ⇒ Object



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

def self.build_lib(generator)
  @ct = generator
  build_clib
  build_globals
  build_raise
end

.build_raiseObject



23
24
25
26
27
28
29
# File 'lib/citrus/runtime.rb', line 23

def self.build_raise
  func = @ct.function("raise", ["msg"]) do |gf|
    gf.assign_global(ERR_GLOBAL, gf.load("msg"))
    gf.assign_global(STS_GLOBAL, gf.number(1))
  end
  func.force_types([PCHAR], INT)
end