factor/native/compiler.c

64 lines
1.1 KiB
C
Raw Normal View History

2004-09-06 02:32:04 -04:00
#include "factor.h"
void init_compiler(void)
{
init_zone(&compiling,COMPILE_ZONE_SIZE);
literal_top = compiling.base;
2004-09-06 02:32:04 -04:00
}
void check_compiled_offset(CELL offset)
2004-09-06 02:32:04 -04:00
{
if(offset < compiling.base || offset >= compiling.limit)
range_error(F,offset,compiling.limit);
2004-09-06 02:32:04 -04:00
}
void primitive_set_compiled_byte(void)
2004-09-06 02:32:04 -04:00
{
2004-09-19 17:39:28 -04:00
CELL offset = unbox_integer();
BYTE b = to_fixnum(dpop());
check_compiled_offset(offset);
bput(offset,b);
2004-09-06 02:32:04 -04:00
}
void primitive_set_compiled_cell(void)
{
2004-09-19 17:39:28 -04:00
CELL offset = unbox_integer();
CELL c = to_fixnum(dpop());
check_compiled_offset(offset);
put(offset,c);
}
void primitive_compiled_offset(void)
2004-09-06 02:32:04 -04:00
{
2004-09-19 17:39:28 -04:00
box_integer(compiling.here);
2004-09-06 02:32:04 -04:00
}
void primitive_set_compiled_offset(void)
{
2004-09-19 17:39:28 -04:00
CELL offset = unbox_integer();
check_compiled_offset(offset);
compiling.here = offset;
}
void primitive_literal_top(void)
{
2004-09-19 17:39:28 -04:00
box_integer(literal_top);
}
void primitive_set_literal_top(void)
{
2004-09-19 17:39:28 -04:00
CELL offset = unbox_integer();
check_compiled_offset(offset);
literal_top = offset;
}
void collect_literals(void)
{
CELL i = compiling.base;
while(i < literal_top)
{
copy_object((CELL*)i);
i += CELLS;
}
}