Method: Emfrp::TypeDef#struct_gen

Defined in:
lib/emfrp/compile/c/syntax_codegen.rb

#struct_gen(ct) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/emfrp/compile/c/syntax_codegen.rb', line 117

def struct_gen(ct)
  return if enum?(ct)
  ct.define_struct("struct", struct_name(ct), nil) do |s1|
    s1 << "int tvalue_id;" if self[:tvalues].length > 1
    s1 << "int mark;" unless self[:static]
    s1 << ct.define_struct("union", nil, "value") do |s2|
      self[:tvalues].each_with_index do |tvalue, i|
        next if tvalue[:params].size == 0
        s2 << ct.define_struct("struct", nil, tvalue.struct_name(ct)) do |s3|
          tvalue[:params].each_with_index do |param, i|
            s3 << "#{ct.tref(param)} member#{i};"
          end
        end
      end
    end
  end
end