00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CPPINSTANCE_H
00020 #define CPPINSTANCE_H
00021
00022 #include <dtoolbase.h>
00023
00024 #include "cppDeclaration.h"
00025 #include "cppType.h"
00026 #include "cppIdentifier.h"
00027 #include "cppTemplateParameterList.h"
00028
00029 class CPPInstanceIdentifier;
00030 class CPPIdentifier;
00031 class CPPParameterList;
00032 class CPPScope;
00033 class CPPExpression;
00034
00035
00036
00037
00038
00039 class CPPInstance : public CPPDeclaration {
00040 public:
00041
00042
00043 enum StorageClass {
00044 SC_static = 0x001,
00045 SC_extern = 0x002,
00046 SC_c_binding = 0x004,
00047 SC_virtual = 0x008,
00048 SC_inline = 0x010,
00049 SC_explicit = 0x020,
00050 SC_register = 0x040,
00051 SC_pure_virtual = 0x080,
00052 SC_volatile = 0x100,
00053 SC_mutable = 0x200,
00054
00055
00056 SC_inherited_virtual = 0x400,
00057 };
00058
00059 CPPInstance(CPPType *type, const string &name, int storage_class = 0);
00060 CPPInstance(CPPType *type, CPPIdentifier *ident, int storage_class = 0);
00061 CPPInstance(CPPType *type, CPPInstanceIdentifier *ii,
00062 int storage_class, const CPPFile &file);
00063 CPPInstance(const CPPInstance ©);
00064 ~CPPInstance();
00065
00066 static CPPInstance *
00067 make_typecast_function(CPPInstance *inst, CPPIdentifier *ident,
00068 CPPParameterList *parameters, int function_flags);
00069
00070 bool operator == (const CPPInstance &other) const;
00071 bool operator != (const CPPInstance &other) const;
00072 bool operator < (const CPPInstance &other) const;
00073
00074 void set_initializer(CPPExpression *initializer);
00075
00076 bool is_scoped() const;
00077 CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope,
00078 CPPPreprocessor *error_sink = NULL) const;
00079
00080 string get_simple_name() const;
00081 string get_local_name(CPPScope *scope = NULL) const;
00082 string get_fully_scoped_name() const;
00083
00084 void check_for_constructor(CPPScope *current_scope, CPPScope *global_scope);
00085
00086 virtual CPPDeclaration *
00087 instantiate(const CPPTemplateParameterList *actual_params,
00088 CPPScope *current_scope, CPPScope *global_scope,
00089 CPPPreprocessor *error_sink = NULL) const;
00090
00091 virtual bool is_fully_specified() const;
00092 virtual CPPDeclaration *substitute_decl(SubstDecl &subst,
00093 CPPScope *current_scope,
00094 CPPScope *global_scope);
00095
00096 virtual void output(ostream &out, int indent_level, CPPScope *scope,
00097 bool complete) const;
00098 void output(ostream &out, int indent_level, CPPScope *scope,
00099 bool complete, int num_default_parameters) const;
00100 virtual SubType get_subtype() const;
00101
00102 virtual CPPInstance *as_instance();
00103
00104 CPPType *_type;
00105 CPPIdentifier *_ident;
00106 CPPExpression *_initializer;
00107
00108 int _storage_class;
00109
00110 private:
00111 typedef map<const CPPTemplateParameterList *, CPPInstance *, CPPTPLCompare> Instantiations;
00112 Instantiations _instantiations;
00113 };
00114
00115 #endif
00116