/usr/include/Synopsis/SymbolLookup/Symbol.hh is in libsynopsis0.12-dev 0.12-8.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | //
// Copyright (C) 2004 Stefan Seefeld
// All rights reserved.
// Licensed to the public under the terms of the GNU LGPL (>= 2),
// see the file COPYING for details.
//
#ifndef Synopsis_SymbolLookup_Symbol_hh_
#define Synopsis_SymbolLookup_Symbol_hh_
#include <Synopsis/PTree/Encoding.hh>
#include <Synopsis/PTree/Lists.hh>
namespace Synopsis
{
namespace SymbolLookup
{
class Symbol;
class VariableName;
class ConstName;
class TypeName;
class TypedefName;
class ClassName;
class EnumName;
class ClassTemplateName;
class FunctionName;
class FunctionTemplateName;
class NamespaceName;
class SymbolVisitor
{
public:
virtual ~SymbolVisitor() {}
virtual void visit(Symbol const *) = 0;
virtual void visit(VariableName const *) = 0;
virtual void visit(ConstName const *) = 0;
virtual void visit(TypeName const *) = 0;
virtual void visit(TypedefName const *) = 0;
virtual void visit(ClassName const *) = 0;
virtual void visit(EnumName const *) = 0;
virtual void visit(ClassTemplateName const *) = 0;
virtual void visit(FunctionName const *) = 0;
virtual void visit(FunctionTemplateName const *) = 0;
virtual void visit(NamespaceName const *) = 0;
};
class Scope;
class Class;
class Namespace;
class FunctionScope;
class Symbol
{
public:
Symbol(PTree::Encoding const &t, PTree::Node const *p, bool def, Scope *s)
: my_type(t), my_ptree(p), my_definition(def), my_scope(s) {}
virtual ~Symbol(){}
virtual void accept(SymbolVisitor *v) const { v->visit(this);}
PTree::Encoding const & type() const { return my_type;}
PTree::Node const * ptree() const { return my_ptree;}
bool is_definition() const { return my_definition;}
Scope * scope() const { return my_scope;}
private:
PTree::Encoding my_type;
PTree::Node const * my_ptree;
bool my_definition;
Scope * my_scope;
};
class VariableName : public Symbol
{
public:
VariableName(PTree::Encoding const &type, PTree::Node const *ptree,
bool def, Scope *s)
: Symbol(type, ptree, def, s) {}
virtual void accept(SymbolVisitor *v) const { v->visit(this);}
};
class ConstName : public VariableName
{
public:
ConstName(PTree::Encoding const &type, long v,
PTree::Node const *ptree, bool def, Scope *s)
: VariableName(type, ptree, def, s), my_defined(true), my_value(v) {}
ConstName(PTree::Encoding const &type,
PTree::Node const *ptree, bool def, Scope *s)
: VariableName(type, ptree, def, s), my_defined(false) {}
virtual void accept(SymbolVisitor *v) const { v->visit(this);}
bool defined() const { return my_defined;}
long value() const { return my_value;}
private:
bool my_defined;
long my_value;
};
class TypeName : public Symbol
{
public:
TypeName(PTree::Encoding const &type, PTree::Node const *ptree,
bool def, Scope *s)
: Symbol(type, ptree, def, s) {}
virtual void accept(SymbolVisitor *v) const { v->visit(this);}
};
class TypedefName : public TypeName
{
public:
TypedefName(PTree::Encoding const &type, PTree::Node const *ptree, Scope *scope)
: TypeName(type, ptree, false, scope) {}
virtual void accept(SymbolVisitor *v) const { v->visit(this);}
};
class ClassName : public TypeName
{
public:
ClassName(PTree::Encoding const &type, PTree::Node const *ptree, bool def, Scope *s)
: TypeName(type, ptree, def, s) {}
virtual void accept(SymbolVisitor *v) const { v->visit(this);}
//. Return the class scope associated with this symbol.
//. This will return 0 if the class definition hasn't been seen yet.
Class *as_scope() const;
};
class EnumName : public TypeName
{
public:
EnumName(PTree::Encoding const &type, PTree::Node const *ptree, Scope *scope)
: TypeName(type, ptree, true, scope) {}
virtual void accept(SymbolVisitor *v) const { v->visit(this);}
};
class ClassTemplateName : public Symbol
{
public:
ClassTemplateName(PTree::Encoding const &type, PTree::Node const *ptree, bool def,
Scope *s)
: Symbol(type, ptree, def, s) {}
virtual void accept(SymbolVisitor *v) const { v->visit(this);}
//. Return the class scope associated with this symbol.
//. This will return 0 if the class definition hasn't been seen yet.
Class *as_scope() const;
};
class FunctionName : public Symbol
{
public:
FunctionName(PTree::Encoding const &type, PTree::Node const *ptree,
bool def, Scope *s)
: Symbol(type, ptree, def, s) {}
virtual void accept(SymbolVisitor *v) const { v->visit(this);}
//. Return the function scope associated with this symbol.
//. This will return 0 if the function definition hasn't been seen yet.
FunctionScope *as_scope() const;
};
class FunctionTemplateName : public Symbol
{
public:
FunctionTemplateName(PTree::Encoding const &type, PTree::Node const *ptree, Scope *s)
: Symbol(type, ptree, true, s) {}
virtual void accept(SymbolVisitor *v) const { v->visit(this);}
//. Return the function scope associated with this symbol.
//. This will return 0 if the function definition hasn't been seen yet.
FunctionScope *as_scope() const;
};
class NamespaceName : public Symbol
{
public:
NamespaceName(PTree::Encoding const &type, PTree::Node const *ptree,
bool def, Scope *s)
: Symbol(type, ptree, def, s) {}
virtual void accept(SymbolVisitor *v) const { v->visit(this);}
//. Return the namespace scope associated with this symbol.
//. This will return 0 if the namespace definition hasn't been seen yet.
Namespace *as_scope() const;
};
}
}
#endif
|