[INTERPRETER]

* BUG: Correctly load optional exported classes at component loading.


git-svn-id: svn://localhost/gambas/trunk@7539 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2015-12-30 17:10:00 +00:00
parent c255863403
commit 97ab7c0a3a

View file

@ -45,6 +45,8 @@
#include "gb_arch_temp.h" #include "gb_arch_temp.h"
//#define DEBUG_COMP 1
/* main archive project (used only if gbx is run with -x flag) */ /* main archive project (used only if gbx is run with -x flag) */
ARCHIVE *ARCHIVE_main = NULL; ARCHIVE *ARCHIVE_main = NULL;
@ -158,17 +160,11 @@ void ARCHIVE_load_exported_class(ARCHIVE *arch, int pass)
else else
class = CLASS_find_global(name);*/ class = CLASS_find_global(name);*/
class = CLASS_find_global(name); if (!optional || CLASS_look_global(name, len) == NULL)
CLASS_check_global(class);
if (optional)
{ {
if (CLASS_look_global(name, len)) class = CLASS_find_global(name);
class = NULL; CLASS_check_global(class);
}
if (class)
{
#if DEBUG_COMP #if DEBUG_COMP
fprintf(stderr, "Add to load: %p %s\n", class, name); fprintf(stderr, "Add to load: %p %s\n", class, name);
#endif #endif
@ -182,7 +178,7 @@ void ARCHIVE_load_exported_class(ARCHIVE *arch, int pass)
FREE(&buffer); FREE(&buffer);
} }
if (pass & AR_FIND_ONLY) if (pass & AR_FIND_ONLY) // That way the 'pass' flag is always ignored.
{ {
#if DEBUG_COMP #if DEBUG_COMP
fprintf(stderr, "<Load pass>\n"); fprintf(stderr, "<Load pass>\n");
@ -320,19 +316,19 @@ bool ARCHIVE_find_from_path(ARCHIVE **parch, const char **ppath)
{ {
int i; int i;
CLASS *class; CLASS *class;
if (*parch) if (*parch)
return FALSE; return FALSE;
if (COMPONENT_current && COMPONENT_current->archive) if (COMPONENT_current && COMPONENT_current->archive)
*parch = COMPONENT_current->archive; *parch = COMPONENT_current->archive;
else if (CP && CP->component && CP->component->archive) else if (CP && CP->component && CP->component->archive)
*parch = CP->component->archive; *parch = CP->component->archive;
else else
*parch = NULL; *parch = NULL;
//fprintf(stderr, "ARCHIVE_find_from_path: %s (%s)\n", *ppath, *parch ? (*parch)->name : "NULL"); //fprintf(stderr, "ARCHIVE_find_from_path: %s (%s)\n", *ppath, *parch ? (*parch)->name : "NULL");
if (strncmp(*ppath, ".../", 4) == 0) if (strncmp(*ppath, ".../", 4) == 0)
{ {
*ppath += 4; *ppath += 4;
@ -346,7 +342,7 @@ bool ARCHIVE_find_from_path(ARCHIVE **parch, const char **ppath)
*ppath += 3; *ppath += 3;
if (*parch == NULL || *parch == ARCHIVE_main) if (*parch == NULL || *parch == ARCHIVE_main)
continue; continue;
while (i < STACK_frame_count) while (i < STACK_frame_count)
{ {
class = STACK_frame[i].cp; class = STACK_frame[i].cp;
@ -364,20 +360,20 @@ bool ARCHIVE_find_from_path(ARCHIVE **parch, const char **ppath)
break; break;
} }
} }
i++; i++;
} }
if (i == STACK_frame_count) if (i == STACK_frame_count)
*parch = NULL; *parch = NULL;
} }
} }
if (*parch == NULL && EXEC_arch) if (*parch == NULL && EXEC_arch)
*parch = ARCHIVE_main; *parch = ARCHIVE_main;
//fprintf(stderr, "--> '%s' / %s\n", *parch ? (*parch)->name : "(null)", *ppath); //fprintf(stderr, "--> '%s' / %s\n", *parch ? (*parch)->name : "(null)", *ppath);
return *parch == NULL; return *parch == NULL;
} }