factor/native/word.c

58 lines
1.2 KiB
C
Raw Normal View History

2004-07-16 02:26:21 -04:00
#include "factor.h"
/* When a word is executed we jump to the value of the xt field. However this
value is an unportable function pointer, so in the image we store a primitive
number that indexes a list of xts. */
void update_xt(F_WORD* word)
2004-07-16 02:26:21 -04:00
{
word->xt = primitive_to_xt(word->primitive);
}
/* <word> ( primitive parameter plist -- word ) */
void primitive_word(void)
{
2004-12-24 02:52:02 -05:00
F_WORD* word;
maybe_garbage_collection();
2004-12-24 02:52:02 -05:00
word = allot_object(WORD_TYPE,sizeof(F_WORD));
2004-12-27 22:58:43 -05:00
word->hashcode = tag_fixnum((CELL)word); /* initial address */
2004-12-24 02:52:02 -05:00
word->xt = (CELL)undefined;
word->primitive = 0;
word->def = F;
word->props = F;
2004-12-24 02:52:02 -05:00
word->call_count = 0;
word->allot_count = 0;
dpush(tag_object(word));
2004-08-23 01:13:09 -04:00
}
2004-12-24 02:52:02 -05:00
void primitive_update_xt(void)
2004-08-29 03:20:19 -04:00
{
2004-12-24 02:52:02 -05:00
update_xt(untag_word(dpop()));
2004-08-29 03:20:19 -04:00
}
2004-12-24 02:52:02 -05:00
void primitive_word_compiledp(void)
2004-08-29 03:20:19 -04:00
{
F_WORD* word = untag_word(dpop());
2004-12-24 02:52:02 -05:00
box_boolean(word->xt != (CELL)docol && word->xt != (CELL)dosym);
2004-08-29 03:20:19 -04:00
}
void fixup_word(F_WORD* word)
2004-07-16 02:26:21 -04:00
{
2004-12-25 02:55:03 -05:00
if(word->xt >= code_relocation_base
&& word->xt < code_relocation_base
- compiling.base + compiling.limit)
code_fixup(&word->xt);
else
update_xt(word);
data_fixup(&word->def);
data_fixup(&word->props);
2004-07-16 02:26:21 -04:00
}
void collect_word(F_WORD* word)
2004-07-16 02:26:21 -04:00
{
COPY_OBJECT(word->def);
COPY_OBJECT(word->props);
2004-07-16 02:26:21 -04:00
}