_export void
p4_load_words (const p4Words* ws, p4_Wordl* wid, int unused)
{
Wordl* save_current = CURRENT;
int k = ws->n;
const p4Word* w = ws->w;
char dictname[NFACNTMAX+1]; char* dn;
int* slot = 0;
if (!wid) wid = CURRENT;
if (ws->name)
{
P4_info1 ("load '%s'" , (ws->name));
strncpy (dictname, ws->name, NFACNTMAX);
dictname[NFACNTMAX] = '\0' ;
if ((dn= strchr (dictname, ' ' ))
|| (dn= strchr (dictname, '(' )))
*dn = '\0' ;
}else{
sprintf (dictname, "%p" , DP);
}
p4_forget_word ("wordset:%s" , (p4cell) dictname,
PFX (p4_forget_wordset_RT),
(p4cell) (ws));
for ( ; --k >= 0; w++)
{
wid = CURRENT;
if (w)
{
char type = *w->name;
const char* name = w->name+2;
int len = strlen (w->name+2);
void* ptr = w->ptr;
Wordl* wid = CURRENT;
p4xt cfa;
switch (type)
{
case p4_LOAD:
if (ptr)
p4_load_words ((p4Words*) ptr, 0, 0);
continue;
case p4_INTO:
{
register void* p;
p = p4_find_wordlist (name, strlen (name));
if (p)
{
P4_debug1 (13, "load into old '%s'" , name);
CURRENT = p;
}else{
Wordl* current = 0;
if (ptr) {
current = p4_find_wordlist (ptr, strlen(ptr));
if (! current)
P4_warn1 ("could not find also-voc %s" ,
(char*)(ptr));
}
if (! current) current = CURRENT;
P4_info1 ("load into new '%s'" , name);
p4_header_comma (name, strlen(name), current);
P4_info1 ("did comma '%p'" , LAST);
FX_RUNTIME1 (p4_vocabulary); FX_IMMEDIATE;
P4_info1 ("done runtime '%p'" , LAST);
CURRENT = p4_make_wordlist (LAST);
P4_info1 ("load into current '%p'" , CURRENT);
}
if (ptr)
{
if (! CURRENT->also)
CURRENT->also = p4_find_wordlist (ptr, strlen(ptr));
p4_load_into (name);
}
} continue;
case p4_SLOT:
slot = (int*) ptr;
p4_load_slot_open (slot);
continue;
case p4_SSIZ:
p4_load_slot_init (slot, (p4ucell)(ptr));
continue;
case p4_EXPT:
p4_exception_string(name, (p4cell)(ptr));
continue;
case p4_XXCO:
wid = PFE.atexit_wl;
break;
case p4_DVAH:
{
register void* last = LAST;
register void* p = p4_find (name, strlen(name));
if (! p)
{
if (! ptr) {
P4_fail1 (
"trying to append to non-existant chain %s" ,
name);
continue;
}
p4_header_comma (name, len, wid);
FX_RUNTIME1_RT(p4_dictvar);
FX_UCOMMA (ptr);
FX_PCOMMA (0);
{
register void* here = DP;
FX_PCOMMA(PFE.chain_link); PFE.chain_link = here;
}
p = LAST;
}
p = ((char *) p4TH + *P4_TO_BODY(p4_name_from(p)));
if (last)
{
register void* here = DP;
FX_PCOMMA (*(void**)p);
*(void**)p = here;
FX_PCOMMA (p4_name_from(last));
}
} continue;
}
p4_header_comma (name, len, wid); FX_RUNTIME1_RT (illegal);
if ('A' <= type && type <= 'Z' )
FX_IMMEDIATE;
cfa = P4_BODY_FROM(DP);
# ifndef PFE_CALL_THREADING
switch (type)
{
case p4_SXCO:
# ifndef HOST_WIN32
*cfa = ((p4_Semant *) ptr) ->comp;
if (! ((p4_Semant *)ptr) ->name)
P4_VAR(char*, ((p4_Semant *)ptr) ->name) = name-1;
# else
*cfa = ((p4_Semant*(*)())ptr) () -> comp;
if (! ((p4_Semant *(*)())ptr) () ->name)
(char*) ((p4_Semant *(*)())ptr) () ->name = name-1;
# endif
continue;
case p4_RTCO:
# ifndef HOST_WIN32
*cfa = ((p4_Runtime2 *) ptr) ->comp;
# else
*cfa = ((p4_Runtime2*(*)())ptr) () -> comp;
# endif
continue;
case p4_IXCO:
case p4_FXCO:
*cfa = (p4code) ptr;
continue;
case p4_XXCO:
*cfa = (p4code) ptr;
((p4code)ptr) ();
continue;
case p4_IVOC:
case p4_OVOC:
*cfa = p4_vocabulary_RT_ ;
continue;
case p4_DVAH:
case p4_DVAR:
*cfa = p4_dictvar_RT_ ;
break;
case p4_DCON:
*cfa = p4_dictget_RT_ ;
break;
case p4_DSET:
*cfa = p4_dictset_RT_ ;
break;
case p4_OVAR:
case p4_IVAR:
*cfa = p4_variable_RT_ ;
break;
case p4_OVAL:
case p4_IVAL:
*cfa = p4_value_RT_ ;
break;
case p4_OCON:
case p4_ICON:
*cfa = p4_constant_RT_ ;
break;
case p4_OFFS:
*cfa = p4_offset_RT_ ;
break;
case p4_iOLD:
case p4_xOLD:
*cfa = p4_obsoleted_RT_;
if (p4_LogMask && p4_LogMask^P4_LOG_FATAL) goto synonym;
case p4_SNYM:
case p4_FNYM:
*cfa = p4_synonym_RT_ ;
synonym:
ptr = p4_find (ptr, strlen(ptr));
if (ptr) ptr = p4_name_from (ptr);
else P4_fail3 ("could not resolve SYNONYM %.*s %s" ,
NFACNT(*LAST), LAST+1, (char*)w->ptr);
break;
default:
P4_fail3 ("unknown typecode for loadlist entry: "
"0x%x -> \"%.*s\"" ,
type, len, name);
}
# else
switch (type)
{
case p4_XXCO:
# if 1
((p4code)ptr) ();
# endif
case p4_IXCO:
case p4_FXCO:
case p4_IVOC:
case p4_OVOC:
case p4_DVAH:
case p4_DVAR:
case p4_DCON:
case p4_DSET:
case p4_OVAR:
case p4_IVAR:
case p4_OVAL:
case p4_IVAL:
case p4_OCON:
case p4_ICON:
case p4_OFFS:
case p4_SXCO:
case p4_RTCO:
case p4_iOLD:
case p4_xOLD:
cfa->word = (p4Word*)w;
break;
case p4_SNYM:
case p4_FNYM: {
ptr = p4_find (ptr, strlen(ptr));
if (ptr) ptr = p4_name_from (ptr);
else P4_fail3 ("could not resolve SYNONYM %.*s %s" ,
NFACNT(*LAST), LAST+1, (char*)w->ptr);
if (ptr) cfa->word = ((p4xt)ptr)->word;
continue;
}
default:
P4_fail3 ("unknown typecode for loadlist entry: "
"0x%x -> \"%.*s\"" ,
type, len, name);
}
# endif
FX_VCOMMA (ptr);
continue;
}
}
CURRENT = save_current;
} |