diff --git a/generator/c/c_generator.c2 b/generator/c/c_generator.c2 index 3e6bf8993..69504bd35 100644 --- a/generator/c/c_generator.c2 +++ b/generator/c/c_generator.c2 @@ -461,6 +461,30 @@ fn void Generator.emitStruct(Generator* gen, string_buffer.Buf* out, Decl* d, u3 } } +fn void Generator.emitFunctionParam(Generator* gen, string_buffer.Buf* out, QualType qt, u32 name_idx, u32 arg_num) { + char[16] temp; + const char* name; + if (name_idx) { + name = gen.idx2name(name_idx); + } else { + // some compilers do not accept unnamed arguments in function definitions + snprintf(temp, elemsof(temp), "_arg%d", arg_num); + name = temp; + } + if (qt.isFunction()) { + FunctionType* ft = qt.getFunctionType(); + FunctionDecl* fd = ft.getDecl(); + if (fd.isParam()) { + gen.gen_member_type_func(fd, out, name); + return; + } + // TODO: when to we get here? + } + gen.emitTypePre(out, qt); + out.space(); + out.add(name); +} + fn void Generator.emitFunctionType(Generator* gen, string_buffer.Buf* out, Decl* d) { FunctionTypeDecl* ftd = (FunctionTypeDecl*)d; FunctionDecl* fd = ftd.getDecl(); @@ -474,15 +498,9 @@ fn void Generator.emitFunctionType(Generator* gen, string_buffer.Buf* out, Decl* u32 num_params = fd.getNumParams(); VarDecl** params = fd.getParams(); for (u32 i=0; i