Mercurial > repos > rhope
view runtime/array.c @ 75:0083b2f7b3c7
Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 06 Jul 2010 07:52:59 -0400 |
parents | 70af7fa155d0 |
children | 4d5ea487f810 |
line wrap: on
line source
#include "integer.h" #include "object.h" void _internal_array_copyout(object * array, int32_t index, object * dest) { t_Array * arr = (t_Array *)array; memcpy(((char *)dest) + sizeof(object), ((char *)array) + sizeof(t_Array) + arr->payload.Eltype->bp->size * index, get_blueprint(dest)->size); } void _internal_array_copyin(object * array, int32_t index, object * val) { t_Array * arr = (t_Array *)array; memcpy(((char *)array) + sizeof(t_Array) + arr->payload.Eltype->bp->size * index, ((char *)val) + sizeof(object), arr->payload.Eltype->bp->size); } object * _internal_array_getboxed(object * array, int32_t index) { object * ret; object ** intarr = (object **)(((char *) array) + sizeof(t_Array)); ret = add_ref(intarr[index]); release_ref(array); return ret; } void _internal_array_setboxed(object *array, int32_t index, object * val) { object ** intarr = (object **)(((char *) array) + sizeof(t_Array)); intarr[index] = val; } object *_internal_array_allocboxed(int32_t size) { t_Array * ret = (t_Array *)new_multisize(TYPE_ARRAY, sizeof(nt_Array)+sizeof(object *)*size); ret->payload.Length = 0; ret->payload.Storage = size; ret->payload.Eltype = (t_Blueprint *)make_Blueprint(0); return (object *)ret; } object * _internal_array_allocnaked(int32_t size , object * type) { t_Array * ret; t_Blueprint * bp = (t_Blueprint *)type; if (bp->bp->size < 0) { return _internal_array_allocboxed(size); } ret = (t_Array *)new_multisize(TYPE_ARRAY, sizeof(nt_Array)+bp->bp->size*size); ret->payload.Length = 0; ret->payload.Storage = size; ret->payload.Eltype = bp; return ret; }