2019-08-31 15:56:36 +03:00
|
|
|
[CodeGen::Inspection::] Inspect Plugs.
|
|
|
|
|
|
|
|
To make sure certain symbol names translate into globally unique target symbols.
|
|
|
|
|
|
|
|
@h Pipeline stage.
|
|
|
|
|
|
|
|
=
|
|
|
|
void CodeGen::Inspection::create_pipeline_stage(void) {
|
|
|
|
CodeGen::Stage::new(I"inspect-plugs", CodeGen::Inspection::run_pipeline_stage, NO_STAGE_ARG, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
int CodeGen::Inspection::run_pipeline_stage(pipeline_step *step) {
|
|
|
|
Inter::Connectors::stecker(step->repository);
|
|
|
|
int resolution_failed = FALSE;
|
2021-04-16 00:42:28 +03:00
|
|
|
InterTree::traverse(step->repository, CodeGen::Inspection::visitor, &resolution_failed, NULL, PACKAGE_IST);
|
2019-08-31 15:56:36 +03:00
|
|
|
if (resolution_failed) internal_error("loose plug(s)");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CodeGen::Inspection::visitor(inter_tree *I, inter_tree_node *P, void *state) {
|
|
|
|
int *fail_flag = (int *) state;
|
|
|
|
inter_package *Q = Inter::Package::defined_by_frame(P);
|
|
|
|
if (Site::connectors_package(I) == Q) return;
|
|
|
|
inter_symbols_table *ST = Inter::Packages::scope(Q);
|
|
|
|
for (int i=0; i<ST->size; i++) {
|
|
|
|
inter_symbol *S = ST->symbol_array[i];
|
|
|
|
if ((S) && (S->equated_to) && (Inter::Symbols::get_scope(S->equated_to) == PLUG_ISYMS)) {
|
2019-09-01 13:50:12 +03:00
|
|
|
if (!(Inter::Symbols::get_flag(S->equated_to, ERROR_ISSUED_MARK_BIT))) {
|
|
|
|
Inter::Symbols::set_flag(S->equated_to, ERROR_ISSUED_MARK_BIT);
|
|
|
|
LOG("$3 == $3 which is a loose plug, seeking %S\n", S, S->equated_to, S->equated_to->equated_name);
|
|
|
|
WRITE_TO(STDERR, "Failed to connect plug to: %S\n", S->equated_to->equated_name);
|
|
|
|
if (fail_flag) *fail_flag = TRUE;
|
|
|
|
}
|
2019-08-31 15:56:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|