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
> > -----Original Message-----
> > From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-
> bounces at cs.uiuc.edu]
> > On Behalf Of leledumbo
> > Sent: 01 November 2010 09:41
> > To: llvmdev at 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:
http://old.nabble.com/Symbol-table-for-> > complex-data-structure-tp30103380p30103380.html
> > Sent from the LLVM - Dev mailing list archive at Nabble.com.
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
--
IMPORTANT NOTICE: The contents of this email and any attachments are
confidential and may also be privileged. If you are not the intended recipient,
please notify the sender immediately and do not disclose the contents to any
other person, use it for any purpose, or store or copy the information in any
medium. Thank you.