3 #define YYLTYPE Location
9 bool memoryGuard = false;
10 public void SetMemoryGuard(bool b) { memoryGuard = b; } public bool GetMemoryGuard() { return memoryGuard; }
12 static void OutputIdentifier(Identifier id, File f)
17 TODO: Name Space Fix ups
18 if(id.nameSpace && id.nameSpace->name)
20 f.Puts(id.nameSpace->name);
24 if(id._class.type == templateTypeSpecifier)
26 if(id._class.templateParameter && id._class.templateParameter.identifier && id._class.templateParameter.identifier.string)
27 f.Puts(id._class.templateParameter.identifier.string);
33 if(!strcmp(id._class.name, "class"))
34 f.Puts("typed_object");
36 f.Puts(id._class.name);
42 f.Puts((id && id.string) ? id.string : "(null identifier)");
45 static void OutputOperator(int op, File f)
49 case INC_OP: f.Puts("++"); break;
50 case DEC_OP: f.Puts("--");break;
51 case SIZEOF: f.Puts("sizeof "); break;
52 case LEFT_OP: f.Puts("<<"); break;
53 case RIGHT_OP: f.Puts(">>"); break;
54 case LE_OP: f.Puts("<="); break;
55 case GE_OP: f.Puts(">="); break;
56 case EQ_OP: f.Puts("=="); break;
57 case NE_OP: f.Puts("!="); break;
58 case AND_OP: f.Puts("&&"); break;
59 case OR_OP: f.Puts("||"); break;
60 case MUL_ASSIGN: f.Puts("*="); break;
61 case DIV_ASSIGN: f.Puts("/="); break;
62 case MOD_ASSIGN: f.Puts("%="); break;
63 case ADD_ASSIGN: f.Puts("+="); break;
64 case SUB_ASSIGN: f.Puts("-="); break;
65 case LEFT_ASSIGN: f.Puts("<<="); break;
66 case RIGHT_ASSIGN: f.Puts(">>="); break;
67 case AND_ASSIGN: f.Puts("&="); break;
68 case XOR_ASSIGN: f.Puts("^="); break;
69 case OR_ASSIGN: f.Puts("|="); break;
70 case '&': case '*': case '+': case '-': case '~': case '!': case '/': case '%':
71 case '<': case '>': case '|': case '^': case '=':
74 case DELETE: f.Puts("delete "); break;
78 public void OutputTypeName(TypeName type, File f)
80 /*if(type.typedObject)
82 //f.Puts("Class * class, void *");
85 else */if(type.qualifiers)
88 for(spec = type.qualifiers->first; spec; spec = spec.next)
90 OutputSpecifier(spec, f, false);
91 if(spec.next) f.Puts(" ");
97 OutputDeclarator(type.declarator, f);
100 if(/*!type.typedObject && */!type.qualifiers && !type.declarator)
105 public void OutputExpression(Expression exp, File f)
111 if(exp._classExp.specifiers)
114 for(spec = exp._classExp.specifiers->first; spec; spec = spec.next)
116 OutputSpecifier(spec, f, false);
117 if(spec.next) f.Puts(" ");
119 if(exp._classExp.decl)
122 OutputDeclarator(exp._classExp.decl, f);
127 case extensionCompoundExp:
128 f.Puts("__extension__ (");
129 OutputStatement(exp.compound, f);
135 OutputTypeName(exp._renew.typeName, f);
137 OutputExpression(exp._renew.size, f);
143 OutputTypeName(exp._renew.typeName, f);
145 OutputExpression(exp._renew.size, f);
150 OutputExpression(exp._renew.exp, f);
152 OutputTypeName(exp._renew.typeName, f);
154 OutputExpression(exp._renew.size, f);
159 OutputExpression(exp._renew.exp, f);
161 OutputTypeName(exp._renew.typeName, f);
163 OutputExpression(exp._renew.size, f);
168 OutputIdentifier(exp.identifier, f);
172 OutputInstance(exp.instance, f);
176 f.Puts(exp.constant);
187 OutputExpression(exp.op.exp1, f);
191 OutputOperator(exp.op.op, f);
194 if(exp.op.exp1 || (exp.op.exp2.type == opExp && !exp.op.exp2.op.exp1 && exp.op.exp2.op.op == exp.op.op))
196 OutputExpression(exp.op.exp2, f);
199 case extensionExpressionExp:
202 Expression expression;
203 if(exp.type == extensionExpressionExp)
204 f.Puts("__extension__ (");
208 for(expression = exp.list->first; expression; expression = expression.next)
210 OutputExpression(expression, f);
211 if(expression.next) f.Puts(", ");
219 Expression expression;
221 OutputExpression(exp.index.exp, f);
224 for(expression = exp.index.index->first; expression; expression = expression.next)
226 OutputExpression(expression, f);
227 if(expression.next) f.Puts(", ");
234 OutputExpression(exp.call.exp, f);
236 if(exp.call.arguments)
238 Expression expression;
239 for(expression = exp.call.arguments->first; expression; expression = expression.next)
241 OutputExpression(expression, f);
242 if(expression.next) f.Puts(", ");
250 OutputExpression(exp.member.exp, f);
252 if(exp.member.member)
253 OutputIdentifier(exp.member.member, f);
256 OutputExpression(exp.member.exp, f);
258 OutputIdentifier(exp.member.member, f);
262 OutputTypeName(exp.typeName, f);
266 f.Puts("__alignof__(");
267 OutputTypeName(exp.typeName, f);
270 case extensionInitializerExp:
271 f.Puts("__extension__ (");
272 if(exp.initializer.typeName)
273 OutputTypeName(exp.initializer.typeName, f);
275 if(exp.initializer.initializer)
276 OutputInitializer(exp.initializer.initializer, f);
280 OutputTypeName(exp.cast.typeName, f);
283 OutputExpression(exp.cast.exp, f);
286 OutputExpression(exp.cond.cond, f);
289 Expression expression;
290 for(expression = exp.cond.exp->first; expression; expression = expression.next)
292 OutputExpression(expression, f);
293 if(expression.next) f.Puts(", ");
297 OutputExpression(exp.cond.elseExp, f);
300 f.Puts("__builtin_va_arg(");
301 OutputExpression(exp.vaArg.exp, f);
303 OutputTypeName(exp.vaArg.typeName, f);
310 Expression expression;
311 for(expression = exp.list->first; expression; expression = expression.next)
313 OutputExpression(expression, f);
314 if(expression.next) f.Puts(", ");
322 static void OutputAsmField(AsmField field, File f)
324 f.Puts(field.command);
328 OutputExpression(field.expression, f);
333 static void OutputStatement(Statement stmt, File f)
335 char name[MAX_FILENAME] = "";
336 char origName[MAX_FILENAME] = "";
340 eString_GetLastDirectory(sourceFile, name);
345 if(yylloc.start.included)
347 //GetWorkingDir(name, sizeof(name));
348 PathCat(name, GetIncludeFileFromID(yylloc.start.included));
352 //GetWorkingDir(name, sizeof(name));
353 PathCat(name, sourceFile);
355 ChangeCh(name, '\\', '/');
357 //GetWorkingDir(origName, sizeof(origName));
358 PathCat(origName, outputFile);
359 ChangeCh(origName, '\\', '/');
363 if(inCompiler && outputLineNumbers && stmt.loc.start.line)
365 /*if(stmt.loc.start.line == 1)
367 f.Printf("\n#line %d \"%s\"\n", stmt.loc.start.line, name);
374 OutputIdentifier(stmt.labeled.id, f);
377 OutputStatement(stmt.labeled.stmt, f);
380 if(stmt.caseStmt.exp)
383 OutputExpression(stmt.caseStmt.exp, f);
389 f.Puts("default:\n");
392 if(stmt.caseStmt.stmt)
393 OutputStatement(stmt.caseStmt.stmt, f);
399 if(stmt.compound.declarations)
402 for(decl = stmt.compound.declarations->first; decl; decl = decl.next)
404 OutputDeclaration(decl, f);
408 if(stmt.compound.statements)
411 if(stmt.compound.declarations)
416 for(statement = stmt.compound.statements->first; statement; statement = statement.next)
418 OutputStatement(statement, f);
423 if(inCompiler && outputLineNumbers && stmt.loc.end.line)
425 /*if(stmt.loc.end.line == 1)
428 f.Printf("\n#line %d \"%s\"\n", stmt.loc.end.line, name);
440 for(exp = stmt.expressions->first; exp; exp = exp.next)
442 OutputExpression(exp, f);
443 if(exp.next) f.Puts(", ");
453 for(exp = stmt.ifStmt.exp->first; exp; exp = exp.next)
455 OutputExpression(exp, f);
456 if(exp.next) f.Puts(", ");
461 OutputStatement(stmt.ifStmt.stmt, f);
462 if(stmt.ifStmt.elseStmt)
467 if(stmt.ifStmt.elseStmt.type != ifStmt)
474 OutputStatement(stmt.ifStmt.elseStmt, f);
482 for(exp = stmt.switchStmt.exp->first; exp; exp = exp.next)
484 OutputExpression(exp, f);
485 if(exp.next) f.Puts(", ");
489 OutputStatement(stmt.switchStmt.stmt, f);
496 for(exp = stmt.switchStmt.exp->first; exp; exp = exp.next)
498 OutputExpression(exp, f);
499 if(exp.next) f.Puts(", ");
503 OutputStatement(stmt.whileStmt.stmt, f);
511 OutputStatement(stmt.whileStmt.stmt, f);
513 for(exp = stmt.switchStmt.exp->first; exp; exp = exp.next)
515 OutputExpression(exp, f);
516 if(exp.next) f.Puts(", ");
525 OutputStatement(stmt.forStmt.init, f);
527 OutputStatement(stmt.forStmt.check, f);
529 if(stmt.forStmt.increment)
531 // TESTING THIS HERE FOR FOR INCREMENT
532 if(inCompiler && outputLineNumbers && stmt.loc.end.line)
534 /*if(stmt.loc.end.line == 1)
537 f.Printf("\n#line %d \"%s\"\n", stmt.loc.end.line, name);
541 for(exp = stmt.forStmt.increment->first; exp; exp = exp.next)
543 OutputExpression(exp, f);
544 if(exp.next) f.Puts(", ");
549 OutputStatement(stmt.forStmt.stmt, f);
555 OutputIdentifier(stmt.gotoStmt.id, f);
569 if(inCompiler && memoryGuard)
571 Expression exp = stmt.expressions ? stmt.expressions->last : null;
573 if(exp && exp.expType)
576 char string[1024] = "";
577 OldList * specs = MkList();
580 if(exp.expType.kind == templateType)
582 if(exp.expType.templateParameter.dataTypeString)
583 decl = SpecDeclFromString(exp.expType.templateParameter.dataTypeString, specs,
584 MkDeclaratorIdentifier(MkIdentifier("__ecereReturnVal")));
585 else if(exp.expType.templateParameter.dataType)
588 specs = CopyList(exp.expType.templateParameter.dataType.specifiers, CopySpecifier);
589 decl = PlugDeclarator(/*CopyDeclarator(*/exp.expType.templateParameter.dataType.decl/*)*/,
590 MkDeclaratorIdentifier(MkIdentifier("__ecereReturnVal")));
594 ListAdd(specs, MkSpecifierName("uint64"));
595 decl = MkDeclaratorIdentifier(MkIdentifier("__ecereReturnVal"));
600 PrintType(exp.expType, string, true, true);
601 decl = SpecDeclFromString(string, specs, MkDeclaratorIdentifier(MkIdentifier("__ecereReturnVal")));
604 typeName = MkTypeName(specs, decl);
605 InstDeclPassTypeName(typeName, false);
606 OutputTypeName(typeName, f);
608 FreeTypeName(typeName);
615 Expression exp = stmt.expressions ? stmt.expressions->last : null;
616 if(exp && exp.expType)
617 f.Printf("__ecereReturnVal = ");
622 for(exp = stmt.expressions->first; exp; exp = exp.next)
624 OutputExpression(exp, f);
625 if(exp.next) f.Puts(", ");
630 if(inCompiler && memoryGuard)
632 Expression exp = stmt.expressions ? (Expression)stmt.expressions->last : null;
633 f.Printf(" __ecereNameSpace__ecere__com__MemoryGuard_PopLoc();");
634 if(exp && exp.expType)
635 f.Printf("return __ecereReturnVal;");
648 if(stmt.asmStmt.spec)
649 OutputSpecifier(stmt.asmStmt.spec, f, false);
651 f.Puts(stmt.asmStmt.statements);
653 if(stmt.asmStmt.inputFields || stmt.asmStmt.outputFields || stmt.asmStmt.clobberedFields)
656 if(stmt.asmStmt.inputFields)
658 for(field = stmt.asmStmt.inputFields->first; field; field = field.next)
660 if(field.prev) f.Puts(",");
661 OutputAsmField(field, f);
665 if(stmt.asmStmt.outputFields || stmt.asmStmt.clobberedFields)
668 if(stmt.asmStmt.outputFields)
670 for(field = stmt.asmStmt.outputFields->first; field; field = field.next)
672 if(field.prev) f.Puts(",");
673 OutputAsmField(field, f);
677 if(stmt.asmStmt.clobberedFields)
680 for(field = stmt.asmStmt.clobberedFields->first; field; field = field.next)
682 if(field.prev) f.Puts(",");
683 OutputAsmField(field, f);
691 if(inCompiler && outputLineNumbers && stmt.loc.start.line)
693 f.Printf("\n#line %d \"%s\"\n", outputLine+2, origName);
698 static void OutputPointer(Pointer ptr, File f)
705 for(spec = ptr.qualifiers->first; spec; spec = spec.next)
707 OutputSpecifier(spec, f, false);
708 if(spec.next) f.Puts(" ");
713 OutputPointer(ptr.pointer, f);
717 static void OutputDeclarator(Declarator decl, File f)
721 case structDeclarator:
724 OutputDeclarator(decl.declarator, f);
726 if(decl.structDecl.exp)
729 OutputExpression(decl.structDecl.exp, f);
731 if(decl.structDecl.posExp)
734 OutputExpression(decl.structDecl.posExp, f);
736 if(decl.structDecl.attrib)
739 OutputAttrib(decl.structDecl.attrib, f);
742 case identifierDeclarator:
743 OutputIdentifier(decl.identifier, f);
745 case bracketsDeclarator:
747 OutputDeclarator(decl.declarator, f);
750 case extendedDeclarator:
751 if(decl.extended.extended) OutputExtDecl(decl.extended.extended, f);
753 OutputDeclarator(decl.declarator, f);
755 case extendedDeclaratorEnd:
756 OutputDeclarator(decl.declarator, f);
758 if(decl.extended.extended)
759 OutputExtDecl(decl.extended.extended, f);
761 case arrayDeclarator:
764 OutputDeclarator(decl.declarator, f);
770 ProcessExpressionType(decl.array.exp);
771 ComputeExpression(decl.array.exp);
773 OutputExpression(decl.array.exp, f);
775 else if(decl.array.enumClass)
777 Symbol _class = decl.array.enumClass.symbol; // FindClass(decl.array.enumClass.name);
778 if(_class && _class.registered)
780 f.Printf("%d", eClass_GetProperty(_class.registered, "enumSize"));
785 case functionDeclarator:
790 OutputDeclarator(decl.declarator, f);
792 if(decl.function.parameters && decl.function.parameters->first)
794 for(param = decl.function.parameters->first; param; param = param.next)
796 OutputTypeName(param, f);
804 case pointerDeclarator:
805 if(decl.pointer.pointer) OutputPointer(decl.pointer.pointer, f);
809 OutputDeclarator(decl.declarator, f);
815 static void OutputEnumerator(Enumerator enumerator, File f)
817 OutputIdentifier(enumerator.id, f);
821 OutputExpression(enumerator.exp, f);
825 static void OutputAttribute(Attribute attr, File f)
832 OutputExpression(attr.exp, f);
836 static void OutputAttrib(Attrib attr, File f)
840 case ATTRIB: f.Puts("__attribute__(("); break;
841 case __ATTRIB: f.Puts("__attribute(("); break;
842 case ATTRIB_DEP: f.Puts("__attribute_deprecated__(("); break;
848 for(attrib = attr.attribs->first; attrib; attrib = attrib.next)
850 if(attrib.prev) f.Puts(" ");
851 OutputAttribute(attrib, f);
857 static void OutputExtDecl(ExtDecl extDecl, File f)
859 if(extDecl.type == extDeclString && extDecl.s)
861 else if(extDecl.type == extDeclAttrib)
862 OutputAttrib(extDecl.attr, f);
865 static void OutputSpecifier(Specifier spec, File f, bool typeName)
870 switch(spec.specifier)
911 f.Puts(typeName ? "uint" : "unsigned int");
916 f.Puts(typeName ? "int64" : "long long");
919 f.Puts("__builtin_va_list");
937 f.Puts("typed_object");
940 f.Puts("any_object");
950 case extendedSpecifier:
952 OutputExtDecl(spec.extDecl, f);
955 //case classSpecifier:
956 if(spec.name && !strcmp(spec.name, "class"))
958 f.Puts("typed_object");
962 Symbol symbol = spec.symbol; // FindClass(spec.name);
963 // WILL HAVE TO VERIFY THESE ELSEWHERE...
964 if(!symbol && spec.name)
965 symbol = FindClass(spec.name);
968 f.Puts(symbol.string ? symbol.string : "(null)");
980 OutputIdentifier(spec.id, f);
984 Enumerator enumerator;
987 for(enumerator = spec.list->first; enumerator; enumerator = enumerator.next)
989 OutputEnumerator(enumerator, f);
990 if(enumerator.next) f.Puts(", ");
997 case structSpecifier:
1000 f.Puts((spec.type == structSpecifier) ? "struct" : "union");
1001 if(spec.extDeclStruct)
1004 OutputExtDecl(spec.extDeclStruct, f);
1009 OutputIdentifier(spec.id, f);
1011 if(spec.definitions)
1016 for(def = spec.definitions->first; def; def = def.next)
1018 //OutputDeclaration(decl, f);
1019 OutputClassDef(def, f);
1021 f.Puts("} __attribute__ ((gcc_struct))");
1025 case typeOfSpecifier:
1026 f.Puts("__typeof(");
1027 OutputExpression(spec.expression, f);
1030 case subClassSpecifier:
1031 f.Puts("subclass(");
1032 OutputSpecifier(spec._class, f, false);
1035 case templateTypeSpecifier:
1036 OutputIdentifier(spec.templateParameter.identifier, f);
1041 static void OutputInitializer(Initializer initializer, File f)
1043 char name[MAX_FILENAME] = "";
1044 char origName[MAX_FILENAME] = "";
1048 eString_GetLastDirectory(sourceFile, name);
1053 if(yylloc.start.included)
1055 //GetWorkingDir(name, sizeof(name));
1056 PathCat(name, GetIncludeFileFromID(yylloc.start.included));
1060 //GetWorkingDir(name, sizeof(name));
1061 PathCat(name, sourceFile);
1063 ChangeCh(name, '\\', '/');
1065 //GetWorkingDir(origName, sizeof(origName));
1066 PathCat(origName, outputFile);
1067 ChangeCh(origName, '\\', '/');
1070 switch(initializer.type)
1072 case listInitializer:
1078 if(inCompiler && outputLineNumbers && initializer.loc.start.line)
1080 /*if(initializer.loc.start.line == 1)
1083 f.Printf("\n#line %d \"%s\"\n", initializer.loc.start.line, name);
1087 for(init = initializer.list->first; init; init = init.next)
1089 OutputInitializer(init, f);
1090 if(init.next) f.Puts(", ");
1094 if(inCompiler && outputLineNumbers && initializer.loc.start.line)
1096 /*if(initializer.loc.start.line == 1)
1099 f.Printf("\n#line %d \"%s\"\n", initializer.loc.start.line, name);
1106 case expInitializer:
1108 OutputExpression(initializer.exp, f);
1113 static void OutputInitDeclarator(InitDeclarator decl, File f)
1115 OutputDeclarator(decl.declarator, f);
1116 if(decl.initializer)
1119 OutputInitializer(decl.initializer, f);
1123 static void OutputDeclaration(Declaration decl, File f)
1126 char origName[MAX_FILENAME] = "";
1130 case initDeclaration:
1134 //GetWorkingDir(origName, sizeof(origName));
1137 PathCat(origName, outputFile);
1138 ChangeCh(origName, '\\', '/');
1141 if(decl.declarators && decl.declarators->first)
1143 for(d = decl.declarators->first; d; d = d.next)
1146 char name[MAX_FILENAME] = "";
1149 GetLastDirectory(sourceFile, name);
1152 if(yylloc.start.included)
1154 //GetWorkingDir(name, sizeof(name));
1155 PathCat(name, GetIncludeFileFromID(yylloc.start.included));
1159 //GetWorkingDir(name, sizeof(name));
1160 PathCat(name, sourceFile);
1162 ChangeCh(name, '\\', '/');
1164 if(inCompiler && outputLineNumbers && decl.loc.start.line)
1166 /*if(decl.loc.start.line == 1)
1169 f.Printf("\n#line %d \"%s\"\n", decl.loc.start.line, name);
1178 bool inTypeDef = false;
1179 for(spec = decl.specifiers->first; spec; spec = spec.next)
1181 if(spec.type == baseSpecifier && spec.specifier == TYPEDEF)
1183 OutputSpecifier(spec, f, inTypeDef && !spec.next);
1184 if(spec.next) f.Puts(" ");
1187 if(decl.declarators && decl.declarators->first)
1191 for(d = decl.declarators->first; d; d = d.next)
1193 OutputInitDeclarator(d, f);
1194 if(d.next) f.Puts(", ");
1199 case structDeclaration:
1203 for(spec = decl.specifiers->first; spec; spec = spec.next)
1205 OutputSpecifier(spec, f, false);
1206 if(spec.next) f.Puts(" ");
1209 if(decl.declarators)
1214 for(d = decl.declarators->first; d; d = d.next)
1216 OutputDeclarator(d, f);
1217 if(d.next) f.Puts(", ");
1223 OutputSpecifier(decl.extStorage, f, false);
1227 case instDeclaration:
1230 OutputInstance(decl.inst, f);
1233 case defineDeclaration:
1234 return; // Skip semicolon
1238 if(inCompiler && outputLineNumbers && decl.loc.start.line && decl.type == initDeclaration)
1240 f.Printf("\n#line %d \"%s\"\n", outputLine+2, origName);
1245 static FunctionDefinition curFunction;
1247 static void OutputFunction(FunctionDefinition func, File f)
1249 FunctionDefinition oldFunc = curFunction;
1254 for(spec = func.specifiers->first; spec; spec = spec.next)
1256 OutputSpecifier(spec, f, false);
1257 if(spec.next) f.Puts(" ");
1261 if(func.declarator) OutputDeclarator(func.declarator, f);
1264 if(func.declarations)
1267 for(decl = func.declarations->first; decl; decl = decl.next)
1269 OutputDeclaration(decl, f);
1276 if(inCompiler && memoryGuard)
1278 char name[1024] = "";
1279 Identifier id = GetDeclId(func.declarator);
1281 if(yylloc.start.included)
1283 //GetWorkingDir(name, sizeof(name));
1284 PathCat(name, GetIncludeFileFromID(yylloc.start.included));
1288 //GetWorkingDir(name, sizeof(name));
1289 PathCat(name, sourceFile);
1291 ChangeCh(name, '\\', '/');
1294 f.Printf(" __ecereNameSpace__ecere__com__MemoryGuard_PushLoc(\"%s:%s\");\n", name, id.string);
1297 OutputStatement(func.body, f);
1298 if(inCompiler && memoryGuard)
1300 f.Printf(" __ecereNameSpace__ecere__com__MemoryGuard_PopLoc();\n");
1307 curFunction = oldFunc;
1310 static void OutputMemberInit(MemberInit init, File f)
1312 if(init.identifiers)
1314 if(init.identifiers->count > 1)
1318 for(id = init.identifiers->first; id; id = id.next)
1320 OutputIdentifier(id, f);
1326 else if(init.identifiers->first)
1327 OutputIdentifier(init.identifiers->first, f);
1330 if(init.initializer)
1331 OutputInitializer(init.initializer, f);
1334 static void OutputMembersInit(MembersInit init, File f)
1338 case dataMembersInit:
1341 if(init.dataMembers)
1343 for(member = init.dataMembers->first; member; member = member.next)
1345 OutputMemberInit(member, f);
1346 if(member.next) f.Puts(", ");
1351 case methodMembersInit:
1352 OutputClassFunction(init.function, f);
1357 static void OutputInstance(Instantiation inst, File f)
1360 OutputSpecifier(inst._class, f, false);
1364 OutputExpression(inst.exp, f);
1366 if(inst.members && inst.members->count > 1)
1371 else if(inst.members)
1378 for(init = inst.members->first; init; init = init.next)
1380 OutputMembersInit(init, f);
1381 if(init.type == dataMembersInit && init.next)
1394 static void OutputClassFunction(ClassFunction func, File f)
1399 for(spec = func.specifiers->first; spec; spec = spec.next)
1401 OutputSpecifier(spec, f, false);
1402 if(spec.next) f.Puts(" ");
1408 //if(func.class != (void *)-1)
1410 OutputSpecifier(func.class, f, false);
1413 if(func.declarator) OutputDeclarator(func.declarator, f);
1416 if(func.declarations)
1419 for(decl = func.declarations->first; decl; decl = decl.next)
1421 OutputDeclaration(decl, f);
1428 OutputStatement(func.body, f);
1436 static void OutputClassDef(ClassDef def, File f)
1440 case declarationClassDef:
1443 OutputDeclaration(def.decl, f);
1444 if(def.next && def.next.type != declarationClassDef)
1451 case defaultPropertiesClassDef:
1454 for(init = def.defProperties->first; init; init = init.next)
1456 OutputMemberInit(init, f);
1457 if(init.next) f.Puts(", ");
1463 case functionClassDef:
1464 OutputClassFunction(def.function, f);
1471 static void OutputClass(ClassDefinition _class, File f)
1474 OutputSpecifier(_class._class, f, false);
1475 if(_class.baseSpecs)
1480 for(spec = _class.baseSpecs->first; spec; spec = spec.next)
1482 OutputSpecifier(spec, f, false);
1485 if(_class.definitions)
1490 for(def = _class.definitions->first; def; def = def.next)
1492 OutputClassDef(def, f);
1501 public void OutputTree(OldList ast, File f)
1507 for(external = ast.first; external; external = external.next)
1509 switch(external.type)
1511 case functionExternal:
1512 OutputFunction(external.function, f);
1516 case declarationExternal:
1517 OutputDeclaration(external.declaration, f);
1522 OutputClass(external._class, f);
1530 public char * StringFromSpecDecl(OldList specs, Declarator decl)
1533 TypeName typeName { };
1534 File f = TempFile { };
1537 typeName.qualifiers = specs;
1538 typeName.declarator = decl;
1540 OutputTypeName(typeName, f);
1545 string = new char[size + 1];
1547 f.Read(string, 1, size);
1548 string[size] = '\0';
1549 TrimRSpaces(string, string);