Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/cppparser/cppScope.h

Go to the documentation of this file.
00001 // Filename: cppScope.h
00002 // Created by:  drose (21Oct99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef CPPSCOPE_H
00020 #define CPPSCOPE_H
00021 
00022 #include <dtoolbase.h>
00023 
00024 #include "cppVisibility.h"
00025 #include "cppTemplateParameterList.h"
00026 #include "cppNameComponent.h"
00027 
00028 #include <vector>
00029 #include <map>
00030 #include <set>
00031 #include <string>
00032 
00033 using namespace std;
00034 
00035 class CPPType;
00036 class CPPDeclaration;
00037 class CPPExtensionType;
00038 class CPPStructType;
00039 class CPPNamespace;
00040 class CPPUsing;
00041 class CPPTypedef;
00042 class CPPInstance;
00043 class CPPFunctionGroup;
00044 class CPPTemplateScope;
00045 class CPPTemplateParameterList;
00046 class CPPPreprocessor;
00047 class CPPNameComponent;
00048 struct cppyyltype;
00049 
00050 ///////////////////////////////////////////////////////////////////
00051 //       Class : CPPScope
00052 // Description :
00053 ////////////////////////////////////////////////////////////////////
00054 class CPPScope {
00055 public:
00056   CPPScope(CPPScope *parent_scope,
00057            const CPPNameComponent &name, CPPVisibility starting_vis);
00058   virtual ~CPPScope();
00059 
00060   void set_current_vis(CPPVisibility current_vis);
00061   CPPVisibility get_current_vis() const;
00062 
00063   void set_struct_type(CPPStructType *struct_type);
00064   CPPStructType *get_struct_type() const;
00065   CPPScope *get_parent_scope() const;
00066 
00067   virtual void add_declaration(CPPDeclaration *decl, CPPScope *global_scope,
00068                                CPPPreprocessor *preprocessor,
00069                                const cppyyltype &pos);
00070   virtual void add_enum_value(CPPInstance *inst);
00071   virtual void define_extension_type(CPPExtensionType *type);
00072   virtual void define_namespace(CPPNamespace *scope);
00073   virtual void add_using(CPPUsing *using_decl, CPPScope *global_scope,
00074                          CPPPreprocessor *error_sink = NULL);
00075 
00076   virtual bool is_fully_specified() const;
00077 
00078   CPPScope *
00079   instantiate(const CPPTemplateParameterList *actual_params,
00080               CPPScope *current_scope, CPPScope *global_scope,
00081               CPPPreprocessor *error_sink = NULL) const;
00082 
00083   CPPScope *
00084   substitute_decl(CPPDeclaration::SubstDecl &subst,
00085                   CPPScope *current_scope,
00086                   CPPScope *global_scope) const;
00087 
00088   CPPType *find_type(const string &name, bool recurse = true) const;
00089   CPPType *find_type(const string &name,
00090                      CPPDeclaration::SubstDecl &subst,
00091                      CPPScope *global_scope,
00092                      bool recurse = true) const;
00093   CPPScope *find_scope(const string &name, bool recurse = true) const;
00094   CPPScope *find_scope(const string &name,
00095                        CPPDeclaration::SubstDecl &subst,
00096                        CPPScope *global_scope,
00097                        bool recurse = true) const;
00098   CPPDeclaration *find_symbol(const string &name,
00099                               bool recurse = true) const;
00100   CPPDeclaration *find_template(const string &name,
00101                                 bool recurse = true) const;
00102 
00103   virtual string get_simple_name() const;
00104   virtual string get_local_name(CPPScope *scope = NULL) const;
00105   virtual string get_fully_scoped_name() const;
00106 
00107   virtual void output(ostream &out, CPPScope *scope) const;
00108   void write(ostream &out, int indent, CPPScope *scope) const;
00109 
00110   CPPTemplateScope *get_template_scope();
00111   virtual CPPTemplateScope *as_template_scope();
00112 
00113 private:
00114   bool
00115   copy_substitute_decl(CPPScope *to_scope, CPPDeclaration::SubstDecl &subst,
00116                        CPPScope *global_scope) const;
00117 
00118   void handle_declaration(CPPDeclaration *decl, CPPScope *global_scope);
00119 
00120 public:
00121   typedef vector<CPPDeclaration *> Declarations;
00122   Declarations _declarations;
00123 
00124   typedef map<string, CPPType *> ExtensionTypes;
00125   ExtensionTypes _structs;
00126   ExtensionTypes _classes;
00127   ExtensionTypes _unions;
00128   ExtensionTypes _enums;
00129 
00130   typedef map<string, CPPNamespace *> Namespaces;
00131   Namespaces _namespaces;
00132 
00133   typedef map<string, CPPTypedef *> Typedefs;
00134   Typedefs _typedefs;
00135   typedef map<string, CPPInstance *> Variables;
00136   Variables _variables;
00137   Variables _enum_values;
00138   typedef map<string, CPPFunctionGroup *> Functions;
00139   Functions _functions;
00140   typedef map<string, CPPDeclaration *> Templates;
00141   Templates _templates;
00142   CPPNameComponent _name;
00143 
00144 protected:
00145   CPPScope *_parent_scope;
00146   CPPStructType *_struct_type;
00147   typedef set<CPPScope *> Using;
00148   Using _using;
00149   CPPVisibility _current_vis;
00150 
00151 private:
00152   typedef map<const CPPTemplateParameterList *, CPPScope *, CPPTPLCompare> Instantiations;
00153   Instantiations _instantiations;
00154 
00155   bool _is_fully_specified;
00156   bool _fully_specified_known;
00157   bool _is_fully_specified_recursive_protect;
00158   bool _subst_decl_recursive_protect;
00159 };
00160 
00161 inline ostream &
00162 operator << (ostream &out, const CPPScope &scope) {
00163   scope.output(out, (CPPScope *)NULL);
00164   return out;
00165 }
00166 
00167 #endif

Generated on Thu May 1 22:12:55 2003 for DTool by doxygen1.3