예제 #1
0
파일: words.cpp 프로젝트: AlexIljin/factor
// word-code ( word -- start end )
// Allocates memory (from_unsigned_cell allocates)
void factor_vm::primitive_word_code() {
  data_root<word> w(ctx->pop(), this);
  check_tagged(w);

  ctx->push(from_unsigned_cell(w->entry_point));
  ctx->push(from_unsigned_cell((cell)w->code() + w->code()->size()));
}
예제 #2
0
파일: io.cpp 프로젝트: unreal666/factor
// Allocates memory (from_unsigned_cell())
void factor_vm::primitive_fread() {
  FILE* file = pop_file_handle();
  void* buf = (void*)alien_offset(ctx->pop());
  cell size = unbox_array_size();

  if (size == 0) {
    ctx->push(from_unsigned_cell(0));
    return;
  }
  size_t c = safe_fread(buf, 1, size, file);
  if (c == 0 || feof(file))
    clearerr(file);
  ctx->push(from_unsigned_cell(c));
}
예제 #3
0
파일: words.cpp 프로젝트: erg/factor
/* word-code ( word -- start end ) */
void factor_vm::primitive_word_code()
{
	data_root<word> w(ctx->pop(),this);
	w.untag_check(this);

	if(counting_profiler_p)
	{
		ctx->push(from_unsigned_cell((cell)w->profiling->entry_point()));
		ctx->push(from_unsigned_cell((cell)w->profiling + w->profiling->size()));
	}
	else
	{
		ctx->push(from_unsigned_cell((cell)w->code->entry_point()));
		ctx->push(from_unsigned_cell((cell)w->code + w->code->size()));
	}
}
예제 #4
0
파일: errors.cpp 프로젝트: ForNeVeR/factor
/* Allocates memory */
void factor_vm::memory_signal_handler_impl() {
  if (code->safepoint_p(signal_fault_addr)) {
    safepoint.handle_safepoint(this, signal_fault_pc);
  }
  else {
    vm_error_type type = ctx->address_to_error(signal_fault_addr);
    cell number = from_unsigned_cell(signal_fault_addr);
    general_error(type, number, false_object);
  }
  if (!signal_resumable) {
    /* In theory we should only get here if the callstack overflowed during a
       safepoint */
    general_error(ERROR_CALLSTACK_OVERFLOW, false_object, false_object);
  }
}
예제 #5
0
void factor_vm::memory_protection_error(cell pc, cell addr)
{
	if(code->safepoint_p(addr))
		safepoint.handle_safepoint(this, pc);
	else if(ctx->datastack_seg->underflow_p(addr))
		general_error(ERROR_DATASTACK_UNDERFLOW,false_object,false_object);
	else if(ctx->datastack_seg->overflow_p(addr))
		general_error(ERROR_DATASTACK_OVERFLOW,false_object,false_object);
	else if(ctx->retainstack_seg->underflow_p(addr))
		general_error(ERROR_RETAINSTACK_UNDERFLOW,false_object,false_object);
	else if(ctx->retainstack_seg->overflow_p(addr))
		general_error(ERROR_RETAINSTACK_OVERFLOW,false_object,false_object);
	else if(ctx->callstack_seg->underflow_p(addr))
		general_error(ERROR_CALLSTACK_OVERFLOW,false_object,false_object);
	else if(ctx->callstack_seg->overflow_p(addr))
		general_error(ERROR_CALLSTACK_UNDERFLOW,false_object,false_object);
	else
		general_error(ERROR_MEMORY,from_unsigned_cell(addr),false_object);
}
예제 #6
0
파일: alien.cpp 프로젝트: AlexIljin/factor
// address of an object representing a C pointer. Explicitly throw an error
// if the object is a byte array, as a sanity check.
// Allocates memory (from_unsigned_cell can allocate)
void factor_vm::primitive_alien_address() {
  ctx->replace(from_unsigned_cell((cell)pinned_alien_offset(ctx->peek())));
}
예제 #7
0
파일: errors.cpp 프로젝트: ForNeVeR/factor
/* Allocates memory */
void factor_vm::synchronous_signal_handler_impl() {
  general_error(ERROR_SIGNAL, from_unsigned_cell(signal_number), false_object);
}
예제 #8
0
파일: objects.cpp 프로젝트: jonenst/factor
// Allocates memory
void factor_vm::primitive_size() {
  ctx->replace(from_unsigned_cell(object_size(ctx->peek())));
}
예제 #9
0
파일: alien.cpp 프로젝트: 8byte-jose/factor
/* address of an object representing a C pointer. Explicitly throw an error
if the object is a byte array, as a sanity check. */
void factor_vm::primitive_alien_address()
{
	ctx->push(from_unsigned_cell((cell)pinned_alien_offset(ctx->pop())));
}
예제 #10
0
// Allocates memory (from_unsigned_cell)
void factor_vm::primitive_quotation_code() {
  data_root<quotation> quot(ctx->pop(), this);

  ctx->push(from_unsigned_cell(quot->entry_point));
  ctx->push(from_unsigned_cell((cell)quot->code() + quot->code()->size()));
}
예제 #11
0
void factor_vm::primitive_size()
{
	ctx->push(from_unsigned_cell(object_size(ctx->pop())));
}
예제 #12
0
void factor_vm::signal_error(cell signal)
{
	general_error(ERROR_SIGNAL,from_unsigned_cell(signal),false_object);
}