|Implementation of 'C' like pointers and arrays... firstname.lastname@example.org (Tom Fjellstrom) (2000-08-05)|
|Re: Implementation of 'C' like pointers and arrays... email@example.com (Tom Fjellstrom) (2000-08-09)|
|Re: Implementation of 'C' like pointers and arrays... firstname.lastname@example.org (Tom Fjellstrom) (2000-08-13)|
|From:||Tom Fjellstrom <email@example.com>|
|Date:||9 Aug 2000 23:58:39 -0400|
> [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...
[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
Search the comp.compilers archives again.