2022-02-03 21:44:57 +02:00
|
|
|
[InterSymbol::] Symbols.
|
2019-02-05 02:44:07 +02:00
|
|
|
|
|
|
|
To manage named symbols in inter code.
|
|
|
|
|
|
|
|
@h Symbols themselves.
|
|
|
|
|
|
|
|
=
|
|
|
|
typedef struct inter_symbol {
|
2020-07-01 02:58:55 +03:00
|
|
|
inter_ti symbol_ID;
|
2019-02-05 02:44:07 +02:00
|
|
|
struct inter_symbols_table *owning_table;
|
|
|
|
struct text_stream *symbol_name;
|
2019-07-24 20:15:07 +03:00
|
|
|
struct inter_tree_node *definition;
|
2022-01-04 01:40:23 +02:00
|
|
|
struct wiring_data wiring;
|
2019-07-26 10:59:23 +03:00
|
|
|
int symbol_status;
|
|
|
|
struct inter_annotation_set ann_set;
|
2019-02-05 02:44:07 +02:00
|
|
|
struct text_stream *translate_text;
|
2019-08-02 20:51:21 +03:00
|
|
|
int link_time;
|
|
|
|
struct inter_symbol *linked_to;
|
2021-08-06 21:48:18 +03:00
|
|
|
struct general_pointer translation_data;
|
2019-02-05 02:44:07 +02:00
|
|
|
} inter_symbol;
|
|
|
|
|
|
|
|
@ =
|
2022-02-03 21:44:57 +02:00
|
|
|
inter_symbol *InterSymbol::new(text_stream *name, inter_symbols_table *T, inter_ti ID) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (Str::len(name) == 0) internal_error("symbol cannot have empty text as identifier");
|
|
|
|
inter_symbol *symb = CREATE(inter_symbol);
|
|
|
|
symb->owning_table = T;
|
|
|
|
symb->symbol_ID = ID;
|
2019-07-26 10:59:23 +03:00
|
|
|
symb->symbol_status = 0;
|
2022-02-03 21:44:57 +02:00
|
|
|
InterSymbol::set_type(symb, MISC_ISYMT);
|
|
|
|
InterSymbol::set_scope(symb, PUBLIC_ISYMS);
|
2019-02-05 02:44:07 +02:00
|
|
|
symb->symbol_name = Str::duplicate(name);
|
2022-02-03 21:44:57 +02:00
|
|
|
InterSymbol::undefine(symb);
|
2019-07-26 10:59:23 +03:00
|
|
|
symb->ann_set = Inter::Annotations::new_set();
|
2022-01-04 01:40:23 +02:00
|
|
|
symb->wiring = Wiring::new_wiring_data(symb);
|
2019-02-05 02:44:07 +02:00
|
|
|
symb->translate_text = NULL;
|
2019-08-02 20:51:21 +03:00
|
|
|
symb->link_time = 0;
|
|
|
|
symb->linked_to = NULL;
|
2021-08-06 21:48:18 +03:00
|
|
|
symb->translation_data = NULL_GENERAL_POINTER;
|
2021-04-25 15:23:45 +03:00
|
|
|
if (Metadata::valid_key(name)) {
|
2022-02-03 21:44:57 +02:00
|
|
|
InterSymbol::set_flag(symb, METADATA_KEY_BIT);
|
|
|
|
InterSymbol::set_scope(symb, PRIVATE_ISYMS);
|
2021-04-25 01:35:10 +03:00
|
|
|
}
|
2019-02-05 02:44:07 +02:00
|
|
|
LOGIF(INTER_SYMBOLS, "Created symbol $3 in $4\n", symb, T);
|
|
|
|
|
|
|
|
return symb;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
inter_package *InterSymbol::package(inter_symbol *S) {
|
2022-02-03 17:51:44 +02:00
|
|
|
if (S == NULL) return NULL;
|
|
|
|
return InterSymbolsTable::package(S->owning_table);
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::is_metadata_key(inter_symbol *S) {
|
|
|
|
return InterSymbol::get_flag(S, METADATA_KEY_BIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
int InterSymbol::get_type(inter_symbol *S) {
|
2019-07-26 10:59:23 +03:00
|
|
|
return S->symbol_status & SYMBOL_TYPE_MASK_ISYMT;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::get_scope(inter_symbol *S) {
|
2019-07-26 10:59:23 +03:00
|
|
|
return S->symbol_status & SYMBOL_SCOPE_MASK_ISYMT;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::set_type(inter_symbol *S, int V) {
|
2019-07-26 10:59:23 +03:00
|
|
|
S->symbol_status = S->symbol_status - (S->symbol_status & SYMBOL_TYPE_MASK_ISYMT) + V;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::set_scope(inter_symbol *S, int V) {
|
2019-07-26 10:59:23 +03:00
|
|
|
S->symbol_status = S->symbol_status - (S->symbol_status & SYMBOL_SCOPE_MASK_ISYMT) + V;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::log(OUTPUT_STREAM, void *vs) {
|
2019-02-05 02:44:07 +02:00
|
|
|
inter_symbol *S = (inter_symbol *) vs;
|
|
|
|
if (S == NULL) WRITE("<no-symbol>");
|
2019-04-09 18:09:53 +03:00
|
|
|
else {
|
2022-02-03 17:51:44 +02:00
|
|
|
InterSymbolsTable::write_symbol_URL(DL, S);
|
2019-04-09 18:09:53 +03:00
|
|
|
WRITE("{%d}", S->symbol_ID - SYMBOL_BASE_VAL);
|
2019-04-10 04:13:29 +03:00
|
|
|
if (Str::len(S->translate_text) > 0) WRITE("'%S'", S->translate_text);
|
2019-04-09 18:09:53 +03:00
|
|
|
}
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::sort_number(const inter_symbol *S) {
|
2019-07-26 10:59:23 +03:00
|
|
|
if (S == NULL) return 0;
|
|
|
|
return 100000 * (S->owning_table->allocation_id) + (int) (S->symbol_ID);
|
|
|
|
}
|
|
|
|
|
2019-02-05 02:44:07 +02:00
|
|
|
@ =
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::is_stored_in_data(inter_ti val1, inter_ti val2) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (val1 == ALIAS_IVAL) return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::to_data(inter_tree *I, inter_package *pack, inter_symbol *S, inter_ti *val1, inter_ti *val2) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (S == NULL) internal_error("no symbol");
|
2022-02-03 17:51:44 +02:00
|
|
|
*val1 = ALIAS_IVAL; *val2 = InterSymbolsTable::id_from_symbol(I, pack, S);
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@ =
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::write_declaration(OUTPUT_STREAM, inter_symbol *mark, int N) {
|
2019-02-05 02:44:07 +02:00
|
|
|
for (int L=0; L<N; L++) WRITE("\t");
|
|
|
|
WRITE("symbol ");
|
2022-02-03 21:44:57 +02:00
|
|
|
switch (InterSymbol::get_scope(mark)) {
|
2019-02-05 02:44:07 +02:00
|
|
|
case PRIVATE_ISYMS: WRITE("private"); break;
|
|
|
|
case PUBLIC_ISYMS: WRITE("public"); break;
|
|
|
|
case EXTERNAL_ISYMS: WRITE("external"); break;
|
2019-08-04 14:19:47 +03:00
|
|
|
case PLUG_ISYMS: WRITE("plug"); break;
|
|
|
|
case SOCKET_ISYMS: WRITE("socket"); break;
|
2019-02-05 02:44:07 +02:00
|
|
|
default: internal_error("unknown symbol type"); break;
|
|
|
|
}
|
|
|
|
WRITE(" ");
|
2022-02-03 21:44:57 +02:00
|
|
|
switch (InterSymbol::get_type(mark)) {
|
2019-02-05 02:44:07 +02:00
|
|
|
case LABEL_ISYMT: WRITE("label"); break;
|
|
|
|
case MISC_ISYMT: WRITE("misc"); break;
|
|
|
|
case PACKAGE_ISYMT: WRITE("package"); break;
|
|
|
|
case PTYPE_ISYMT: WRITE("packagetype"); break;
|
|
|
|
default: internal_error("unknown symbol type"); break;
|
|
|
|
}
|
|
|
|
WRITE(" %S", mark->symbol_name);
|
2022-02-03 21:44:57 +02:00
|
|
|
if (InterSymbol::get_flag(mark, MAKE_NAME_UNIQUE)) WRITE("*");
|
2022-01-04 01:40:23 +02:00
|
|
|
if (Wiring::is_wired_to_name(mark)) {
|
|
|
|
WRITE(" --? %S", Wiring::wired_to_name(mark));
|
2019-08-04 14:19:47 +03:00
|
|
|
}
|
2022-02-03 21:44:57 +02:00
|
|
|
text_stream *trans_name = InterSymbol::get_translate(mark);
|
2019-08-04 14:19:47 +03:00
|
|
|
if (Str::len(trans_name) > 0)
|
|
|
|
WRITE(" `%S`", trans_name);
|
2022-01-04 01:40:23 +02:00
|
|
|
if (Wiring::is_wired(mark)) {
|
2019-08-04 14:19:47 +03:00
|
|
|
WRITE(" --> ");
|
2022-02-03 17:51:44 +02:00
|
|
|
InterSymbolsTable::write_symbol_URL(OUT, Wiring::wired_to(mark));
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::define(inter_symbol *S, inter_tree_node *P) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (S == NULL) internal_error("tried to define null symbol");
|
|
|
|
S->definition = P;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
inter_tree_node *InterSymbol::definition(inter_symbol *S) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (S == NULL) internal_error("tried to find definition of null symbol");
|
|
|
|
return S->definition;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::is_defined(inter_symbol *S) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (S == NULL) return FALSE;
|
2022-02-03 21:44:57 +02:00
|
|
|
if (InterSymbol::definition(S)) return TRUE;
|
2019-02-05 02:44:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::evaluate_to_int(inter_symbol *S) {
|
|
|
|
inter_tree_node *P = InterSymbol::definition(S);
|
2019-07-24 17:19:38 +03:00
|
|
|
if ((P) &&
|
2022-01-30 15:32:38 +02:00
|
|
|
(P->W.instruction[ID_IFLD] == CONSTANT_IST) &&
|
|
|
|
(P->W.instruction[FORMAT_CONST_IFLD] == CONSTANT_DIRECT) &&
|
|
|
|
(P->W.instruction[DATA_CONST_IFLD] == LITERAL_IVAL)) {
|
|
|
|
return (int) P->W.instruction[DATA_CONST_IFLD + 1];
|
2019-05-05 16:54:24 +03:00
|
|
|
}
|
2019-07-24 17:19:38 +03:00
|
|
|
if ((P) &&
|
2022-01-30 15:32:38 +02:00
|
|
|
(P->W.instruction[ID_IFLD] == CONSTANT_IST) &&
|
|
|
|
(P->W.instruction[FORMAT_CONST_IFLD] == CONSTANT_DIRECT) &&
|
|
|
|
(P->W.instruction[DATA_CONST_IFLD] == ALIAS_IVAL)) {
|
2019-05-05 16:54:24 +03:00
|
|
|
inter_symbols_table *scope = S->owning_table;
|
2022-02-03 17:51:44 +02:00
|
|
|
inter_symbol *alias_to = InterSymbolsTable::symbol_from_ID(scope, P->W.instruction[DATA_CONST_IFLD + 1]);
|
2022-02-03 21:44:57 +02:00
|
|
|
return InterSymbol::evaluate_to_int(alias_to);
|
2019-05-05 16:54:24 +03:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::set_int(inter_symbol *S, int N) {
|
|
|
|
inter_tree_node *P = InterSymbol::definition(S);
|
2021-05-03 16:39:21 +03:00
|
|
|
if ((P) &&
|
2022-01-30 15:32:38 +02:00
|
|
|
(P->W.instruction[ID_IFLD] == CONSTANT_IST) &&
|
|
|
|
(P->W.instruction[FORMAT_CONST_IFLD] == CONSTANT_DIRECT) &&
|
|
|
|
(P->W.instruction[DATA_CONST_IFLD] == LITERAL_IVAL)) {
|
|
|
|
P->W.instruction[DATA_CONST_IFLD + 1] = (inter_ti) N;
|
2021-05-03 16:39:21 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((P) &&
|
2022-01-30 15:32:38 +02:00
|
|
|
(P->W.instruction[ID_IFLD] == CONSTANT_IST) &&
|
|
|
|
(P->W.instruction[FORMAT_CONST_IFLD] == CONSTANT_DIRECT) &&
|
|
|
|
(P->W.instruction[DATA_CONST_IFLD] == ALIAS_IVAL)) {
|
2021-05-03 16:39:21 +03:00
|
|
|
inter_symbols_table *scope = S->owning_table;
|
2022-02-03 17:51:44 +02:00
|
|
|
inter_symbol *alias_to = InterSymbolsTable::symbol_from_ID(scope, P->W.instruction[DATA_CONST_IFLD + 1]);
|
2022-02-03 21:44:57 +02:00
|
|
|
InterSymbol::set_int(alias_to, N);
|
2021-05-03 16:39:21 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (P == NULL) LOG("Synbol $3 is undefined\n", S);
|
|
|
|
LOG("Synbol $3 cannot be set to %d\n", S, N);
|
|
|
|
internal_error("unable to set symbol");
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::strike_definition(inter_symbol *S) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (S) {
|
2022-02-03 21:44:57 +02:00
|
|
|
inter_tree_node *D = InterSymbol::definition(S);
|
2022-01-27 01:59:02 +02:00
|
|
|
if (D) NodePlacement::remove(D);
|
2022-02-03 21:44:57 +02:00
|
|
|
InterSymbol::undefine(S);
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::undefine(inter_symbol *S) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (S == NULL) internal_error("tried to undefine null symbol");
|
2019-07-24 17:19:38 +03:00
|
|
|
S->definition = NULL;
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::clear_transient_flags(inter_symbol *symb) {
|
2019-07-26 10:59:23 +03:00
|
|
|
symb->symbol_status = (symb->symbol_status) & NONTRANSIENT_SYMBOL_BITS;
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::get_flag(inter_symbol *symb, int f) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (symb == NULL) internal_error("no symbol");
|
2019-07-26 10:59:23 +03:00
|
|
|
return (symb->symbol_status & f)?TRUE:FALSE;
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::set_flag(inter_symbol *symb, int f) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (symb == NULL) internal_error("no symbol");
|
2019-07-26 10:59:23 +03:00
|
|
|
symb->symbol_status = symb->symbol_status | f;
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::clear_flag(inter_symbol *symb, int f) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (symb == NULL) internal_error("no symbol");
|
2019-07-26 10:59:23 +03:00
|
|
|
if (symb->symbol_status & f) symb->symbol_status = symb->symbol_status - f;
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::set_translate(inter_symbol *symb, text_stream *S) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (symb == NULL) internal_error("no symbol");
|
|
|
|
symb->translate_text = Str::duplicate(S);
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
text_stream *InterSymbol::get_translate(inter_symbol *symb) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (symb == NULL) internal_error("no symbol");
|
|
|
|
return symb->translate_text;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::annotate(inter_symbol *symb, inter_annotation IA) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (symb == NULL) internal_error("annotated null symbol");
|
2019-07-26 10:59:23 +03:00
|
|
|
Inter::Annotations::add_to_set(&(symb->ann_set), IA);
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::unannotate(inter_symbol *symb, inter_ti annot_ID) {
|
2021-04-22 20:47:42 +03:00
|
|
|
if (symb == NULL) internal_error("annotated null symbol");
|
|
|
|
Inter::Annotations::remove_from_set(&(symb->ann_set), annot_ID);
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::annotate_i(inter_symbol *symb, inter_ti annot_ID, inter_ti n) {
|
2019-07-26 10:59:23 +03:00
|
|
|
inter_annotation IA = Inter::Annotations::from_bytecode(annot_ID, n);
|
2022-02-03 21:44:57 +02:00
|
|
|
InterSymbol::annotate(symb, IA);
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::read_annotation(const inter_symbol *symb, inter_ti ID) {
|
2019-07-26 10:59:23 +03:00
|
|
|
inter_annotation *IA = Inter::Annotations::find(&(symb->ann_set), ID);
|
|
|
|
if (IA) return (int) IA->annot_value;
|
2019-02-05 02:44:07 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
text_stream *InterSymbol::read_annotation_t(inter_symbol *symb, inter_tree *I, inter_ti ID) {
|
2019-07-26 10:59:23 +03:00
|
|
|
inter_annotation *IA = Inter::Annotations::find(&(symb->ann_set), ID);
|
2022-01-30 15:32:38 +02:00
|
|
|
if (IA) return InterWarehouse::get_text(InterTree::warehouse(I), IA->annot_value);
|
2019-02-05 02:44:07 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::annotate_t(inter_tree *I, inter_package *owner, inter_symbol *symb, inter_ti annot_ID, text_stream *S) {
|
2022-01-30 15:32:38 +02:00
|
|
|
inter_ti n = InterWarehouse::create_text(InterTree::warehouse(I), owner);
|
|
|
|
Str::copy(InterWarehouse::get_text(InterTree::warehouse(I), n), S);
|
2019-07-26 10:59:23 +03:00
|
|
|
inter_annotation IA = Inter::Annotations::from_bytecode(annot_ID, n);
|
2022-02-03 21:44:57 +02:00
|
|
|
InterSymbol::annotate(symb, IA);
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::write_annotations(OUTPUT_STREAM, inter_tree_node *F, inter_symbol *symb) {
|
2019-07-26 10:59:23 +03:00
|
|
|
if (symb) Inter::Annotations::write_set(OUT, &(symb->ann_set), F);
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::transpose_annotations(inter_symbol *symb, inter_ti *grid, inter_ti grid_extent, inter_error_message **E) {
|
2019-09-07 03:28:18 +03:00
|
|
|
if (symb) Inter::Annotations::transpose_set(&(symb->ann_set), grid, grid_extent, E);
|
|
|
|
}
|
|
|
|
|
2019-02-05 02:44:07 +02:00
|
|
|
@ =
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::is_predeclared(inter_symbol *S) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (S == NULL) return FALSE;
|
2022-02-03 21:44:57 +02:00
|
|
|
if (InterSymbol::get_scope(S) != PUBLIC_ISYMS) return FALSE;
|
|
|
|
if (InterSymbol::get_type(S) != MISC_ISYMT) return FALSE;
|
|
|
|
if (InterSymbol::is_defined(S)) return FALSE;
|
2019-02-05 02:44:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::is_predeclared_local(inter_symbol *S) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (S == NULL) return FALSE;
|
2022-02-03 21:44:57 +02:00
|
|
|
if (InterSymbol::get_scope(S) != PRIVATE_ISYMS) return FALSE;
|
|
|
|
if (InterSymbol::get_type(S) != MISC_ISYMT) return FALSE;
|
|
|
|
if (InterSymbol::is_defined(S)) return FALSE;
|
2019-02-05 02:44:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::is_undefined_private(inter_symbol *S) {
|
2019-06-11 21:12:34 +03:00
|
|
|
if (S == NULL) return FALSE;
|
2022-02-03 21:44:57 +02:00
|
|
|
if (InterSymbol::get_scope(S) != PRIVATE_ISYMS) return FALSE;
|
|
|
|
if (InterSymbol::is_defined(S)) return FALSE;
|
2019-06-11 21:12:34 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::is_extern(inter_symbol *S) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (S == NULL) return FALSE;
|
2022-02-03 21:44:57 +02:00
|
|
|
if (InterSymbol::get_scope(S) == EXTERNAL_ISYMS) return TRUE;
|
|
|
|
if (InterSymbol::get_scope(S) == PLUG_ISYMS) return TRUE;
|
2019-02-05 02:44:07 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::extern(inter_symbol *S) {
|
|
|
|
InterSymbol::set_scope(S, EXTERNAL_ISYMS);
|
|
|
|
InterSymbol::set_type(S, MISC_ISYMT);
|
2019-07-26 10:59:23 +03:00
|
|
|
S->definition = NULL;
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::is_label(inter_symbol *S) {
|
2019-02-05 02:44:07 +02:00
|
|
|
if (S == NULL) return FALSE;
|
2022-02-03 21:44:57 +02:00
|
|
|
if (InterSymbol::get_scope(S) != PRIVATE_ISYMS) return FALSE;
|
|
|
|
if (InterSymbol::get_type(S) != LABEL_ISYMT) return FALSE;
|
2019-02-05 02:44:07 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::label(inter_symbol *S) {
|
2019-06-11 21:12:34 +03:00
|
|
|
if (Str::get_first_char(S->symbol_name) != '.') {
|
|
|
|
LOG("Name is %S\n", S->symbol_name);
|
|
|
|
internal_error("not a label name");
|
|
|
|
}
|
2022-02-03 21:44:57 +02:00
|
|
|
InterSymbol::set_scope(S, PRIVATE_ISYMS);
|
|
|
|
InterSymbol::set_type(S, LABEL_ISYMT);
|
2019-07-26 10:59:23 +03:00
|
|
|
S->definition = NULL;
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
void InterSymbol::local(inter_symbol *S) {
|
|
|
|
InterSymbol::set_scope(S, PRIVATE_ISYMS);
|
|
|
|
InterSymbol::set_type(S, MISC_ISYMT);
|
2019-07-26 10:59:23 +03:00
|
|
|
S->definition = NULL;
|
2019-02-05 02:44:07 +02:00
|
|
|
}
|
2019-04-28 05:27:32 +03:00
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::is_local(inter_symbol *S) {
|
2019-04-28 05:27:32 +03:00
|
|
|
if (S == NULL) return FALSE;
|
2022-02-03 21:44:57 +02:00
|
|
|
if (InterSymbol::get_scope(S) != PRIVATE_ISYMS) return FALSE;
|
|
|
|
if (InterSymbol::get_type(S) != MISC_ISYMT) return FALSE;
|
2019-04-28 05:27:32 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
2019-08-04 14:19:47 +03:00
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
int InterSymbol::is_connector(inter_symbol *S) {
|
|
|
|
if ((S) && ((InterSymbol::get_scope(S) == PLUG_ISYMS) ||
|
|
|
|
(InterSymbol::get_scope(S) == SOCKET_ISYMS)))
|
2019-08-04 14:19:47 +03:00
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2021-09-26 13:01:13 +03:00
|
|
|
|
2022-02-03 21:44:57 +02:00
|
|
|
text_stream *InterSymbol::name(inter_symbol *symb) {
|
2021-09-26 13:01:13 +03:00
|
|
|
if (symb == NULL) return NULL;
|
2022-02-03 21:44:57 +02:00
|
|
|
if (InterSymbol::get_translate(symb)) return InterSymbol::get_translate(symb);
|
2021-09-26 13:01:13 +03:00
|
|
|
return symb->symbol_name;
|
|
|
|
}
|