cppTypeDeclaration.cxx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 cppTypeDeclaration.cxx
  10. * @author drose
  11. * @date 2000-08-14
  12. */
  13. #include "cppTypeDeclaration.h"
  14. /**
  15. * Constructs a new CPPTypeDeclaration object for the given type.
  16. */
  17. CPPTypeDeclaration::
  18. CPPTypeDeclaration(CPPType *type) :
  19. CPPInstance(type, nullptr)
  20. {
  21. assert(_type != nullptr);
  22. if (_type->_declaration == nullptr) {
  23. _type->_declaration = this;
  24. }
  25. }
  26. /**
  27. *
  28. */
  29. CPPDeclaration *CPPTypeDeclaration::
  30. substitute_decl(CPPDeclaration::SubstDecl &subst,
  31. CPPScope *current_scope, CPPScope *global_scope) {
  32. CPPDeclaration *decl =
  33. CPPInstance::substitute_decl(subst, current_scope, global_scope);
  34. assert(decl != nullptr);
  35. if (decl->as_type_declaration()) {
  36. return decl;
  37. }
  38. assert(decl->as_instance() != nullptr);
  39. return new CPPTypeDeclaration(decl->as_instance()->_type);
  40. }
  41. /**
  42. *
  43. */
  44. void CPPTypeDeclaration::
  45. output(std::ostream &out, int indent_level, CPPScope *scope, bool) const {
  46. _type->output(out, indent_level, scope, true);
  47. }
  48. /**
  49. *
  50. */
  51. CPPDeclaration::SubType CPPTypeDeclaration::
  52. get_subtype() const {
  53. return ST_type_declaration;
  54. }
  55. /**
  56. *
  57. */
  58. CPPTypeDeclaration *CPPTypeDeclaration::
  59. as_type_declaration() {
  60. return this;
  61. }