Module: SFRP::Low::DSL

Extended by:
DSL
Included in:
DSL
Defined in:
lib/sfrp/low/dsl.rb

Defined Under Namespace

Classes: FuncProxy, IfChainProxy

Instance Method Summary collapse

Instance Method Details

#call_exp(callee_str, arg_exps) ⇒ Object


Expression (String)




86
87
88
# File 'lib/sfrp/low/dsl.rb', line 86

def call_exp(callee_str, arg_exps)
  "#{callee_str}(#{arg_exps.map { |e| "(#{e})" }.join(', ')})"
end

#function(name_str, type_str, static = false, &block) ⇒ Object



15
16
17
18
19
# File 'lib/sfrp/low/dsl.rb', line 15

def function(name_str, type_str, static = false, &block)
  fp = FuncProxy.new
  block.call(fp) if block
  Function.new(static, name_str, type_str, fp.params, fp.stmts)
end

#if_chain_exp(&block) ⇒ Object



90
91
92
93
94
# File 'lib/sfrp/low/dsl.rb', line 90

def if_chain_exp(&block)
  ip = IfChainProxy.new
  block.call(ip)
  ip.to_exp
end

#if_stmt(cond_exp, &block) ⇒ Object



76
77
78
79
80
# File 'lib/sfrp/low/dsl.rb', line 76

def if_stmt(cond_exp, &block)
  stmts = []
  block.call(stmts) if block
  Block.new('if', cond_exp, stmts)
end

#include_ab(str) ⇒ Object



7
8
9
# File 'lib/sfrp/low/dsl.rb', line 7

def include_ab(str)
  Include.new("<#{str}>")
end

#include_dq(str) ⇒ Object



11
12
13
# File 'lib/sfrp/low/dsl.rb', line 11

def include_dq(str)
  Include.new('"' + str + '"')
end

#macro(str) ⇒ Object



25
26
27
# File 'lib/sfrp/low/dsl.rb', line 25

def macro(str)
  Macro.new(str)
end

#member(str) ⇒ Object



41
42
43
# File 'lib/sfrp/low/dsl.rb', line 41

def member(str)
  Member.new(str)
end

#member_structure(kind_str, var_str, &block) ⇒ Object



35
36
37
38
39
# File 'lib/sfrp/low/dsl.rb', line 35

def member_structure(kind_str, var_str, &block)
  members = []
  block.call(members) if block
  MemberStructure.new(kind_str, var_str, members)
end

#stmt(line) ⇒ Object


Statement




66
67
68
# File 'lib/sfrp/low/dsl.rb', line 66

def stmt(line)
  Statement.new(line)
end

#struct(name_str, &block) ⇒ Object



29
30
31
32
33
# File 'lib/sfrp/low/dsl.rb', line 29

def struct(name_str, &block)
  members = []
  block.call(members) if block
  Structure.new('struct', name_str, members)
end

#typedef(str) ⇒ Object



21
22
23
# File 'lib/sfrp/low/dsl.rb', line 21

def typedef(str)
  Typedef.new(str)
end

#while(cond_exp, &block) ⇒ Object



70
71
72
73
74
# File 'lib/sfrp/low/dsl.rb', line 70

def while(cond_exp, &block)
  stmts = []
  block.call(stmts) if block
  Block.new('while', cond_exp, stmts)
end