2004-09-06 02:32:04 -04:00
|
|
|
#include "factor.h"
|
|
|
|
|
|
|
|
void init_compiler(void)
|
|
|
|
{
|
|
|
|
init_zone(&compiling,COMPILE_ZONE_SIZE);
|
2004-09-06 22:39:12 -04:00
|
|
|
literal_top = compiling.base;
|
2004-09-06 02:32:04 -04:00
|
|
|
}
|
|
|
|
|
2004-09-06 22:39:12 -04:00
|
|
|
void check_compiled_offset(CELL offset)
|
2004-09-06 02:32:04 -04:00
|
|
|
{
|
2004-09-06 22:39:12 -04:00
|
|
|
if(offset < compiling.base || offset >= compiling.limit)
|
|
|
|
range_error(F,offset,compiling.limit);
|
2004-09-06 02:32:04 -04:00
|
|
|
}
|
|
|
|
|
2004-09-06 22:39:12 -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();
|
2004-09-06 22:39:12 -04:00
|
|
|
BYTE b = to_fixnum(dpop());
|
|
|
|
check_compiled_offset(offset);
|
|
|
|
bput(offset,b);
|
2004-09-06 02:32:04 -04:00
|
|
|
}
|
|
|
|
|
2004-09-06 22:39:12 -04:00
|
|
|
void primitive_set_compiled_cell(void)
|
|
|
|
{
|
2004-09-19 17:39:28 -04:00
|
|
|
CELL offset = unbox_integer();
|
2004-09-06 22:39:12 -04:00
|
|
|
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
|
|
|
}
|
2004-09-06 22:39:12 -04:00
|
|
|
|
|
|
|
void primitive_set_compiled_offset(void)
|
|
|
|
{
|
2004-09-19 17:39:28 -04:00
|
|
|
CELL offset = unbox_integer();
|
2004-09-06 22:39:12 -04:00
|
|
|
check_compiled_offset(offset);
|
|
|
|
compiling.here = offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void primitive_literal_top(void)
|
|
|
|
{
|
2004-09-19 17:39:28 -04:00
|
|
|
box_integer(literal_top);
|
2004-09-06 22:39:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void primitive_set_literal_top(void)
|
|
|
|
{
|
2004-09-19 17:39:28 -04:00
|
|
|
CELL offset = unbox_integer();
|
2004-09-06 22:39:12 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|