view runtime/progfoot.inc @ 44:9dd370530f69

Fix escape codes in string literals. Don't print out the return value of main method. Fixup fib example to use print: method. Cleanup error handling in compiler slightly
author Mike Pavone <pavone@retrodev.com>
date Thu, 12 Jul 2012 22:49:08 -0700
parents 927fd7911a01
children 2a9c6eed0c70
line wrap: on
line source


object * make_array(uint32_t num_els, ...)
{
	va_list els;
	int i;
	array * arr = malloc(sizeof(array));
	arr->header.meta = &array_meta;
	arr->header.parent = NULL;
	arr->storage = arr->size = num_els;
	if (num_els < 4) {
		arr->storage = 4;
	}
	arr->data = malloc(sizeof(object *) * arr->storage);
	va_start(els, num_els);
	for (i = 0; i < num_els; i++)
		arr->data[i] = va_arg(els, object *);
	va_end(els);
	return &(arr->header);
}

int main(int argc, char ** argv)
{
	object * ret = mcall(METHOD_ID_MAIN, 1, mainModule());
	if (ret->meta == &obj_int32_meta) {
		obj_int32 * reti32 = (obj_int32 *) ret;
		return reti32->num;
	}
	return 0;
}