Synopsis - Cross-Reference

File: /Synopsis/Parsers/Cxx/ScopeInfo.hh
 1//
 2// Copyright (C) 2001 Stephen Davies
 3// Copyright (C) 2001 Stefan Seefeld
 4// All rights reserved.
 5// Licensed to the public under the terms of the GNU LGPL (>= 2),
 6// see the file COPYING for details.
 7//
 8
 9#ifndef ScopeInfo_hh_
10#define ScopeInfo_hh_
11
12#include <string>
13#include <map>
14#include <vector>
15#include "common.hh"
16#include "FakeGC.hh"
17
18class Dictionary;
19
20//. Forward declare ScopeInfo, used later in this file
21class ScopeInfo;
22
23//. Typedef for a Scope Search
24typedef std::vector<ScopeInfo*> ScopeSearch;
25
26//. This class encapsulates information about a Scope and its dictionary of names.
27//. Since the ASG::Scope is meant purely for documentation purposes, this
28//. class provides the extra information needed for operations such as name
29//. lookup (a dictionary of types, and links to using scopes).
30//.
31//. The using directives work as follows: Using directives effectively add all
32//. contained declarations to the namespace containing the directive, but they
33//. still need to be processed separately. To handle this each ScopeInfo
34//. remembers which other namespaces it is using {@see using_scopes}.
35//.
36//. One quirk is that all used namespaces are considered as a whole for
37//. overload resolution, *not* one at a time. To facilitate this 'dummy'
38//. scopeinfos are inserted into the ScopeSearch of a containing namespace,
39//. which the algorithms recognize. (TODO: consider a wrapper(?) a.la
40//. ASG::Inheritance)
41struct ScopeInfo : public FakeGC::LightObject
42{
43    //. Constructor
44    ScopeInfo(ASG::Scope* s);
45
46    //. Constructor that creates a Dummy 'using' scope referencing 's'
47    ScopeInfo(ScopeInfo* s);
48
49    //. Destructor
50    ~ScopeInfo();
51
52    //. Dictionary for this scope
53    Dictionary* dict;
54    //class Dictionary* dict; <-- used to be this, but it confuses parser
55    //--->MAKE INTO TESTCASE!!!
56
57    //. The declaration for this scope
58    ASG::Scope* scope_decl;
59
60    //. The list of scopes to search for this scope, including this
61    ScopeSearch search;
62
63    //. The list of scopes in the search because they are 'using'd
64    ScopeSearch using_scopes;
65
66    //. The list of scopes 'using' this one
67    ScopeSearch used_by;
68
69    //. True only if this is a dummy Scope representing the use of
70    //. another. If this is the case, then only 'dict' is set
71    bool is_using;
72
73    //. Current accessability
74    ASG::Access access;
75
76    //. Counts of named sub-namespaces. The names are things like "if", "while"
77    //. etc. This is for the purely aesthetic purpose of being able to name
78    //. anonymous namespaces like "`if `while `if2 `do" instead of "`if1 `while2
79    //. `if3 `do4" or even "`0001 `0002 `0003 `0004" as OpenC++ does.
80    std::map<std::string, int> nscounts;
81    int getCount(const std::string& name);
82};
83
84#endif
85// vim: set ts=8 sts=4 sw=4 et: