Class: Emfrp::FuncDef

Inherits:
Object
  • Object
show all
Defined in:
lib/emfrp/compile/c/syntax_codegen.rb

Instance Method Summary collapse

Instance Method Details

#codegen(ct) ⇒ Object



333
334
335
336
337
338
# File 'lib/emfrp/compile/c/syntax_codegen.rb', line 333

def codegen(ct)
  params = self[:params].map{|x| [ct.tref(x), x[:name][:desc]]}
  ct.define_func(ct.tref(self), func_name(ct), params) do |x|
    x << "return #{self[:exp].codegen(ct, x)};"
  end
end

#func_name(ct) ⇒ Object



340
341
342
# File 'lib/emfrp/compile/c/syntax_codegen.rb', line 340

def func_name(ct)
  ct.escape_name(self[:name][:desc]) + "_" + ct.serial(self[:name][:desc], self).to_s
end

#var_name(ct, name) ⇒ Object



344
345
346
# File 'lib/emfrp/compile/c/syntax_codegen.rb', line 344

def var_name(ct, name)
  ct.escape_name(name)
end