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 elementmust> > 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.
> 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.Actually, I don't put it along with the AST. It's a separate class in separate module, should it be integrated? Hmm... storing the AST node might be a good idea, I was duplicating the information by copying the declaration line, type, etc. as the symbol table entry. This is the point where I got confused in complex data type. -- View this message in context: http://old.nabble.com/Symbol-table-for-complex-data-structure-tp30103380p30103564.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Hi, As far as encapsulation is concerned, that's your decision (and sticking the Symtab in a separate class is a good idea). I was more checking that this symbol analysis is being done *on* your AST - so at the AST phase of compilation. 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 10:17 > To: llvmdev at cs.uiuc.edu > Subject: Re: [LLVMdev] Symbol table for complex data structure > > > > 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. > > Actually, I don't put it along with the AST. It's a separate class in > separate module, should it be integrated? > Hmm... storing the AST node might be a good idea, I was duplicatingthe> information by copying the declaration line, type, etc. as the symbol > table > entry. This is the point where I got confused in complex data type. > -- > View this message in context: http://old.nabble.com/Symbol-table-for- > complex-data-structure-tp30103380p30103564.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.
Apparently Analagous Threads
- [LLVMdev] Symbol table for complex data structure
- [LLVMdev] Symbol table for complex data structure
- [LLVMdev] Symbol table for complex data structure
- [LLVMdev] Bls: Compiling LLVM 2.7 with MinGW GCC 4.5.0
- [LLVMdev] Bls: Compiling LLVM 2.7 with MinGW GCC 4.5.0