Exemplo n.º 1
0
st_uint
st_input_get_line (st_input *input)
{
    st_assert (input != NULL);

    return input->line;
}
Exemplo n.º 2
0
st_uint
st_input_index (st_input *input)
{
    st_assert (input != NULL);

    return input->p;
}
Exemplo n.º 3
0
st_uint
st_input_size (st_input *input)
{
    st_assert (input != NULL);

    return input->n;
}
Exemplo n.º 4
0
st_uint
st_input_get_column (st_input *input)
{
    st_assert (input != NULL);

    return input->column;
}
Exemplo n.º 5
0
static st_oop
block_context_new (st_machine *machine, st_uint initial_ip, st_uint argcount)
{
    st_oop  home;
    st_oop  context;
    st_oop  method;
    st_oop *stack;
    st_uint stack_size;

    stack_size = 32;
    
    context = st_memory_allocate (ST_SIZE_OOPS (struct st_block_context) + stack_size);
    if (context == 0) {
	st_memory_perform_gc ();
	context = st_memory_allocate (ST_SIZE_OOPS (struct st_block_context) + stack_size);
	st_assert (context != 0);
    }

    st_object_initialize_header (context, ST_BLOCK_CONTEXT_CLASS);
    
    if (ST_OBJECT_CLASS (machine->context) == ST_BLOCK_CONTEXT_CLASS)
	home = ST_BLOCK_CONTEXT_HOME (machine->context);
    else
	home = machine->context;

    ST_CONTEXT_PART_SENDER (context) = ST_NIL;
    ST_CONTEXT_PART_IP (context)     = st_smi_new (0);
    ST_CONTEXT_PART_SP (context)     = st_smi_new (0);

    ST_BLOCK_CONTEXT_INITIALIP (context) = st_smi_new (initial_ip);
    ST_BLOCK_CONTEXT_ARGCOUNT (context)  = st_smi_new (argcount);
    ST_BLOCK_CONTEXT_HOME (context)      = home;
    
    return context;
}
Exemplo n.º 6
0
static void
create_actual_message (st_machine *machine)
{
    st_oop *elements;
    st_oop  message;
    st_oop  array;

    array = st_object_new_arrayed (ST_ARRAY_CLASS, machine->message_argcount);
    elements = st_array_elements (array);
    for (st_uint i = 0; i < machine->message_argcount; i++)
	elements[i] = machine->stack[machine->sp - machine->message_argcount + i];

    machine->sp -= machine->message_argcount;

    message = st_object_new (ST_MESSAGE_CLASS);
    if (message == 0) {
	st_memory_perform_gc ();
	message = st_object_new (ST_MESSAGE_CLASS);
	st_assert (message != 0);
    }

    ST_OBJECT_FIELDS (message)[0] = machine->message_selector;
    ST_OBJECT_FIELDS (message)[1] = array;

    ST_STACK_PUSH (machine, message);

    machine->message_selector = ST_SELECTOR_DOESNOTUNDERSTAND;
    machine->message_argcount = 1;
}
Exemplo n.º 7
0
void
st_input_destroy (st_input *input)
{
    st_assert (input != NULL);

    st_free (input->text);
    st_free (input);
}
Exemplo n.º 8
0
void
st_input_mark (st_input *input)
{
    st_assert (input != NULL);
    
    input->marker.p      = input->p;
    input->marker.line   = input->line;
    input->marker.column = input->column;
}
Exemplo n.º 9
0
void
st_input_rewind (st_input *input)
{
    st_assert (input != NULL);
    
    st_input_seek (input, input->marker.p);

    input->line   = input->marker.line;
    input->column = input->marker.column;
}
Exemplo n.º 10
0
void
st_input_seek (st_input *input, st_uint index)
{
    st_assert (input != NULL);

    if (index <= input->p) {
	input->p = index;
    }

    while (input->p < index)
	st_input_consume (input);
}
Exemplo n.º 11
0
st_input *
st_input_new (const char *string)
{
    st_input *input;

    st_assert (string != NULL);

    input = st_new0 (st_input);

    initialize_state (input, strdup (string));    

    return input;
}
Exemplo n.º 12
0
void SchedulerTestFixture::testSchedulerLeaks() {
	MWTime howlongus = 1000;
	
	shared_ptr<ScheduleTask> node;
	st_assert("node is not initialized correctly", node == 0);
	st_assert("node is not initialized correctly", node.use_count() == 0);
	
	shared_ptr<Scheduler> scheduler = Scheduler::instance();
	
	node = scheduler->scheduleUS(FILELINE,
								 howlongus,
								 0, 
								 1, 
								 boost::bind(test_for_leaks),
								 M_DEFAULT_PRIORITY,
								 M_DEFAULT_WARN_SLOP_US,
								 M_DEFAULT_FAIL_SLOP_US,
								 M_MISSED_EXECUTION_CATCH_UP);
	
	sleep(5);
	st_assert("something is wrong at this point", bool(node));
	st_assert("node should have one reference at this point", node.use_count() == 1);
}
Exemplo n.º 13
0
char *
st_input_range (st_input *input, st_uint start, st_uint end)
{
    char    *buf;
    st_uint  len;

    st_assert ((end - start) >= 0);

    len = end - start;
    buf = st_malloc (len + 1);
    memcpy (buf, input->text + start, len);
    buf[len] = 0;

    return buf;
}
Exemplo n.º 14
0
void
st_input_consume (st_input *input)
{
    st_assert (input != NULL);

    if (input->p < input->n) {

	input->column++;

	/* 0x000A is newline */
	if (input->text[input->p] == 0x000A) {
	    input->line++;
	    input->column = 1;
	}

	input->p++;
    }
}
Exemplo n.º 15
0
char
st_input_look_ahead (st_input *input, int i)
{
    st_assert (input != NULL);

    if (ST_UNLIKELY (i == 0)) {
	return 0x0000;
    }

    if (ST_UNLIKELY (i < 0)) {
	i++;
	if ((input->p + i - 1) < 0)
	    return ST_INPUT_EOF;
    }

    if ((input->p + i - 1) >= input->n) {
	return ST_INPUT_EOF;
    }

    return input->text[input->p + i - 1];
}
Exemplo n.º 16
0
	void *test_for_leaks() {
		usleep(1000);
		st_assert("test assert", true);
		return 0;
	}