| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386 |
- // Filename: cppDeclaration.cxx
- // Created by: drose (19Oct99)
- //
- ////////////////////////////////////////////////////////////////////
- //
- // PANDA 3D SOFTWARE
- // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
- //
- // All use of this software is subject to the terms of the Panda 3d
- // Software license. You should have received a copy of this license
- // along with this source code; you will also find a current copy of
- // the license at http://etc.cmu.edu/panda3d/docs/license/ .
- //
- // To contact the maintainers of this program write to
- // [email protected] .
- //
- ////////////////////////////////////////////////////////////////////
- #include "cppDeclaration.h"
- #include "cppPreprocessor.h"
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::Constructor
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPDeclaration::
- CPPDeclaration(const CPPFile &file) :
- _file(file)
- {
- _vis = V_unknown;
- _template_scope = NULL;
- _leading_comment = (CPPCommentBlock *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::Copy Constructor
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPDeclaration::
- CPPDeclaration(const CPPDeclaration ©) :
- _vis(copy._vis),
- _template_scope(copy._template_scope),
- _file(copy._file),
- _leading_comment(copy._leading_comment)
- {
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::Destructor
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPDeclaration::
- ~CPPDeclaration() {
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::Equivalence Operator
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- bool CPPDeclaration::
- operator == (const CPPDeclaration &other) const {
- if (get_subtype() != other.get_subtype()) {
- return false;
- }
- return is_equal(&other);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::Nonequivalence Operator
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- bool CPPDeclaration::
- operator != (const CPPDeclaration &other) const {
- return !(*this == other);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::Ordering Operator
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- bool CPPDeclaration::
- operator < (const CPPDeclaration &other) const {
- if (get_subtype() != other.get_subtype()) {
- return get_subtype() < other.get_subtype();
- }
- return is_less(&other);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::is_template
- // Access: Public
- // Description: 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 != NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::get_template_scope
- // Access: Public
- // Description: 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;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::is_fully_specified
- // Access: Public, Virtual
- // Description: 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();
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::instantiate
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPDeclaration *CPPDeclaration::
- instantiate(const CPPTemplateParameterList *,
- CPPScope *, CPPScope *,
- CPPPreprocessor *error_sink) const {
- if (error_sink != NULL) {
- error_sink->warning("Ignoring template parameters");
- }
- return (CPPDeclaration *)this;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::substitute_decl
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPDeclaration *CPPDeclaration::
- substitute_decl(SubstDecl &subst, CPPScope *, CPPScope *) {
- SubstDecl::const_iterator si = subst.find(this);
- if (si != subst.end()) {
- return (*si).second;
- }
- return this;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_instance
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPInstance *CPPDeclaration::
- as_instance() {
- return (CPPInstance *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_class_template_parameter
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPClassTemplateParameter *CPPDeclaration::
- as_class_template_parameter() {
- return (CPPClassTemplateParameter *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_typedef
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPTypedef *CPPDeclaration::
- as_typedef() {
- return (CPPTypedef *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_type_declaration
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPTypeDeclaration *CPPDeclaration::
- as_type_declaration() {
- return (CPPTypeDeclaration *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_expression
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPExpression *CPPDeclaration::
- as_expression() {
- return (CPPExpression *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPType *CPPDeclaration::
- as_type() {
- return (CPPType *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_namespace
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPNamespace *CPPDeclaration::
- as_namespace() {
- return (CPPNamespace *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_using
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPUsing *CPPDeclaration::
- as_using() {
- return (CPPUsing *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_simple_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPSimpleType *CPPDeclaration::
- as_simple_type() {
- return (CPPSimpleType *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_pointer_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPPointerType *CPPDeclaration::
- as_pointer_type() {
- return (CPPPointerType *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_reference_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPReferenceType *CPPDeclaration::
- as_reference_type() {
- return (CPPReferenceType *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_array_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPArrayType *CPPDeclaration::
- as_array_type() {
- return (CPPArrayType *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_const_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPConstType *CPPDeclaration::
- as_const_type() {
- return (CPPConstType *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_function_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPFunctionType *CPPDeclaration::
- as_function_type() {
- return (CPPFunctionType *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_function_group
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPFunctionGroup *CPPDeclaration::
- as_function_group() {
- return (CPPFunctionGroup *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_extension_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPExtensionType *CPPDeclaration::
- as_extension_type() {
- return (CPPExtensionType *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_struct_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPStructType *CPPDeclaration::
- as_struct_type() {
- return (CPPStructType *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_enum_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPEnumType *CPPDeclaration::
- as_enum_type() {
- return (CPPEnumType *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_tbd_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPTBDType *CPPDeclaration::
- as_tbd_type() {
- return (CPPTBDType *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::as_type_proxy
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPTypeProxy *CPPDeclaration::
- as_type_proxy() {
- return (CPPTypeProxy *)NULL;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::is_equal
- // Access: Protected, Virtual
- // Description: 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;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPDeclaration::is_less
- // Access: Protected, Virtual
- // Description: 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;
- }
|