/usr/include/Synopsis/TypeAnalysis/Type.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 | //
// Copyright (C) 2005 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_TypeAnalysis_Type_hh_
#define Synopsis_TypeAnalysis_Type_hh_
#include <Synopsis/TypeAnalysis/Visitor.hh>
#include <string>
#include <ostream>
#include <iterator>
namespace Synopsis
{
namespace TypeAnalysis
{
class Type
{
public:
Type(std::string const &name) : my_name(name), my_refcounter(1) {}
virtual ~Type() {}
const std::string &name() const { return my_name;}
virtual void accept(Visitor *visitor) = 0;
virtual void ref() const { ++my_refcounter;}
virtual void deref() const { if (--my_refcounter) delete this;}
// TODO: add 'new' / 'delete' operators for optimization.
private:
const std::string my_name;
mutable size_t my_refcounter;
};
class BuiltinType : public Type
{
public:
BuiltinType(std::string const &name) : Type(name) {}
virtual void accept(Visitor *visitor) { visitor->visit(this);}
// BuiltinType is preallocated and thus is destructed at program termination.
virtual void ref() const {}
virtual void deref() const {}
};
extern BuiltinType BOOL;
extern BuiltinType CHAR;
extern BuiltinType WCHAR;
extern BuiltinType SHORT;
extern BuiltinType INT;
extern BuiltinType LONG;
extern BuiltinType FLOAT;
extern BuiltinType DOUBLE;
extern BuiltinType UCHAR;
extern BuiltinType USHORT;
extern BuiltinType UINT;
extern BuiltinType ULONG;
extern BuiltinType SCHAR;
extern BuiltinType SSHORT;
extern BuiltinType SINT;
extern BuiltinType SLONG;
class Enum : public Type
{
public:
Enum(std::string const &name) : Type(name) {}
virtual void accept(Visitor *visitor) { visitor->visit(this);}
};
class Compound : public Type
{
public:
Compound(std::string const &name) : Type(name) {}
};
class Class : public Compound
{
public:
enum Kind { STRUCT, CLASS};
Class(Kind kind, std::string const &name) : Compound(name), my_kind(kind) {}
virtual void accept(Visitor *visitor) { visitor->visit(this);}
private:
Kind my_kind;
};
class Union : public Compound
{
public:
Union(std::string const &name) : Compound(name) {}
virtual void accept(Visitor *visitor) { visitor->visit(this);}
private:
};
class CVType : public Type
{
public:
enum CVQualifier { NONE=0x0, CONST=0x1, VOLATILE=0x2};
CVType(Type const *type, CVQualifier q)
: Type(names[q]), my_type(type), my_qual(q) {}
virtual void accept(Visitor *visitor) { visitor->visit(this);}
private:
static std::string const names[4];
Type const *my_type;
CVQualifier my_qual;
};
class Pointer : public Type
{
public:
Pointer(Type const *type) : Type("*"), my_type(type) {}
virtual void accept(Visitor *visitor) { visitor->visit(this);}
private:
Type const *my_type;
};
class Reference : public Type
{
public:
Reference(Type const *type) : Type("&"), my_type(type) {}
virtual void accept(Visitor *visitor) { visitor->visit(this);}
private:
Type const *my_type;
};
class Array : public Type
{
public:
Array(Type const *type) : Type("[]"), my_type(type) {}
virtual void accept(Visitor *visitor) { visitor->visit(this);}
private:
Type const *my_type;
};
class Function : public Type
{
public:
Function() : Type("") {}
virtual void accept(Visitor *visitor) { visitor->visit(this);}
private:
Type const *my_type;
};
class PointerToMember : public Type
{
public:
PointerToMember() : Type("") {}
virtual void accept(Visitor *visitor) { visitor->visit(this);}
private:
Type const *my_container;
Type const *my_member;
};
}
}
#endif
|