cppInstance.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Filename: cppInstance.h
  2. // Created by: drose (19Oct99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #ifndef CPPINSTANCE_H
  6. #define CPPINSTANCE_H
  7. #include <dtoolbase.h>
  8. #include "cppDeclaration.h"
  9. #include "cppType.h"
  10. #include "cppIdentifier.h"
  11. #include "cppTemplateParameterList.h"
  12. class CPPInstanceIdentifier;
  13. class CPPIdentifier;
  14. class CPPParameterList;
  15. class CPPScope;
  16. class CPPExpression;
  17. ///////////////////////////////////////////////////////////////////
  18. // Class : CPPInstance
  19. // Description :
  20. ////////////////////////////////////////////////////////////////////
  21. class CPPInstance : public CPPDeclaration {
  22. public:
  23. // Some of these flags clearly only make sense in certain contexts,
  24. // e.g. for a function or method.
  25. enum StorageClass {
  26. SC_static = 0x001,
  27. SC_extern = 0x002,
  28. SC_c_binding = 0x004,
  29. SC_virtual = 0x008,
  30. SC_inline = 0x010,
  31. SC_explicit = 0x020,
  32. SC_register = 0x040,
  33. SC_pure_virtual = 0x080,
  34. SC_volatile = 0x100,
  35. SC_mutable = 0x200,
  36. // This bit is only set by CPPStructType::check_virtual().
  37. SC_inherited_virtual = 0x400,
  38. };
  39. CPPInstance(CPPType *type, const string &name, int storage_class = 0);
  40. CPPInstance(CPPType *type, CPPIdentifier *ident, int storage_class = 0);
  41. CPPInstance(CPPType *type, CPPInstanceIdentifier *ii,
  42. int storage_class, const CPPFile &file);
  43. CPPInstance(const CPPInstance &copy);
  44. ~CPPInstance();
  45. static CPPInstance *
  46. make_typecast_function(CPPInstance *inst, CPPIdentifier *ident,
  47. CPPParameterList *parameters, int function_flags);
  48. bool operator == (const CPPInstance &other) const;
  49. bool operator != (const CPPInstance &other) const;
  50. bool operator < (const CPPInstance &other) const;
  51. void set_initializer(CPPExpression *initializer);
  52. bool is_scoped() const;
  53. CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope,
  54. CPPPreprocessor *error_sink = NULL) const;
  55. string get_simple_name() const;
  56. string get_local_name(CPPScope *scope = NULL) const;
  57. string get_fully_scoped_name() const;
  58. void check_for_constructor(CPPScope *current_scope, CPPScope *global_scope);
  59. virtual CPPDeclaration *
  60. instantiate(const CPPTemplateParameterList *actual_params,
  61. CPPScope *current_scope, CPPScope *global_scope,
  62. CPPPreprocessor *error_sink = NULL) const;
  63. virtual bool is_fully_specified() const;
  64. virtual CPPDeclaration *substitute_decl(SubstDecl &subst,
  65. CPPScope *current_scope,
  66. CPPScope *global_scope);
  67. virtual void output(ostream &out, int indent_level, CPPScope *scope,
  68. bool complete) const;
  69. void output(ostream &out, int indent_level, CPPScope *scope,
  70. bool complete, int num_default_parameters) const;
  71. virtual SubType get_subtype() const;
  72. virtual CPPInstance *as_instance();
  73. CPPType *_type;
  74. CPPIdentifier *_ident;
  75. CPPExpression *_initializer;
  76. int _storage_class;
  77. private:
  78. typedef map<const CPPTemplateParameterList *, CPPInstance *, CPPTPLCompare> Instantiations;
  79. Instantiations _instantiations;
  80. };
  81. #endif