Class: Emfrp::DataDef
- Inherits:
-
Object
- Object
- Emfrp::DataDef
- Defined in:
- lib/emfrp/compile/c/syntax_codegen.rb
Instance Method Summary collapse
Instance Method Details
#codegen(ct) ⇒ Object
310 311 312 313 314 315 316 317 |
# File 'lib/emfrp/compile/c/syntax_codegen.rb', line 310 def codegen(ct) t = ct.tref(self) ct.define_global_var(t, var_name(ct, self[:name][:desc])) ct.define_init_stmt("#{var_name(ct, self[:name][:desc])} = #{init_func_name(ct)}();") ct.define_func(t, init_func_name(ct), []) do |x| x << "return #{self[:exp].codegen(ct, x)};" end end |
#init_func_name(ct) ⇒ Object
323 324 325 |
# File 'lib/emfrp/compile/c/syntax_codegen.rb', line 323 def init_func_name(ct) "init_#{self[:name][:desc]}" end |
#var_name(ct, name) ⇒ Object
319 320 321 |
# File 'lib/emfrp/compile/c/syntax_codegen.rb', line 319 def var_name(ct) "data_#{self[:name][:desc]}" end |