| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379 |
- /**
- * PANDA 3D SOFTWARE
- * Copyright (c) Carnegie Mellon University. All rights reserved.
- *
- * All use of this software is subject to the terms of the revised BSD
- * license. You should have received a copy of this license along
- * with this source code in a file named "LICENSE."
- *
- * @file cppDeclaration.cxx
- * @author drose
- * @date 1999-10-19
- */
- #include "cppDeclaration.h"
- #include "cppPreprocessor.h"
- /**
- *
- */
- CPPDeclaration::
- CPPDeclaration(const CPPFile &file, CPPAttributeList attr) :
- _file(file),
- _attributes(std::move(attr))
- {
- _vis = V_unknown;
- _template_scope = nullptr;
- _leading_comment = nullptr;
- }
- /**
- *
- */
- CPPDeclaration::
- CPPDeclaration(const CPPDeclaration ©) :
- _vis(copy._vis),
- _template_scope(copy._template_scope),
- _file(copy._file),
- _leading_comment(copy._leading_comment),
- _attributes(copy._attributes)
- {
- }
- /**
- *
- */
- CPPDeclaration &CPPDeclaration::
- operator = (const CPPDeclaration ©) {
- _vis = copy._vis;
- _template_scope = copy._template_scope;
- _file = copy._file;
- _leading_comment = copy._leading_comment;
- _attributes = copy._attributes;
- return *this;
- }
- /**
- *
- */
- bool CPPDeclaration::
- operator == (const CPPDeclaration &other) const {
- if (get_subtype() != other.get_subtype()) {
- return false;
- }
- return is_equal(&other);
- }
- /**
- *
- */
- bool CPPDeclaration::
- operator != (const CPPDeclaration &other) const {
- return !(*this == other);
- }
- /**
- *
- */
- bool CPPDeclaration::
- operator < (const CPPDeclaration &other) const {
- if (get_subtype() != other.get_subtype()) {
- return get_subtype() < other.get_subtype();
- }
- return is_less(&other);
- }
- /**
- * Returns true if this is a template declaration of some kind: a template
- * function or a template class, typically.
- */
- bool CPPDeclaration::
- is_template() const {
- return _template_scope != nullptr;
- }
- /**
- * If is_template(), above, returns true, this returns the CPPTemplateScope in
- * which this particular template declaration is defined. This scope includes
- * the information about the template parameters.
- */
- CPPTemplateScope *CPPDeclaration::
- get_template_scope() const {
- return _template_scope;
- }
- /**
- * Returns true if this declaration is an actual, factual declaration, or
- * false if some part of the declaration depends on a template parameter which
- * has not yet been instantiated.
- */
- bool CPPDeclaration::
- is_fully_specified() const {
- return !is_template();
- }
- /**
- *
- */
- CPPDeclaration *CPPDeclaration::
- instantiate(const CPPTemplateParameterList *,
- CPPScope *, CPPScope *,
- CPPPreprocessor *error_sink) const {
- if (error_sink != nullptr) {
- error_sink->warning("Ignoring template parameters");
- }
- return (CPPDeclaration *)this;
- }
- /**
- *
- */
- CPPDeclaration *CPPDeclaration::
- substitute_decl(SubstDecl &subst, CPPScope *, CPPScope *) {
- SubstDecl::const_iterator si = subst.find(this);
- if (si != subst.end()) {
- assert((*si).second != nullptr);
- return (*si).second;
- }
- return this;
- }
- /**
- *
- */
- void CPPDeclaration::
- output(std::ostream &out, int indent_level, CPPScope *scope, bool complete) const {
- out << _attributes;
- }
- /**
- *
- */
- CPPDeclaration::SubType CPPDeclaration::
- get_subtype() const {
- return ST_empty;
- }
- /**
- *
- */
- CPPInstance *CPPDeclaration::
- as_instance() {
- return nullptr;
- }
- /**
- *
- */
- CPPClassTemplateParameter *CPPDeclaration::
- as_class_template_parameter() {
- return nullptr;
- }
- /**
- *
- */
- CPPTypedefType *CPPDeclaration::
- as_typedef_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPTypeDeclaration *CPPDeclaration::
- as_type_declaration() {
- return nullptr;
- }
- /**
- *
- */
- CPPExpression *CPPDeclaration::
- as_expression() {
- return nullptr;
- }
- /**
- *
- */
- CPPType *CPPDeclaration::
- as_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPNamespace *CPPDeclaration::
- as_namespace() {
- return nullptr;
- }
- /**
- *
- */
- CPPUsing *CPPDeclaration::
- as_using() {
- return nullptr;
- }
- /**
- *
- */
- CPPSimpleType *CPPDeclaration::
- as_simple_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPPointerType *CPPDeclaration::
- as_pointer_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPReferenceType *CPPDeclaration::
- as_reference_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPArrayType *CPPDeclaration::
- as_array_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPConstType *CPPDeclaration::
- as_const_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPFunctionType *CPPDeclaration::
- as_function_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPFunctionGroup *CPPDeclaration::
- as_function_group() {
- return nullptr;
- }
- /**
- *
- */
- CPPExtensionType *CPPDeclaration::
- as_extension_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPStructType *CPPDeclaration::
- as_struct_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPEnumType *CPPDeclaration::
- as_enum_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPTBDType *CPPDeclaration::
- as_tbd_type() {
- return nullptr;
- }
- /**
- *
- */
- CPPTypeProxy *CPPDeclaration::
- as_type_proxy() {
- return nullptr;
- }
- /**
- *
- */
- CPPMakeProperty *CPPDeclaration::
- as_make_property() {
- return nullptr;
- }
- /**
- *
- */
- CPPMakeSeq *CPPDeclaration::
- as_make_seq() {
- return nullptr;
- }
- /**
- *
- */
- CPPClosureType *CPPDeclaration::
- as_closure_type() {
- return nullptr;
- }
- /**
- * Called by CPPDeclaration to determine whether this type is equivalent to
- * another type of the same type.
- */
- bool CPPDeclaration::
- is_equal(const CPPDeclaration *other) const {
- return this == other;
- }
- /**
- * Called by CPPDeclaration to determine whether this type should be ordered
- * before another type of the same type, in an arbitrary but fixed ordering.
- */
- bool CPPDeclaration::
- is_less(const CPPDeclaration *other) const {
- return this < other;
- }
- std::ostream &
- operator << (std::ostream &out, const CPPDeclaration::SubstDecl &subst) {
- CPPDeclaration::SubstDecl::const_iterator it;
- for (it = subst.begin(); it != subst.end(); ++it) {
- out << " ";
- if (it->first == nullptr) {
- out << "(null)";
- } else {
- out << *(it->first);
- }
- out << " -> ";
- if (it->second == nullptr) {
- out << "(null)";
- } else {
- out << *(it->second);
- }
- out << "\n";
- }
- return out;
- }
|