Related articles |
---|
Implementation of 'C' like pointers and arrays... tfjellstrom@home.com (Tom Fjellstrom) (2000-08-05) |
Re: Implementation of 'C' like pointers and arrays... tfjellstrom@home.com (Tom Fjellstrom) (2000-08-09) |
Re: Implementation of 'C' like pointers and arrays... tfjellstrom@home.com (Tom Fjellstrom) (2000-08-13) |
From: | Tom Fjellstrom <tfjellstrom@home.com> |
Newsgroups: | comp.compilers |
Date: | 9 Aug 2000 23:58:39 -0400 |
Organization: | Compilers Central |
References: | 00-08-030 |
Keywords: | types |
> [C types are recursively defined wigth "array of", "pointer to", and
> "function returning" either a base type or another array, pointer, or
> function. I'd use a recursive data structure if you really want the
> fully glory of C types. PCC, the 2nd C compiler, used a cute trick
> using two-bit fields in the type word to describe the pointer, array,
> and function bits. -John]
Currently I store the type in the flags entry of the symtab_node_t
struct, be it a pointer (refrence), a function, or a regular variable.
What I was going to do is if the variable is an array, initialize the
'info.data' struct (for size and len...) and alloc the
'info.data.val.vval' void pointer to the size of the array. If it
happens to be an array of an array I would use the 'vval' as the
symbol[s] to create the nested array.
I'm sure I can do arrays of arrays... but pointers to arrays and
pointers to pointers are stumping me...
thx,
Tom Fjellstrom
[You need to make a linked list of "pointer to", "array of", and
"function returning" modifier types, or something close to that.
For the arrays, you also need the array size. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.