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);
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);
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);
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);
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)
870 switch(spec.specifier)
911 f.Puts("unsigned int");
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");
1004 OutputIdentifier(spec.id, f);
1006 if(spec.definitions)
1011 for(def = spec.definitions->first; def; def = def.next)
1013 //OutputDeclaration(decl, f);
1014 OutputClassDef(def, f);
1020 case typeOfSpecifier:
1021 f.Puts("__typeof(");
1022 OutputExpression(spec.expression, f);
1025 case subClassSpecifier:
1026 f.Puts("subclass(");
1027 OutputSpecifier(spec._class, f);
1030 case templateTypeSpecifier:
1031 OutputIdentifier(spec.templateParameter.identifier, f);
1036 static void OutputInitializer(Initializer initializer, File f)
1038 char name[MAX_FILENAME] = "";
1039 char origName[MAX_FILENAME] = "";
1043 eString_GetLastDirectory(sourceFile, name);
1048 if(yylloc.start.included)
1050 //GetWorkingDir(name, sizeof(name));
1051 PathCat(name, GetIncludeFileFromID(yylloc.start.included));
1055 //GetWorkingDir(name, sizeof(name));
1056 PathCat(name, sourceFile);
1058 ChangeCh(name, '\\', '/');
1060 //GetWorkingDir(origName, sizeof(origName));
1061 PathCat(origName, outputFile);
1062 ChangeCh(origName, '\\', '/');
1065 switch(initializer.type)
1067 case listInitializer:
1073 if(inCompiler && outputLineNumbers && initializer.loc.start.line)
1075 /*if(initializer.loc.start.line == 1)
1078 f.Printf("\n#line %d \"%s\"\n", initializer.loc.start.line, name);
1082 for(init = initializer.list->first; init; init = init.next)
1084 OutputInitializer(init, f);
1085 if(init.next) f.Puts(", ");
1089 if(inCompiler && outputLineNumbers && initializer.loc.start.line)
1091 /*if(initializer.loc.start.line == 1)
1094 f.Printf("\n#line %d \"%s\"\n", initializer.loc.start.line, name);
1101 case expInitializer:
1103 OutputExpression(initializer.exp, f);
1108 static void OutputInitDeclarator(InitDeclarator decl, File f)
1110 OutputDeclarator(decl.declarator, f);
1111 if(decl.initializer)
1114 OutputInitializer(decl.initializer, f);
1118 static void OutputDeclaration(Declaration decl, File f)
1121 char origName[MAX_FILENAME] = "";
1125 case initDeclaration:
1129 //GetWorkingDir(origName, sizeof(origName));
1132 PathCat(origName, outputFile);
1133 ChangeCh(origName, '\\', '/');
1136 if(decl.declarators && decl.declarators->first)
1138 for(d = decl.declarators->first; d; d = d.next)
1141 char name[MAX_FILENAME] = "";
1144 GetLastDirectory(sourceFile, name);
1147 if(yylloc.start.included)
1149 //GetWorkingDir(name, sizeof(name));
1150 PathCat(name, GetIncludeFileFromID(yylloc.start.included));
1154 //GetWorkingDir(name, sizeof(name));
1155 PathCat(name, sourceFile);
1157 ChangeCh(name, '\\', '/');
1159 if(inCompiler && outputLineNumbers && decl.loc.start.line)
1161 /*if(decl.loc.start.line == 1)
1164 f.Printf("\n#line %d \"%s\"\n", decl.loc.start.line, name);
1173 for(spec = decl.specifiers->first; spec; spec = spec.next)
1175 OutputSpecifier(spec, f);
1176 if(spec.next) f.Puts(" ");
1179 if(decl.declarators && decl.declarators->first)
1183 for(d = decl.declarators->first; d; d = d.next)
1185 OutputInitDeclarator(d, f);
1186 if(d.next) f.Puts(", ");
1191 case structDeclaration:
1195 for(spec = decl.specifiers->first; spec; spec = spec.next)
1197 OutputSpecifier(spec, f);
1198 if(spec.next) f.Puts(" ");
1201 if(decl.declarators)
1206 for(d = decl.declarators->first; d; d = d.next)
1208 OutputDeclarator(d, f);
1209 if(d.next) f.Puts(", ");
1215 OutputSpecifier(decl.extStorage, f);
1219 case instDeclaration:
1222 OutputInstance(decl.inst, f);
1225 case defineDeclaration:
1226 return; // Skip semicolon
1230 if(inCompiler && outputLineNumbers && decl.loc.start.line && decl.type == initDeclaration)
1232 f.Printf("\n#line %d \"%s\"\n", outputLine+2, origName);
1237 static FunctionDefinition curFunction;
1239 static void OutputFunction(FunctionDefinition func, File f)
1241 FunctionDefinition oldFunc = curFunction;
1246 for(spec = func.specifiers->first; spec; spec = spec.next)
1248 OutputSpecifier(spec, f);
1249 if(spec.next) f.Puts(" ");
1253 if(func.declarator) OutputDeclarator(func.declarator, f);
1256 if(func.declarations)
1259 for(decl = func.declarations->first; decl; decl = decl.next)
1261 OutputDeclaration(decl, f);
1268 if(inCompiler && memoryGuard)
1270 char name[1024] = "";
1271 Identifier id = GetDeclId(func.declarator);
1273 if(yylloc.start.included)
1275 //GetWorkingDir(name, sizeof(name));
1276 PathCat(name, GetIncludeFileFromID(yylloc.start.included));
1280 //GetWorkingDir(name, sizeof(name));
1281 PathCat(name, sourceFile);
1283 ChangeCh(name, '\\', '/');
1286 f.Printf(" __ecereNameSpace__ecere__com__MemoryGuard_PushLoc(\"%s:%s\");\n", name, id.string);
1289 OutputStatement(func.body, f);
1290 if(inCompiler && memoryGuard)
1292 f.Printf(" __ecereNameSpace__ecere__com__MemoryGuard_PopLoc();\n");
1299 curFunction = oldFunc;
1302 static void OutputMemberInit(MemberInit init, File f)
1304 if(init.identifiers)
1306 if(init.identifiers->count > 1)
1310 for(id = init.identifiers->first; id; id = id.next)
1312 OutputIdentifier(id, f);
1318 else if(init.identifiers->first)
1319 OutputIdentifier(init.identifiers->first, f);
1322 if(init.initializer)
1323 OutputInitializer(init.initializer, f);
1326 static void OutputMembersInit(MembersInit init, File f)
1330 case dataMembersInit:
1333 if(init.dataMembers)
1335 for(member = init.dataMembers->first; member; member = member.next)
1337 OutputMemberInit(member, f);
1338 if(member.next) f.Puts(", ");
1343 case methodMembersInit:
1344 OutputClassFunction(init.function, f);
1349 static void OutputInstance(Instantiation inst, File f)
1352 OutputSpecifier(inst._class, f);
1356 OutputExpression(inst.exp, f);
1358 if(inst.members && inst.members->count > 1)
1363 else if(inst.members)
1370 for(init = inst.members->first; init; init = init.next)
1372 OutputMembersInit(init, f);
1373 if(init.type == dataMembersInit && init.next)
1386 static void OutputClassFunction(ClassFunction func, File f)
1391 for(spec = func.specifiers->first; spec; spec = spec.next)
1393 OutputSpecifier(spec, f);
1394 if(spec.next) f.Puts(" ");
1400 //if(func.class != (void *)-1)
1402 OutputSpecifier(func.class, f);
1405 if(func.declarator) OutputDeclarator(func.declarator, f);
1408 if(func.declarations)
1411 for(decl = func.declarations->first; decl; decl = decl.next)
1413 OutputDeclaration(decl, f);
1420 OutputStatement(func.body, f);
1428 static void OutputClassDef(ClassDef def, File f)
1432 case declarationClassDef:
1435 OutputDeclaration(def.decl, f);
1436 if(def.next && def.next.type != declarationClassDef)
1443 case defaultPropertiesClassDef:
1446 for(init = def.defProperties->first; init; init = init.next)
1448 OutputMemberInit(init, f);
1449 if(init.next) f.Puts(", ");
1455 case functionClassDef:
1456 OutputClassFunction(def.function, f);
1463 static void OutputClass(ClassDefinition _class, File f)
1466 OutputSpecifier(_class._class, f);
1467 if(_class.baseSpecs)
1472 for(spec = _class.baseSpecs->first; spec; spec = spec.next)
1474 OutputSpecifier(spec, f);
1477 if(_class.definitions)
1482 for(def = _class.definitions->first; def; def = def.next)
1484 OutputClassDef(def, f);
1493 public void OutputTree(OldList ast, File f)
1499 for(external = ast.first; external; external = external.next)
1501 switch(external.type)
1503 case functionExternal:
1504 OutputFunction(external.function, f);
1508 case declarationExternal:
1509 OutputDeclaration(external.declaration, f);
1514 OutputClass(external._class, f);
1522 public char * StringFromSpecDecl(OldList specs, Declarator decl)
1525 TypeName typeName { };
1526 File f = TempFile { };
1529 typeName.qualifiers = specs;
1530 typeName.declarator = decl;
1532 OutputTypeName(typeName, f);
1537 string = new char[size + 1];
1539 f.Read(string, 1, size);
1540 string[size] = '\0';
1541 TrimRSpaces(string, string);