cppIdentifier.h 3.5 KB

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