cppTypeDeclaration.cxx 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Filename: cppTypeDeclaration.cxx
  2. // Created by: drose (14Aug00)
  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. #include "cppTypeDeclaration.h"
  15. ////////////////////////////////////////////////////////////////////
  16. // Function: CPPTypeDeclaration::Constructor
  17. // Access: Public
  18. // Description: Constructs a new CPPTypeDeclaration object for the
  19. // given type.
  20. ////////////////////////////////////////////////////////////////////
  21. CPPTypeDeclaration::
  22. CPPTypeDeclaration(CPPType *type) :
  23. CPPInstance(type, (CPPIdentifier *)NULL)
  24. {
  25. assert(_type != NULL);
  26. if (_type->_declaration == (CPPTypeDeclaration *)NULL) {
  27. _type->_declaration = this;
  28. }
  29. }
  30. ////////////////////////////////////////////////////////////////////
  31. // Function: CPPTypeDeclaration::substitute_decl
  32. // Access: Public, Virtual
  33. // Description:
  34. ////////////////////////////////////////////////////////////////////
  35. CPPDeclaration *CPPTypeDeclaration::
  36. substitute_decl(CPPDeclaration::SubstDecl &subst,
  37. CPPScope *current_scope, CPPScope *global_scope) {
  38. CPPDeclaration *decl =
  39. CPPInstance::substitute_decl(subst, current_scope, global_scope);
  40. assert(decl != NULL);
  41. if (decl->as_type_declaration()) {
  42. return decl;
  43. }
  44. assert(decl->as_instance() != NULL);
  45. return new CPPTypeDeclaration(decl->as_instance()->_type);
  46. }
  47. ////////////////////////////////////////////////////////////////////
  48. // Function: CPPTypeDeclaration::output
  49. // Access: Public, Virtual
  50. // Description:
  51. ////////////////////////////////////////////////////////////////////
  52. void CPPTypeDeclaration::
  53. output(ostream &out, int indent_level, CPPScope *scope, bool) const {
  54. _type->output(out, indent_level, scope, true);
  55. }
  56. ////////////////////////////////////////////////////////////////////
  57. // Function: CPPTypeDeclaration::get_subtype
  58. // Access: Public, Virtual
  59. // Description:
  60. ////////////////////////////////////////////////////////////////////
  61. CPPDeclaration::SubType CPPTypeDeclaration::
  62. get_subtype() const {
  63. return ST_type_declaration;
  64. }
  65. ////////////////////////////////////////////////////////////////////
  66. // Function: CPPTypeDeclaration::as_type_declaration
  67. // Access: Public, Virtual
  68. // Description:
  69. ////////////////////////////////////////////////////////////////////
  70. CPPTypeDeclaration *CPPTypeDeclaration::
  71. as_type_declaration() {
  72. return this;
  73. }