00001 // Filename: cppDeclaration.cxx 00002 // Created by: drose (19Oct99) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 #include "cppDeclaration.h" 00021 #include "cppPreprocessor.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Function: CPPDeclaration::Constructor 00025 // Access: Public 00026 // Description: 00027 //////////////////////////////////////////////////////////////////// 00028 CPPDeclaration:: 00029 CPPDeclaration(const CPPFile &file) : 00030 _file(file) 00031 { 00032 _vis = V_unknown; 00033 _template_scope = NULL; 00034 _leading_comment = (CPPCommentBlock *)NULL; 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: CPPDeclaration::Copy Constructor 00039 // Access: Public 00040 // Description: 00041 //////////////////////////////////////////////////////////////////// 00042 CPPDeclaration:: 00043 CPPDeclaration(const CPPDeclaration ©) : 00044 _vis(copy._vis), 00045 _template_scope(copy._template_scope), 00046 _file(copy._file), 00047 _leading_comment(copy._leading_comment) 00048 { 00049 } 00050 00051 //////////////////////////////////////////////////////////////////// 00052 // Function: CPPDeclaration::Destructor 00053 // Access: Public 00054 // Description: 00055 //////////////////////////////////////////////////////////////////// 00056 CPPDeclaration:: 00057 ~CPPDeclaration() { 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: CPPDeclaration::Equivalence Operator 00062 // Access: Public 00063 // Description: 00064 //////////////////////////////////////////////////////////////////// 00065 bool CPPDeclaration:: 00066 operator == (const CPPDeclaration &other) const { 00067 if (get_subtype() != other.get_subtype()) { 00068 return false; 00069 } 00070 return is_equal(&other); 00071 } 00072 00073 //////////////////////////////////////////////////////////////////// 00074 // Function: CPPDeclaration::Nonequivalence Operator 00075 // Access: Public 00076 // Description: 00077 //////////////////////////////////////////////////////////////////// 00078 bool CPPDeclaration:: 00079 operator != (const CPPDeclaration &other) const { 00080 return !(*this == other); 00081 } 00082 00083 //////////////////////////////////////////////////////////////////// 00084 // Function: CPPDeclaration::Ordering Operator 00085 // Access: Public 00086 // Description: 00087 //////////////////////////////////////////////////////////////////// 00088 bool CPPDeclaration:: 00089 operator < (const CPPDeclaration &other) const { 00090 if (get_subtype() != other.get_subtype()) { 00091 return get_subtype() < other.get_subtype(); 00092 } 00093 return is_less(&other); 00094 } 00095 00096 //////////////////////////////////////////////////////////////////// 00097 // Function: CPPDeclaration::is_template 00098 // Access: Public 00099 // Description: Returns true if this is a template declaration of 00100 // some kind: a template function or a template class, 00101 // typically. 00102 //////////////////////////////////////////////////////////////////// 00103 bool CPPDeclaration:: 00104 is_template() const { 00105 return _template_scope != NULL; 00106 } 00107 00108 //////////////////////////////////////////////////////////////////// 00109 // Function: CPPDeclaration::get_template_scope 00110 // Access: Public 00111 // Description: If is_template(), above, returns true, this returns 00112 // the CPPTemplateScope in which this particular 00113 // template declaration is defined. This scope includes 00114 // the information about the template parameters. 00115 //////////////////////////////////////////////////////////////////// 00116 CPPTemplateScope *CPPDeclaration:: 00117 get_template_scope() const { 00118 return _template_scope; 00119 } 00120 00121 //////////////////////////////////////////////////////////////////// 00122 // Function: CPPDeclaration::is_fully_specified 00123 // Access: Public, Virtual 00124 // Description: Returns true if this declaration is an actual, 00125 // factual declaration, or false if some part of the 00126 // declaration depends on a template parameter which has 00127 // not yet been instantiated. 00128 //////////////////////////////////////////////////////////////////// 00129 bool CPPDeclaration:: 00130 is_fully_specified() const { 00131 return !is_template(); 00132 } 00133 00134 //////////////////////////////////////////////////////////////////// 00135 // Function: CPPDeclaration::instantiate 00136 // Access: Public, Virtual 00137 // Description: 00138 //////////////////////////////////////////////////////////////////// 00139 CPPDeclaration *CPPDeclaration:: 00140 instantiate(const CPPTemplateParameterList *, 00141 CPPScope *, CPPScope *, 00142 CPPPreprocessor *error_sink) const { 00143 if (error_sink != NULL) { 00144 error_sink->warning("Ignoring template parameters"); 00145 } 00146 return (CPPDeclaration *)this; 00147 } 00148 00149 //////////////////////////////////////////////////////////////////// 00150 // Function: CPPDeclaration::substitute_decl 00151 // Access: Public, Virtual 00152 // Description: 00153 //////////////////////////////////////////////////////////////////// 00154 CPPDeclaration *CPPDeclaration:: 00155 substitute_decl(SubstDecl &subst, CPPScope *, CPPScope *) { 00156 SubstDecl::const_iterator si = subst.find(this); 00157 if (si != subst.end()) { 00158 return (*si).second; 00159 } 00160 return this; 00161 } 00162 00163 //////////////////////////////////////////////////////////////////// 00164 // Function: CPPDeclaration::as_instance 00165 // Access: Public, Virtual 00166 // Description: 00167 //////////////////////////////////////////////////////////////////// 00168 CPPInstance *CPPDeclaration:: 00169 as_instance() { 00170 return (CPPInstance *)NULL; 00171 } 00172 00173 //////////////////////////////////////////////////////////////////// 00174 // Function: CPPDeclaration::as_class_template_parameter 00175 // Access: Public, Virtual 00176 // Description: 00177 //////////////////////////////////////////////////////////////////// 00178 CPPClassTemplateParameter *CPPDeclaration:: 00179 as_class_template_parameter() { 00180 return (CPPClassTemplateParameter *)NULL; 00181 } 00182 00183 //////////////////////////////////////////////////////////////////// 00184 // Function: CPPDeclaration::as_typedef 00185 // Access: Public, Virtual 00186 // Description: 00187 //////////////////////////////////////////////////////////////////// 00188 CPPTypedef *CPPDeclaration:: 00189 as_typedef() { 00190 return (CPPTypedef *)NULL; 00191 } 00192 00193 //////////////////////////////////////////////////////////////////// 00194 // Function: CPPDeclaration::as_type_declaration 00195 // Access: Public, Virtual 00196 // Description: 00197 //////////////////////////////////////////////////////////////////// 00198 CPPTypeDeclaration *CPPDeclaration:: 00199 as_type_declaration() { 00200 return (CPPTypeDeclaration *)NULL; 00201 } 00202 00203 //////////////////////////////////////////////////////////////////// 00204 // Function: CPPDeclaration::as_expression 00205 // Access: Public, Virtual 00206 // Description: 00207 //////////////////////////////////////////////////////////////////// 00208 CPPExpression *CPPDeclaration:: 00209 as_expression() { 00210 return (CPPExpression *)NULL; 00211 } 00212 00213 //////////////////////////////////////////////////////////////////// 00214 // Function: CPPDeclaration::as_type 00215 // Access: Public, Virtual 00216 // Description: 00217 //////////////////////////////////////////////////////////////////// 00218 CPPType *CPPDeclaration:: 00219 as_type() { 00220 return (CPPType *)NULL; 00221 } 00222 00223 //////////////////////////////////////////////////////////////////// 00224 // Function: CPPDeclaration::as_namespace 00225 // Access: Public, Virtual 00226 // Description: 00227 //////////////////////////////////////////////////////////////////// 00228 CPPNamespace *CPPDeclaration:: 00229 as_namespace() { 00230 return (CPPNamespace *)NULL; 00231 } 00232 00233 //////////////////////////////////////////////////////////////////// 00234 // Function: CPPDeclaration::as_using 00235 // Access: Public, Virtual 00236 // Description: 00237 //////////////////////////////////////////////////////////////////// 00238 CPPUsing *CPPDeclaration:: 00239 as_using() { 00240 return (CPPUsing *)NULL; 00241 } 00242 00243 //////////////////////////////////////////////////////////////////// 00244 // Function: CPPDeclaration::as_simple_type 00245 // Access: Public, Virtual 00246 // Description: 00247 //////////////////////////////////////////////////////////////////// 00248 CPPSimpleType *CPPDeclaration:: 00249 as_simple_type() { 00250 return (CPPSimpleType *)NULL; 00251 } 00252 00253 //////////////////////////////////////////////////////////////////// 00254 // Function: CPPDeclaration::as_pointer_type 00255 // Access: Public, Virtual 00256 // Description: 00257 //////////////////////////////////////////////////////////////////// 00258 CPPPointerType *CPPDeclaration:: 00259 as_pointer_type() { 00260 return (CPPPointerType *)NULL; 00261 } 00262 00263 //////////////////////////////////////////////////////////////////// 00264 // Function: CPPDeclaration::as_reference_type 00265 // Access: Public, Virtual 00266 // Description: 00267 //////////////////////////////////////////////////////////////////// 00268 CPPReferenceType *CPPDeclaration:: 00269 as_reference_type() { 00270 return (CPPReferenceType *)NULL; 00271 } 00272 00273 //////////////////////////////////////////////////////////////////// 00274 // Function: CPPDeclaration::as_array_type 00275 // Access: Public, Virtual 00276 // Description: 00277 //////////////////////////////////////////////////////////////////// 00278 CPPArrayType *CPPDeclaration:: 00279 as_array_type() { 00280 return (CPPArrayType *)NULL; 00281 } 00282 00283 //////////////////////////////////////////////////////////////////// 00284 // Function: CPPDeclaration::as_const_type 00285 // Access: Public, Virtual 00286 // Description: 00287 //////////////////////////////////////////////////////////////////// 00288 CPPConstType *CPPDeclaration:: 00289 as_const_type() { 00290 return (CPPConstType *)NULL; 00291 } 00292 00293 //////////////////////////////////////////////////////////////////// 00294 // Function: CPPDeclaration::as_function_type 00295 // Access: Public, Virtual 00296 // Description: 00297 //////////////////////////////////////////////////////////////////// 00298 CPPFunctionType *CPPDeclaration:: 00299 as_function_type() { 00300 return (CPPFunctionType *)NULL; 00301 } 00302 00303 //////////////////////////////////////////////////////////////////// 00304 // Function: CPPDeclaration::as_function_group 00305 // Access: Public, Virtual 00306 // Description: 00307 //////////////////////////////////////////////////////////////////// 00308 CPPFunctionGroup *CPPDeclaration:: 00309 as_function_group() { 00310 return (CPPFunctionGroup *)NULL; 00311 } 00312 00313 //////////////////////////////////////////////////////////////////// 00314 // Function: CPPDeclaration::as_extension_type 00315 // Access: Public, Virtual 00316 // Description: 00317 //////////////////////////////////////////////////////////////////// 00318 CPPExtensionType *CPPDeclaration:: 00319 as_extension_type() { 00320 return (CPPExtensionType *)NULL; 00321 } 00322 00323 //////////////////////////////////////////////////////////////////// 00324 // Function: CPPDeclaration::as_struct_type 00325 // Access: Public, Virtual 00326 // Description: 00327 //////////////////////////////////////////////////////////////////// 00328 CPPStructType *CPPDeclaration:: 00329 as_struct_type() { 00330 return (CPPStructType *)NULL; 00331 } 00332 00333 //////////////////////////////////////////////////////////////////// 00334 // Function: CPPDeclaration::as_enum_type 00335 // Access: Public, Virtual 00336 // Description: 00337 //////////////////////////////////////////////////////////////////// 00338 CPPEnumType *CPPDeclaration:: 00339 as_enum_type() { 00340 return (CPPEnumType *)NULL; 00341 } 00342 00343 //////////////////////////////////////////////////////////////////// 00344 // Function: CPPDeclaration::as_tbd_type 00345 // Access: Public, Virtual 00346 // Description: 00347 //////////////////////////////////////////////////////////////////// 00348 CPPTBDType *CPPDeclaration:: 00349 as_tbd_type() { 00350 return (CPPTBDType *)NULL; 00351 } 00352 00353 //////////////////////////////////////////////////////////////////// 00354 // Function: CPPDeclaration::as_type_proxy 00355 // Access: Public, Virtual 00356 // Description: 00357 //////////////////////////////////////////////////////////////////// 00358 CPPTypeProxy *CPPDeclaration:: 00359 as_type_proxy() { 00360 return (CPPTypeProxy *)NULL; 00361 } 00362 00363 00364 //////////////////////////////////////////////////////////////////// 00365 // Function: CPPDeclaration::is_equal 00366 // Access: Protected, Virtual 00367 // Description: Called by CPPDeclaration to determine whether this 00368 // type is equivalent to another type of the same type. 00369 //////////////////////////////////////////////////////////////////// 00370 bool CPPDeclaration:: 00371 is_equal(const CPPDeclaration *other) const { 00372 return this == other; 00373 } 00374 00375 //////////////////////////////////////////////////////////////////// 00376 // Function: CPPDeclaration::is_less 00377 // Access: Protected, Virtual 00378 // Description: Called by CPPDeclaration to determine whether this 00379 // type should be ordered before another type of the 00380 // same type, in an arbitrary but fixed ordering. 00381 //////////////////////////////////////////////////////////////////// 00382 bool CPPDeclaration:: 00383 is_less(const CPPDeclaration *other) const { 00384 return this < other; 00385 } 00386