Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/vm/input/classinfo.cc

Go to the documentation of this file.
00001 /*
00002  * vm/input/classinfo.cc
00003  * 
00004  * VM class information. 
00005  * 
00006  * Copyright (c) 2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 
00007  * 
00008  * This file may be distributed and/or modified under the terms of the 
00009  * GNU General Public License version 2 as published by the Free Software 
00010  * Foundation. (See COPYING.GPL for details.)
00011  * 
00012  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014  * 
00015  */
00016 
00017 #include "classinfo.h"
00018 #include <lib/lex/strtreedump.h>
00019 #include <lib/lex/fastval2str.h>
00020 
00021 
00022 namespace VM
00023 {
00024 
00025 TLString ClassInfoIE::CompleteName() const
00026 {
00027     const ClassInfo *c=ci();
00028     if(c)
00029     {  return(c->NamespaceInfo::CompleteName());  }
00030     
00031     char tmp[11+1+1],*e=tmp;
00032     *e++='I';
00033     e=FastInt2String(e,-class_tid,10);
00034     *e='\0';
00035     return(tmp);  // TLString constructor. 
00036 }
00037 
00038 ClassInfoIE::ClassInfoIE(const ClassInfoIE &b) : 
00039     class_tid(b.class_tid)
00040 {
00041     // Only allowed for internal classes. 
00042     Assert(class_tid<0);
00043 }
00044 
00045 //------------------------------------------------------------------------------
00046 
00047 TLString ClassInfo::CompleteName() const
00048 {
00049     return(ClassInfoIE::CompleteName());
00050 }
00051 
00052 
00053 void ClassInfo::DumpTree(StringTreeDump &dump,bool IDs_resolved,
00054     bool recurse) const
00055 {
00056     NamespaceInfo::DumpTree(dump,/*recurse=*/0);
00057     
00058     TLString tmp;
00059     tmp.sprintf(
00060         "  TypeID=%d, size=%u, nvirtuals=%u\n",
00061         (int)class_tid,(uint)size,(uint)nvirtuals);
00062     dump+=tmp;
00063     for(uint32 i=0; i<base.n(); i++)
00064     {
00065         const BaseEntry *e=&base[i];
00066         if(IDs_resolved)
00067         {  tmp.sprintf(
00068             "  base[%u]={ class=%s, off=%d }\n",
00069             (uint)i,e->ci ? e->ci->CompleteName().str() : "(null)",
00070             (int)e->off);  }
00071         else
00072         {  tmp.sprintf(
00073             "  base[%u]={ TypeID=%d, off=%d }\n",
00074             (uint)i,(int)e->tid,(int)e->off);  }
00075         dump+=tmp;
00076     }
00077     for(uint32 i=0; i<membvar.n(); i++)
00078     {
00079         const MemberVarEntry *e=&membvar[i];
00080         tmp.sprintf(
00081             "  membvar[%u]={ vtype=%s, off=%d, name=%s }\n",
00082             (uint)i,e->vtype.TypeString().str(),(int)e->off,
00083             e->name ? e->name.str() : "(null)");
00084         dump+=tmp;
00085     }
00086     for(uint32 i=0; i<vtable.n(); i++)
00087     {
00088         const VTableEntry *e=&vtable[i];
00089         if(IDs_resolved)
00090         {  tmp.sprintf(
00091             "  vtable[%u]={ se=%s }\n",
00092             (uint)i,(e->se ? e->se->CompleteName().str() : "(null)"));  }
00093         else
00094         {  tmp.sprintf(
00095             "  vtable[%u]={ symref=%d }\n",
00096             (uint)i,(int)e->symref);  }
00097         dump+=tmp;
00098     }
00099     tmp.deref();
00100     
00101     // Recurse: 
00102     if(recurse && !down.IsEmpty())
00103     {
00104         dump.AddIndent();
00105         for(NamespaceInfo *i=down.first(); i; i=i->next)
00106         {  i->DumpTree(dump,IDs_resolved,recurse);  }
00107         dump.SubIndent();
00108     }
00109 }
00110 
00111 
00112 ClassInfo::ClassInfo(const TLString &name,TypeID _class_tid,
00113     NamespaceInfo *parent) : 
00114     NamespaceInfo(name,parent,NSClass),
00115     ClassInfoIE(_class_tid),
00116     base(),
00117     vtable(),
00118     membvar()
00119 {
00120     size=0;
00121     nvirtuals=0;
00122     
00123     need_construct=0;
00124     need_cast=0;
00125 }
00126 
00127 ClassInfo::~ClassInfo()
00128 {
00129     // base, vtable, membvar tidy up themselves. 
00130 }
00131 
00132 }  // end of namespace VM

Generated on Sat Feb 19 22:33:46 2005 for Ray by doxygen 1.3.5