cppTypeDeclaration.cxx 2.9 KB

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