cppIdentifier.h 3.5 KB

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