comparison runtime/array.c @ 7:d61550e2c001

Added current work on new runtime
author Mike Pavone <pavone@retrodev.com>
date Wed, 13 May 2009 00:47:40 -0400
parents
children 3e20ed8959c4
comparison
equal deleted inserted replaced
6:f67d9be38ddf 7:d61550e2c001
1 #include "array.h"
2 #include "integer.h"
3
4 Func(Array,0,
5 ;)
6 Ret(0, new_object(TYPE_ARRAY))
7 Return
8 EndFunc
9
10 Method(Index,Array,2,
11 _t_Int32 * idx;)
12 Param(1,idx,Int32)
13 if (idx->num < 0 || idx->num >= me->numels) {
14 Ret(0, NULL)
15 Ret(1, me)
16 } else {
17 Ret(1, NULL)
18 if (me->contents_type) {
19 Ret(0, copy_from_raw(me->conents_type, (char *)me + sizeof(*me) + (idx->num * sizeof(object *))))
20 } else {
21 Ret(0, add_ref((object *)((char *)me + sizeof(*me) + (idx->num * sizeof(object *)))))
22 }
23 release_ref(me);
24 }
25 EndFunc
26