git-svn-id: svn://db.shs.com.ru/pip@553 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2017-11-17 11:54:54 +00:00
parent 606261c38d
commit 6cbe77c5b6
7 changed files with 121 additions and 36 deletions

View File

@@ -54,8 +54,14 @@ void usage() {
void makeClassInfo(PIFile & f, const PICodeParser::Entity * e) {
f << "\n\tci = new ClassInfo();\n";
f << "\t(*classesInfo)[\"" << e->name << "\"] = ci;\n";
f << "\tci->type = \"" << e->type << "\";\n";
f << "\tci->name = \"" << e->name << "\";\n";
f << "\tci->has_name = " << (e->has_name ? "true" : "false") << ";\n";
f << "\t(*classesInfo)[ci->name] = ci;\n";
if (e->parent_scope) {
f << "\tpci = " << "classesInfo->value(\"" << e->parent_scope->name << "\", 0);\n";
f << "\tif (pci) pci->children_info << ci;\n";
}
piForeachC (PICodeParser::Entity * p, e->parents)
f << "\tci->parents << \"" << p->name << "\";\n";
piForeachC (PICodeParser::Member & m, e->members) {
@@ -63,13 +69,18 @@ void makeClassInfo(PIFile & f, const PICodeParser::Entity * e) {
if (m.attributes != 0) {
bool fir = true;
f << ", ";
if (m.attributes[PICodeParser::Const]) {if (fir) fir = false; else f << " | "; f << "Const";}
if (m.attributes[PICodeParser::Static]) {if (fir) fir = false; else f << " | "; f << "Static";}
if (m.attributes[PICodeParser::Mutable]) {if (fir) fir = false; else f << " | "; f << "Mutable";}
if (m.attributes[PICodeParser::Const ]) {if (fir) fir = false; else f << " | "; f << "Const";}
if (m.attributes[PICodeParser::Static ]) {if (fir) fir = false; else f << " | "; f << "Static";}
if (m.attributes[PICodeParser::Mutable ]) {if (fir) fir = false; else f << " | "; f << "Mutable";}
if (m.attributes[PICodeParser::Volatile]) {if (fir) fir = false; else f << " | "; f << "Volatile";}
if (m.attributes[PICodeParser::Inline]) {if (fir) fir = false; else f << " | "; f << "Inline";}
if (m.attributes[PICodeParser::Virtual]) {if (fir) fir = false; else f << " | "; f << "Virtual";}
if (m.attributes[PICodeParser::Inline ]) {if (fir) fir = false; else f << " | "; f << "Inline";}
if (m.attributes[PICodeParser::Virtual ]) {if (fir) fir = false; else f << " | "; f << "Virtual";}
} else {
if (m.isBitfield())
f << ", 0";
}
if (m.isBitfield())
f << ", " << m.bits;
f << ");\n";
}
PIString arg;
@@ -81,7 +92,7 @@ void makeClassInfo(PIFile & f, const PICodeParser::Entity * e) {
if (m.attributes[PICodeParser::Const] || m.attributes[PICodeParser::Static]) {
bool fir = true;
f << ", ";
if (m.attributes[PICodeParser::Const]) {if (fir) fir = false; else f << " | "; f << "Const";}
if (m.attributes[PICodeParser::Const ]) {if (fir) fir = false; else f << " | "; f << "Const";}
if (m.attributes[PICodeParser::Static]) {if (fir) fir = false; else f << " | "; f << "Static";}
}
f << ");\n";
@@ -224,8 +235,10 @@ void writeModel(PICodeParser & parser, PICLI & cli, const PIString out, bool met
if (meta || enums) {
f << "\n\n// Metainformation\n\n__ClassInfo_" << defname << "_Initializer__::__ClassInfo_" << defname << "_Initializer__() {\n";
f << "\tif (_inited_) return;\n\t_inited_ = true;\n\n";
if (meta)
f << "\tClassInfo * ci;\n\tTypeInfo * ni;\n\tFunctionInfo * fi;\n";
if (meta) {
f << "\tClassInfo * ci, * pci = new ClassInfo();\n\tTypeInfo * ni;\n\tFunctionInfo * fi;\n";
f << "\t(*classesInfo)[\"\"] = pci;\n";
}
if (enums) {
f << "\tEnumInfo * ei;\n";
f << "\t(*enumsInfo)[\"\"] = new EnumInfo();\n";
@@ -327,9 +340,9 @@ int main(int argc, char * argv[]) {
piCout << Cyan << Bold << "Writing code model ...";
bool all = cli.hasArgument("All");
writeModel(parser, cli, cli.argumentValue("output"), cli.hasArgument("Metainfo") || all,
cli.hasArgument("Enum") || all,
cli.hasArgument("Stream") || all,
cli.hasArgument("Text") || all);
cli.hasArgument("Enum") || all,
cli.hasArgument("Stream") || all,
cli.hasArgument("Text") || all);
piCout << Cyan << Bold << "Writing done";
if (cli.hasArgument("print") || cli.hasArgument("Print")) {
bool womain = cli.hasArgument("print");