44 #include <osl/macros.h> 45 #include <osl/strings.h> 46 #include <osl/generic.h> 47 #include <osl/relation.h> 48 #include <osl/relation_list.h> 49 #include <osl/extensions/arrays.h> 50 #include <clan/macros.h> 74 int i, j, first = 1, number = 1;
78 for(j = 0; j < level; j++)
80 fprintf(file,
"+-- clan_symbol_t (node %d)\n", number);
83 for(j = 0; j < level; j++)
85 fprintf(file,
"+-- NULL symbol\n");
88 while (symbol != NULL) {
91 for (j = 0; j < level; j++)
93 fprintf(file,
"| clan_symbol_t (node %d)\n", number);
99 for (j = 0; j <= level + 1; j++)
100 fprintf(file,
"|\t");
104 for (j = 0; j <= level; j++)
105 fprintf(file,
"|\t");
106 fprintf(file,
"Key: %d\n", symbol->
key);
109 for (j = 0; j <= level+1; j++)
110 fprintf(file,
"|\t");
114 for (i = 0; i <= level; i++)
115 fprintf(file,
"|\t");
117 fprintf(file,
"+-- Identifier: %s\n", symbol->
identifier);
119 fprintf(file,
"+-- No identifier\n");
122 for(j = 0; j <= level + 1; j++)
123 fprintf(file,
"|\t") ;
124 fprintf(file,
"\n") ;
127 for (j = 0; j <= level; j++)
128 fprintf(file,
"|\t") ;
129 fprintf(file,
"Type: ") ;
130 switch (symbol->
type) {
131 case CLAN_TYPE_ITERATOR : fprintf(file,
"Iterator\n");
break;
132 case CLAN_TYPE_PARAMETER: fprintf(file,
"Parameter\n");
break;
133 case CLAN_TYPE_ARRAY : fprintf(file,
"Array\n");
break;
134 case CLAN_TYPE_FUNCTION : fprintf(file,
"Function\n");
break;
135 default : fprintf(file,
"Unknown\n") ;
139 for (j = 0; j <= level + 1; j++)
140 fprintf(file,
"|\t");
144 for (j = 0; j <= level; j++)
145 fprintf(file,
"|\t");
146 fprintf(file,
"Rank: %d\n", symbol->
rank);
149 for (j = 0; j <= level + 1; j++)
150 fprintf(file,
"|\t");
153 symbol = symbol->
next;
157 if (symbol != NULL) {
158 for (j = 0; j <= level; j++)
159 fprintf(file,
"|\t");
160 fprintf(file,
"V\n");
165 for(j = 0; j <= level; j++)
166 fprintf(file,
"|\t");
199 symbol->
key = CLAN_UNDEFINED;
201 symbol->
type = CLAN_UNDEFINED;
202 symbol->
rank = CLAN_UNDEFINED;
217 while (symbol != NULL) {
241 while (symbol != NULL) {
242 if (strcmp(symbol->
identifier, identifier) == 0)
245 symbol = symbol->
next;
261 while (symbol != NULL) {
262 if (symbol->
key == key)
265 symbol = symbol->
next;
279 int key = CLAN_KEY_START;
281 while (table != NULL) {
282 if (table->
key >= key)
283 key = table->
key + 1;
302 if (*table == NULL) {
305 while (tmp->
next != NULL)
355 while (symbol != NULL) {
356 if (strcmp(symbol->
identifier,identifier) == 0)
359 symbol = symbol->
next;
361 return CLAN_UNDEFINED;
375 while (symbol != NULL) {
376 if (strcmp(symbol->
identifier,identifier) == 0)
379 symbol = symbol->
next;
381 return CLAN_UNDEFINED;
395 while (symbol != NULL) {
396 if (strcmp(symbol->
identifier,identifier) == 0)
399 symbol = symbol->
next;
401 return CLAN_UNDEFINED;
418 int* depths,
int* labels) {
419 int i, j, xfor_index = 0, xfor_index_reuse = 0;
421 osl_strings_p strings = osl_strings_malloc();
424 for (i = 0; i < size; i++) {
428 if (symbol->
next != NULL) {
430 for (j = 0; j < labels[xfor_index]; j++)
431 symbol = symbol->
next;
438 if (xfor_index_reuse >= depths[xfor_index]) {
440 xfor_index_reuse = 0;
461 while (symbol != NULL) {
462 if (symbol->
type == type)
464 symbol = symbol->
next;
484 osl_strings_p strings = NULL;
485 osl_generic_p
generic;
492 strings = osl_strings_malloc();
493 while (symbol != NULL) {
494 if (symbol->
type == type) {
497 symbol = symbol->
next;
501 generic = osl_generic_shell(strings, osl_strings_interface());
536 osl_arrays_p arrays = NULL;
537 osl_generic_p
generic = NULL;
541 while (symbol != NULL) {
543 symbol = symbol->
next;
548 arrays = osl_arrays_malloc();
549 CLAN_malloc(arrays->id,
int*, nb_arrays *
sizeof(
int));
550 CLAN_malloc(arrays->names,
char**, nb_arrays *
sizeof(
char *));
551 arrays->nb_names = nb_arrays;
554 while (symbol != NULL) {
555 arrays->id[i] = symbol->
key;
556 CLAN_strdup(arrays->names[i], symbol->
identifier);
558 symbol = symbol->
next;
562 generic = osl_generic_shell(arrays, osl_arrays_interface());
582 char*
id,
int depth) {
587 if (symbol->
type != CLAN_TYPE_ITERATOR) {
588 yyerror(
"a loop iterator was previously used for something else");
593 if (symbol->
rank != depth + 1)
594 symbol->
rank = depth + 1;
622 CLAN_error(
"cannot even try to update type: NULL symbol table");
624 CLAN_error(
"cannot even try to update type: NULL access list");
627 while (access->next != NULL)
628 access = access->next;
632 relation_type = access->elt->type;
633 access->elt->type = OSL_TYPE_READ;
634 key = osl_relation_get_array_id(access->elt);
635 access->elt->type = relation_type;
638 CLAN_error(
"no symbol corresponding to the key");
640 if ((symbol->
type == CLAN_TYPE_ITERATOR) && (type != CLAN_TYPE_ITERATOR)) {
641 yyerror(
"illegal use of an iterator (update or reference) in a statement");
645 if ((symbol->
type == CLAN_TYPE_PARAMETER) && (type != CLAN_TYPE_PARAMETER)) {
646 yyerror(
"illegal use of a parameter (update or reference) in a statement");
static int clan_symbol_generate_new_key(clan_symbol_p table)
osl_strings_p clan_symbol_array_to_strings(clan_symbol_p *sarray, int size, int *depths, int *labels)
clan_symbol_p clan_symbol_add(clan_symbol_p *table, char *identifier, int type)
int clan_symbol_get_rank(clan_symbol_p symbol, char *identifier)
void clan_symbol_free(clan_symbol_p symbol)
struct clan_symbol * next
clan_symbol_p clan_symbol_clone_one(clan_symbol_p symbol)
clan_symbol_p clan_symbol_lookup_by_key(clan_symbol_p symbol, int key)
int clan_symbol_get_type(clan_symbol_p symbol, char *identifier)
int clan_symbol_nb_of_type(clan_symbol_p symbol, int type)
clan_symbol_p clan_symbol_malloc()
osl_generic_p clan_symbol_to_arrays(clan_symbol_p symbol)
int clan_symbol_update_type(clan_symbol_p table, osl_relation_list_p access, int type)
clan_symbol_p clan_symbol_lookup(clan_symbol_p symbol, char *identifier)
osl_generic_p clan_symbol_to_strings(clan_symbol_p symbol, int type)
void clan_symbol_print_structure(FILE *file, clan_symbol_p symbol, int level)
void clan_symbol_print(FILE *file, clan_symbol_p symbol)
int clan_symbol_get_key(clan_symbol_p symbol, char *identifier)
int clan_symbol_new_iterator(clan_symbol_p *table, clan_symbol_p *array, char *id, int depth)
void clan_symbol_push_at_end(clan_symbol_p *table, clan_symbol_p symbol)