view runtime/progfoot.inc @ 40:927fd7911a01

Add append message to array
author Mike Pavone <pavone@retrodev.com>
date Wed, 11 Jul 2012 19:17:24 -0700
parents e7be612fd3ae
children 9dd370530f69
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;
		printf("%d\n", reti32->num);
	} else if(ret->meta == &lambda_meta) {
		puts("returned lambda????");
	} else {
		int i = 0;
		for(; i < 16; ++i) {
			if (ret->meta->meth_lookup[i] != &no_impl) {
				printf("slot %d is set\n", i);
			}
		}
	}
	return 0;
}