2019-06-28 20:25:50 +03:00
|
|
|
[CodeGen::Inventory::] Final Inventory.
|
2019-04-23 01:29:02 +03:00
|
|
|
|
|
|
|
To print a summary of the contents of a repository.
|
|
|
|
|
2019-06-28 20:25:50 +03:00
|
|
|
@ This target is fairly simple: when we get the message to begin generation,
|
|
|
|
we simply ask the Inter module to output some text, and return true to
|
|
|
|
tell the generator that nothing more need be done.
|
2019-06-11 01:06:40 +03:00
|
|
|
|
|
|
|
=
|
2019-06-28 20:25:50 +03:00
|
|
|
void CodeGen::Inventory::create_target(void) {
|
|
|
|
code_generation_target *inv_cgt = CodeGen::Targets::new(I"inventory");
|
|
|
|
METHOD_ADD(inv_cgt, BEGIN_GENERATION_MTID, CodeGen::Inventory::inv);
|
2019-06-11 01:06:40 +03:00
|
|
|
}
|
|
|
|
|
2019-06-28 20:25:50 +03:00
|
|
|
int CodeGen::Inventory::inv(code_generation_target *cgt, code_generation *gen) {
|
|
|
|
if (gen->from_step == NULL) internal_error("temporary generations cannot be output");
|
2019-07-13 16:17:48 +03:00
|
|
|
|
2021-04-16 00:42:28 +03:00
|
|
|
InterTree::traverse(gen->from, CodeGen::Inventory::visitor,
|
2019-07-13 19:15:26 +03:00
|
|
|
gen->from_step->text_out_file, gen->just_this_package, 0);
|
2019-06-11 01:06:40 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-04-19 00:42:39 +03:00
|
|
|
void CodeGen::Inventory::inv_to(OUTPUT_STREAM, inter_tree *I) {
|
|
|
|
InterTree::traverse(I, CodeGen::Inventory::visitor, OUT, NULL, 0);
|
|
|
|
}
|
|
|
|
|
2019-07-24 20:15:07 +03:00
|
|
|
void CodeGen::Inventory::visitor(inter_tree *I, inter_tree_node *P, void *state) {
|
2019-07-13 16:17:48 +03:00
|
|
|
text_stream *OUT = (text_stream *) state;
|
2019-07-24 20:15:07 +03:00
|
|
|
if (P->W.data[ID_IFLD] == PACKAGE_IST) {
|
2019-07-13 16:17:48 +03:00
|
|
|
inter_package *from = Inter::Package::defined_by_frame(P);
|
2019-06-29 19:36:49 +03:00
|
|
|
inter_symbol *ptype = Inter::Packages::type(from);
|
2019-07-13 16:17:48 +03:00
|
|
|
|
2019-06-29 19:36:49 +03:00
|
|
|
if (Str::eq(ptype->symbol_name, I"_module")) {
|
2019-07-26 12:14:17 +03:00
|
|
|
WRITE("Module '%S'\n", Inter::Packages::name(from));
|
2021-04-25 15:23:45 +03:00
|
|
|
text_stream *title = Metadata::read_optional_textual(from, I"^title");
|
2019-06-29 19:36:49 +03:00
|
|
|
if (title) WRITE("From extension '%S by %S' version %S\n", title,
|
2021-04-25 15:23:45 +03:00
|
|
|
Metadata::read_textual(from, I"^author"),
|
|
|
|
Metadata::read_textual(from, I"^version"));
|
2019-07-13 16:17:48 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Str::eq(ptype->symbol_name, I"_submodule")) {
|
|
|
|
int contents = 0;
|
|
|
|
LOOP_THROUGH_INTER_CHILDREN(C, P) contents++;
|
|
|
|
if (contents > 0) {
|
2021-04-19 00:42:39 +03:00
|
|
|
WRITE(" %S:\n", Inter::Packages::name(from));
|
|
|
|
INDENT;
|
2019-06-29 19:36:49 +03:00
|
|
|
INDENT;
|
2019-07-13 16:17:48 +03:00
|
|
|
Inter::Packages::unmark_all();
|
|
|
|
LOOP_THROUGH_INTER_CHILDREN(C, P) {
|
2019-07-24 20:15:07 +03:00
|
|
|
if (C->W.data[ID_IFLD] == PACKAGE_IST) {
|
2019-07-13 16:17:48 +03:00
|
|
|
inter_package *R = Inter::Package::defined_by_frame(C);
|
2019-07-26 21:20:27 +03:00
|
|
|
if (Inter::Packages::get_flag(R, MARK_PACKAGE_FLAG)) continue;
|
2019-07-13 16:17:48 +03:00
|
|
|
inter_symbol *ptype = Inter::Packages::type(R);
|
|
|
|
OUTDENT;
|
|
|
|
WRITE(" %S ", ptype->symbol_name);
|
|
|
|
int N = 0;
|
|
|
|
LOOP_THROUGH_INTER_CHILDREN(D, P) {
|
2019-07-24 20:15:07 +03:00
|
|
|
if (D->W.data[ID_IFLD] == PACKAGE_IST) {
|
2019-07-13 16:17:48 +03:00
|
|
|
inter_package *R2 = Inter::Package::defined_by_frame(D);
|
|
|
|
if (Inter::Packages::type(R2) == ptype) N++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
WRITE("x %d: ", N);
|
|
|
|
INDENT;
|
|
|
|
int pos = Str::len(ptype->symbol_name) + 7;
|
|
|
|
int first = TRUE;
|
|
|
|
LOOP_THROUGH_INTER_CHILDREN(D, P) {
|
2019-07-24 20:15:07 +03:00
|
|
|
if (D->W.data[ID_IFLD] == PACKAGE_IST) {
|
2019-07-13 16:17:48 +03:00
|
|
|
inter_package *R2 = Inter::Package::defined_by_frame(D);
|
|
|
|
if (Inter::Packages::type(R2) == ptype) {
|
2021-04-25 15:23:45 +03:00
|
|
|
text_stream *name = Metadata::read_optional_textual(R2, I"^name");
|
2019-07-26 12:14:17 +03:00
|
|
|
if (name == NULL) name = Inter::Packages::name(R2);
|
2019-07-13 16:17:48 +03:00
|
|
|
if ((pos > 0) && (first == FALSE)) WRITE(", ");
|
|
|
|
pos += Str::len(name) + 2;
|
|
|
|
if (pos > 80) { WRITE("\n"); pos = Str::len(name) + 2; }
|
|
|
|
WRITE("%S", name);
|
2019-07-26 21:20:27 +03:00
|
|
|
Inter::Packages::set_flag(R2, MARK_PACKAGE_FLAG);
|
2019-07-13 16:17:48 +03:00
|
|
|
first = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2019-04-24 01:31:35 +03:00
|
|
|
}
|
2019-07-13 16:17:48 +03:00
|
|
|
if (pos > 0) WRITE("\n");
|
2019-04-24 01:31:35 +03:00
|
|
|
}
|
2019-06-29 19:36:49 +03:00
|
|
|
}
|
2019-07-13 16:17:48 +03:00
|
|
|
Inter::Packages::unmark_all();
|
2019-06-29 19:36:49 +03:00
|
|
|
OUTDENT;
|
2021-04-19 00:42:39 +03:00
|
|
|
OUTDENT;
|
2019-04-23 11:25:00 +03:00
|
|
|
}
|
2019-07-13 16:17:48 +03:00
|
|
|
return;
|
2019-04-23 01:29:02 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|