public static string Generate(Core.Session session) { var gen = new CGenerator(); gen.session = session; gen.GatherItems(); gen.RegisterStructDependencies(); gen.RegisterFunctDependencies(); var sortedItems = gen.itemGraph.GetTopologicalSort(); var result = ""; result += "typedef char Bool;\n"; result += "typedef int Int;\n"; result += "typedef unsigned int UInt;\n"; result += "\n"; for (var i = 0; i < sortedItems.Count; i++) { var item = sortedItems[i]; switch (item.kind) { case Item.Kind.StructHeader: result += gen.GenerateStructDecl(item.index); break; case Item.Kind.Struct: result += gen.GenerateStructDef(item.index); break; case Item.Kind.FunctHeader: result += gen.GenerateFunctDecl(item.index); break; case Item.Kind.Funct: result += gen.GenerateFunctDef(item.index); break; } } /*result += gen.GenerateFunctDecls() + "\n"; * result += gen.GenerateFunctDefs() + "\n";*/ return(result); }
public static string Generate(Core.Session session) { var gen = new CGenerator(); gen.session = session; gen.GatherItems(); gen.RegisterStructDependencies(); gen.RegisterFunctDependencies(); var sortedItems = gen.itemGraph.GetTopologicalSort(); var result = ""; result += "typedef char Bool;\n"; result += "typedef int Int;\n"; result += "typedef unsigned int UInt;\n"; result += "\n"; for (var i = 0; i < sortedItems.Count; i++) { var item = sortedItems[i]; switch (item.kind) { case Item.Kind.StructHeader: result += gen.GenerateStructDecl(item.index); break; case Item.Kind.Struct: result += gen.GenerateStructDef(item.index); break; case Item.Kind.FunctHeader: result += gen.GenerateFunctDecl(item.index); break; case Item.Kind.Funct: result += gen.GenerateFunctDef(item.index); break; } } /*result += gen.GenerateFunctDecls() + "\n"; result += gen.GenerateFunctDefs() + "\n";*/ return result; }