diff options
author | Adrian Thurston <thurston@complang.org> | 2015-01-04 14:39:40 -0500 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2015-01-04 14:39:40 -0500 |
commit | b86d5b2fa8e4ab4773a0fdb252d5dd8356feec16 (patch) | |
tree | 2b80ce329e7c67d3434674ba7259d0289c8b61e9 /src/struct.c | |
parent | 7f6c8260b492b5bbc4213e22b98c8aa7a3a437ab (diff) | |
download | colm-b86d5b2fa8e4ab4773a0fdb252d5dd8356feec16.tar.gz |
more rough work on object-based lists
Diffstat (limited to 'src/struct.c')
-rw-r--r-- | src/struct.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/struct.c b/src/struct.c index 3386db14..1667b864 100644 --- a/src/struct.c +++ b/src/struct.c @@ -112,7 +112,7 @@ void colm_list_destroy( Program *prg, Tree **sp, struct colm_struct *s ) while ( el != 0 ) { ListEl *next = el->next; treeDownref( prg, sp, el->value ); - listElFree( prg, el ); + //listElFree( prg, el ); el = next; } } @@ -151,3 +151,42 @@ Map *colm_map_new( struct colm_program *prg ) map->id = STRUCT_INBUILT_ID; return map; } + +Tree *colm_list_get( List *list, Word field ) +{ + Tree *result = 0; + switch ( field ) { + case 0: + result = list->head; + break; + case 1: + result = list->tail; + break; + default: + assert( 0 ); + break; + } + return result; +} + +Tree *colm_list_el_get( ListEl *listEl, Word field ) +{ + Tree *result = 0; + switch ( field ) { + case 0: + result = listEl->prev; + break; + case 1: + result = listEl->next; + break; + case 2: + result = listEl->value; + treeUpref( result ); + break; +// default: +// assert( false ); +// break; + } + return result; +} + |