cppIdentifier.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Filename: cppIdentifier.h
  2. // Created by: drose (26Oct99)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #ifndef CPPIDENTIFIER_H
  15. #define CPPIDENTIFIER_H
  16. #include "dtoolbase.h"
  17. #include "cppDeclaration.h"
  18. #include "cppNameComponent.h"
  19. #include "cppFile.h"
  20. #include <string>
  21. #include <vector>
  22. class CPPScope;
  23. class CPPType;
  24. class CPPPreprocessor;
  25. class CPPTemplateParameterList;
  26. ///////////////////////////////////////////////////////////////////
  27. // Class : CPPIdentifier
  28. // Description :
  29. ////////////////////////////////////////////////////////////////////
  30. class CPPIdentifier {
  31. public:
  32. CPPIdentifier(const string &name, const CPPFile &file = CPPFile());
  33. CPPIdentifier(const CPPNameComponent &name);
  34. void add_name(const string &name);
  35. void add_name(const CPPNameComponent &name);
  36. bool operator == (const CPPIdentifier &other) const;
  37. bool operator != (const CPPIdentifier &other) const;
  38. bool operator < (const CPPIdentifier &other) const;
  39. bool is_scoped() const;
  40. string get_simple_name() const;
  41. string get_local_name(CPPScope *scope = NULL) const;
  42. string get_fully_scoped_name() const;
  43. bool is_fully_specified() const;
  44. bool is_tbd() const;
  45. CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope,
  46. CPPPreprocessor *error_sink = NULL) const;
  47. CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope,
  48. CPPDeclaration::SubstDecl &subst,
  49. CPPPreprocessor *error_sink = NULL) const;
  50. CPPType *find_type(CPPScope *current_scope, CPPScope *global_scope,
  51. bool force_instantiate = false,
  52. CPPPreprocessor *error_sink = NULL) const;
  53. CPPType *find_type(CPPScope *current_scope, CPPScope *global_scope,
  54. CPPDeclaration::SubstDecl &subst,
  55. CPPPreprocessor *error_sink = NULL) const;
  56. CPPDeclaration *find_symbol(CPPScope *current_scope,
  57. CPPScope *global_scope,
  58. CPPPreprocessor *error_sink = NULL) const;
  59. CPPDeclaration *find_template(CPPScope *current_scope,
  60. CPPScope *global_scope,
  61. CPPPreprocessor *error_sink = NULL) const;
  62. CPPScope *find_scope(CPPScope *current_scope,
  63. CPPScope *global_scope,
  64. CPPPreprocessor *error_sink = NULL) const;
  65. CPPIdentifier *substitute_decl(CPPDeclaration::SubstDecl &subst,
  66. CPPScope *current_scope,
  67. CPPScope *global_scope);
  68. void output(ostream &out, CPPScope *scope) const;
  69. void output_local_name(ostream &out, CPPScope *scope) const;
  70. void output_fully_scoped_name(ostream &out) const;
  71. typedef vector<CPPNameComponent> Names;
  72. Names _names;
  73. CPPScope *_native_scope;
  74. CPPFile _file;
  75. };
  76. inline ostream &operator << (ostream &out, const CPPIdentifier &identifier) {
  77. identifier.output(out, (CPPScope *)NULL);
  78. return out;
  79. }
  80. #endif