Modules | Files | Inheritance Tree | Inheritance Graph | Name Index | Config
File: Synopsis/Parser/C++/syn/scopeinfo.hh
    1| // Synopsis C++ Parser: scopeinfo.hh header file
    2| // Definition of the ScopeInfo class which stores info about each scope for
    3| // Builder and Lookup to use
    4| 
    5| // $Id: scopeinfo.hh,v 1.4 2002/11/17 12:11:44 chalky Exp $
    6| //
    7| // This file is a part of Synopsis.
    8| // Copyright (C) 2002 Stephen Davies
    9| //
   10| // Synopsis is free software; you can redistribute it and/or modify it
   11| // under the terms of the GNU General Public License as published by
   12| // the Free Software Foundation; either version 2 of the License, or
   13| // (at your option) any later version.
   14| //
   15| // This program is distributed in the hope that it will be useful,
   16| // but WITHOUT ANY WARRANTY; without even the implied warranty of
   17| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   18| // General Public License for more details.
   19| //
   20| // You should have received a copy of the GNU General Public License
   21| // along with this program; if not, write to the Free Software
   22| // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   23| // 02111-1307, USA.
   24| 
   25| #ifndef H_SYNOPSIS_CPP_SCOPEINFO
   26| #define H_SYNOPSIS_CPP_SCOPEINFO
   27| 
   28| #include <string>
   29| #include <map>
   30| #include <vector>
   31| #include "common.hh"
   32| 
   33| class Dictionary;
   34| 
   35| //. Forward declare ScopeInfo, used later in this file
   36| class ScopeInfo;
   37| 
   38| //. Typedef for a Scope Search
   39| typedef std::vector<ScopeInfo*> ScopeSearch;
   40| 
   41| //. This class encapsulates information about a Scope and its dictionary of names.
   42| //. Since the AST::Scope is meant purely for documentation purposes, this
   43| //. class provides the extra information needed for operations such as name
   44| //. lookup (a dictionary of types, and links to using scopes).
   45| //.
   46| //. The using directives work as follows: Using directives effectively add all
   47| //. contained declarations to the namespace containing the directive, but they
   48| //. still need to be processed separately. To handle this each ScopeInfo
   49| //. remembers which other namespaces it is using {@see using_scopes}.
   50| //.
   51| //. One quirk is that all used namespaces are considered as a whole for
   52| //. overload resolution, *not* one at a time. To facilitate this 'dummy'
   53| //. scopeinfos are inserted into the ScopeSearch of a containing namespace,
   54| //. which the algorithms recognize. (TODO: consider a wrapper(?) a.la
   55| //. AST::Inheritance)
   56| struct ScopeInfo : public cleanup
   57| {
   58|     //. Constructor
   59|     ScopeInfo(AST::Scope* s);
   60| 
   61|     //. Constructor that creates a Dummy 'using' scope referencing 's'
   62|     ScopeInfo(ScopeInfo* s);
   63| 
   64|     //. Destructor
   65|     ~ScopeInfo();
   66| 
   67|     //. Dictionary for this scope
   68|     Dictionary* dict;
   69|     //class Dictionary* dict; <-- used to be this, but it confuses parser
   70|     //--->MAKE INTO TESTCASE!!!
   71| 
   72|     //. The declaration for this scope
   73|     AST::Scope* scope_decl;
   74| 
   75|     //. The list of scopes to search for this scope, including this
   76|     ScopeSearch search;
   77| 
   78|     //. The list of scopes in the search because they are 'using'd
   79|     ScopeSearch using_scopes;
   80| 
   81|     //. The list of scopes 'using' this one
   82|     ScopeSearch used_by;
   83| 
   84|     //. True only if this is a dummy Scope representing the use of
   85|     //. another. If this is the case, then only 'dict' is set
   86|     bool is_using;
   87| 
   88|     //. Current accessability
   89|     AST::Access access;
   90| 
   91|     //. Counts of named sub-namespaces. The names are things like "if", "while"
   92|     //. etc. This is for the purely aesthetic purpose of being able to name
   93|     //. anonymous namespaces like "`if `while `if2 `do" instead of "`if1 `while2
   94|     //. `if3 `do4" or even "`0001 `0002 `0003 `0004" as OpenC++ does.
   95|     std::map<std::string, int> nscounts;
   96|     int getCount(const std::string& name);
   97| };
   98| 
   99| #endif
  100| // vim: set ts=8 sts=4 sw=4 et: