Hi,
[Apologies, forgot to reply to list]
No, it's not LLVM specific, but I'll have a go at answering anyway.
The symbol table (in an AST, I assume?) deals with *symbols*. Assuming
your complex datatype is called a "struct" for simplicity's sake, your
symbol table would normally just store the struct's name, along with its
AST node.
Unless you want specific handling for static-style data member accesses
(MyClass::my_static_member in C++), there is no need to add each element
in the struct to the symbol table. The main reason for this is that it
holds no semantic value:
* A struct S is a specific type, which can be instantiated. It would
therefore be added to the symbol table as it can be referred to by code
(my $s = new S).
* A struct member S.m has a type, and a name, but is specific to an
instantiation of the wrapper type S. It holds no semantic meaning to
store S.m in the symbol table, as two S.m's may not refer to the same
node, as the parent S may be different (my $s = new S; my $s2 = new S;
$s.m == $s2.m).
* Unless you want to handle static data members, but personally I handle
them as special cases.
* Not only this, but with more complex datatypes such as classes, which
can have virtual functions, $s1.m() may in fact refer to T.m(), where T
extends S. Therefore a special-case lookup for datatype members is what
I would recommend, instead of trying to match them directly via the
symtab.
I hope this answers your question.
James
> From: llvmdev-bounces@cs.uiuc.edu [mailto:llvmdev-
bounces@cs.uiuc.edu]
> On Behalf Of leledumbo
> Sent: 01 November 2010 09:41
> To: llvmdev@cs.uiuc.edu
> Subject: [LLVMdev] Symbol table for complex data structure
>
>
> Maybe this is not LLVM specific, but more or less related. The
language
> I'm
> implementing allows the programmer to define complex data structure
> like
> Pascal records. How am I suppose to design the symbol table? What
> should be
> recorded there? Just the type name or each of the record element
must
> be
> stored?
> --
> View this message in context: