Fix internal renaming of overridden classes, and use the '^' character instead of '>' to name them.

[INTERPRETER]
* BUG: Fix internal renaming of overridden classes, and use the '^' character instead of '>' to name them.
This commit is contained in:
gambas 2017-10-12 13:48:52 +02:00
parent 2b1a4016fa
commit b8bb7e60c1

View file

@ -201,91 +201,58 @@ static void class_replace_global(CLASS *class)
char *old_name; char *old_name;
CLASS *old_class; CLASS *old_class;
int len; int len;
//int index;
CLASS swap; CLASS swap;
char *swap_name; char *swap_name;
bool swap_free_name; bool swap_free_name;
int nprefix; int nprefix;
int i; int i;
if (CLASS_is_loaded(class)) if (!CLASS_is_loaded(class))
return;
name = class->name;
len = strlen(name);
parent = class->parent;
if (parent)
{ {
//fprintf(stderr, "class_replace_global: %p %s\n", class, name); for (nprefix = 0;; nprefix++)
name = class->name;
len = strlen(name);
nprefix = 0;
parent = class;
do
{ {
nprefix++; if (parent->name[nprefix] != '^')
parent = parent->parent;
}
while (parent);
ALLOC(&old_name, len + nprefix + 1);
for (i = 0; i < nprefix; i++)
old_name[i] = '>';
strcpy(&old_name[i], name);
old_class = CLASS_find_global(old_name);
//fprintf(stderr, "-> %p %s\n", old_class, old_name);
FREE(&old_name);
/*FREE(&old_class->name, "class_replace_global");
old_class->free_name = FALSE;
old_class->name = class->name;*/
//new_name = (char *)new_class->name;
/*if (TABLE_find_symbol(&_global_table, name, len, &index))
{
csym = (CLASS_SYMBOL *)TABLE_get_symbol(&_global_table, index);
csym->class = new_class;
}
if (TABLE_find_symbol(&_global_table, new_name, len + 1, &index))
{
csym = (CLASS_SYMBOL *)TABLE_get_symbol(&_global_table, index);
csym->class = class;
}
new_class->name = class->name;
class->name = new_name;*/
swap = *class;
*class = *old_class;
*old_class = swap;
SWAP_FIELD(swap_name, class, old_class, name);
SWAP_FIELD(swap_free_name, class, old_class, free_name);
SWAP_FIELD(parent, class, old_class, next);
SWAP_FIELD(i, class, old_class, count);
SWAP_FIELD(i, class, old_class, ref);
for (i = 0; i < old_class->n_desc; i++)
{
cds = &old_class->table[i];
if (cds->desc && cds->desc->method.class == class)
cds->desc->method.class = old_class;
}
CLASS_inheritance(class, old_class, FALSE);
/*for(;;)
{
class->override = new_class;
parent = class->parent;
if (!parent || parent->override != class)
break; break;
class = parent;
} }
nprefix++;
}
else
nprefix = 1;
ALLOC(&old_name, len + nprefix + 1);
for (i = 0; i < nprefix; i++)
old_name[i] = '^';
strcpy(&old_name[i], name);
class = new_class;*/ old_class = CLASS_find_global(old_name);
FREE(&old_name);
swap = *class;
*class = *old_class;
*old_class = swap;
SWAP_FIELD(swap_name, class, old_class, name);
SWAP_FIELD(swap_free_name, class, old_class, free_name);
SWAP_FIELD(parent, class, old_class, next);
SWAP_FIELD(i, class, old_class, count);
SWAP_FIELD(i, class, old_class, ref);
for (i = 0; i < old_class->n_desc; i++)
{
cds = &old_class->table[i];
if (cds->desc && cds->desc->method.class == class)
cds->desc->method.class = old_class;
} }
//return class; CLASS_inheritance(class, old_class, FALSE);
} }
static void release_class(CLASS *class) static void release_class(CLASS *class)
@ -1557,7 +1524,7 @@ char *CLASS_get_name(CLASS *class)
{ {
char *name = class->name; char *name = class->name;
while (*name == '>') while (*name == '^')
name++; name++;
return name; return name;