| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- // Filename: cppTemplateScope.C
- // Created by: drose (28Oct99)
- //
- ////////////////////////////////////////////////////////////////////
- #include "cppTemplateScope.h"
- #include "cppExtensionType.h"
- #include "cppClassTemplateParameter.h"
- #include "cppIdentifier.h"
- #include "cppTypedef.h"
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::Constructor
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPTemplateScope::
- CPPTemplateScope(CPPScope *parent_scope) :
- CPPScope(parent_scope, CPPNameComponent("template"), V_public)
- {
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::add_declaration
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- void CPPTemplateScope::
- add_declaration(CPPDeclaration *decl, CPPScope *global_scope,
- CPPPreprocessor *preprocessor,
- const cppyyltype &pos) {
- decl->_template_scope = this;
- assert(_parent_scope != NULL);
- _parent_scope->add_declaration(decl, global_scope, preprocessor, pos);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::add_enum_value
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- void CPPTemplateScope::
- add_enum_value(CPPInstance *inst) {
- inst->_template_scope = this;
- assert(_parent_scope != NULL);
- _parent_scope->add_enum_value(inst);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::define_extension_type
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- void CPPTemplateScope::
- define_extension_type(CPPExtensionType *type) {
- type->_template_scope = this;
- assert(_parent_scope != NULL);
- _parent_scope->define_extension_type(type);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::define_namespace
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- void CPPTemplateScope::
- define_namespace(CPPNamespace *scope) {
- assert(_parent_scope != NULL);
- _parent_scope->define_namespace(scope);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::add_using
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- void CPPTemplateScope::
- add_using(CPPUsing *using_decl, CPPScope *global_scope,
- CPPPreprocessor *error_sink) {
- assert(_parent_scope != NULL);
- _parent_scope->add_using(using_decl, global_scope, error_sink);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::add_template_parameter
- // Access: Public
- // Description:
- ////////////////////////////////////////////////////////////////////
- void CPPTemplateScope::
- add_template_parameter(CPPDeclaration *param) {
- _parameters._parameters.push_back(param);
- CPPClassTemplateParameter *cl = param->as_class_template_parameter();
- if (cl != NULL) {
- // Create an implicit typedef for this class parameter.
- string name = cl->_ident->get_local_name();
- _typedefs[name] = new CPPTypedef(new CPPInstance(cl, cl->_ident), false);
- }
- CPPInstance *inst = param->as_instance();
- if (inst != NULL) {
- // Register the variable for this value parameter.
- string name = inst->get_local_name();
- if (!name.empty()) {
- _variables[name] = inst;
- }
- }
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::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 CPPTemplateScope::
- is_fully_specified() const {
- return false;
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::get_simple_name
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- string CPPTemplateScope::
- get_simple_name() const {
- assert(_parent_scope != NULL);
- return _parent_scope->get_simple_name();
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::get_local_name
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- string CPPTemplateScope::
- get_local_name(CPPScope *scope) const {
- assert(_parent_scope != NULL);
- return _parent_scope->get_local_name(scope);
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::get_fully_scoped_name
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- string CPPTemplateScope::
- get_fully_scoped_name() const {
- assert(_parent_scope != NULL);
- return _parent_scope->get_fully_scoped_name();
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::output
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- void CPPTemplateScope::
- output(ostream &out, CPPScope *scope) const {
- CPPScope::output(out, scope);
- out << "< ";
- _parameters.output(out, scope);
- out << " >";
- }
- ////////////////////////////////////////////////////////////////////
- // Function: CPPTemplateScope::as_template_scope
- // Access: Public, Virtual
- // Description:
- ////////////////////////////////////////////////////////////////////
- CPPTemplateScope *CPPTemplateScope::
- as_template_scope() {
- return this;
- }
|