struct T* TV_init(struct TV *vecv, struct T *vec, struct Slice *slc, BOOL isSub) { test_assert( Slice_first(slc) < vec->size && Slice_last (slc) < vec->size, "slice out of range" ); struct T* vw = &vecv->T; vw->value = Slice_start (slc)*vec->stride + vec->value; vw->size = Slice_size (slc); vw->stride = isSub ? Slice_stride(slc) : Slice_stride(slc)*vec->stride; vecv->ref = vec; return vw; }
test_assert( i < self->size, "index out of range" ); OBJ *dst = self->object + i*self->stride; assign(dst, _3); retmethod(_1); endmethod defmethod(OBJ, gputAt, Array, Slice, Object) PRE test_assert( Slice_first(self2) < self->size && Slice_last (self2) < self->size, "slice out of range" ); BODY U32 dst_n = Slice_size (self2); I32 dst_s = Slice_stride(self2)*self->stride; OBJ *dst = Slice_start (self2)*self->stride + self->object; OBJ *end = dst + dst_s*dst_n; while (dst != end) { assign(dst, _3); dst += dst_s; } retmethod(_1); endmethod // move to sequence? defmethod(OBJ, gputAt, Array, Range, Object) struct Slice *slice = Slice_fromRange(atSlice(0), self2, &self->size); retmethod( gputAt(_1,(OBJ)slice,_3) );