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
|
#ifndef guard_opencxx_TypeInfo_h
#define guard_opencxx_TypeInfo_h
//@beginlicenses@
//@license{chiba-tokyo}{}@
//@license{contributors}{}@
//
// Copyright (C) 1997-2001 Shigeru Chiba, Tokyo Institute of Technology.
//
// Permission to use, copy, distribute and modify this software and
// its documentation for any purpose is hereby granted without fee,
// provided that the above copyright notice appears in all copies and that
// both that copyright notice and this permission notice appear in
// supporting documentation.
//
// Shigeru Chiba makes no representations about the suitability of this
// software for any purpose. It is provided "as is" without express or
// implied warranty.
//
// -----------------------------------------------------------------
//
// Permission to use, copy, distribute and modify this software and its
// documentation for any purpose is hereby granted without fee, provided that
// the above copyright notice appears in all copies and that both that copyright
// notice and this permission notice appear in supporting documentation.
//
// Other Contributors (see file AUTHORS) make(s) no representations about the suitability of this
// software for any purpose. It is provided "as is" without express or implied
// warranty.
//
// Copyright (C) Other Contributors (see file AUTHORS)
//
//@endlicenses@
#include <opencxx/parser/GC.h>
namespace Opencxx
{
class Ptree;
class Class;
class Environment;
class Bind;
enum TypeInfoId {
UndefType,
BuiltInType, ClassType, EnumType, TemplateType,
PointerType, ReferenceType, PointerToMemberType,
ArrayType, FunctionType
};
// These are used by TypeInfo::WhatBuiltinType()
//
enum {
CharType = 1, IntType = 2, ShortType = 4, LongType = 8,
LongLongType = 16, SignedType = 32, UnsignedType = 64, FloatType = 128,
DoubleType = 256, LongDoubleType = 512, VoidType = 1024,
BooleanType = 2048,
WideCharType = 4096
};
/*
TypeInfo interprets an encoded type name. For details of the encoded
type name, see class Encoding in encoding.h and encoding.cc.
*/
class TypeInfo : public LightObject {
public:
TypeInfo();
void Unknown();
void Set(char*, Environment*);
void Set(Class*);
void SetVoid();
void SetInt();
void SetMember(Ptree*);
void SetTypeInfo(Environment *);
TypeInfoId WhatIs();
bool IsNoReturnType();
bool IsConst();
bool IsVolatile();
unsigned int IsBuiltInType();
bool IsFunction();
bool IsEllipsis();
bool IsPointerType();
bool IsReferenceType();
bool IsArray();
bool IsPointerToMember();
bool IsTemplateClass();
Class* ClassMetaobject();
bool IsClass(Class*&);
bool IsEnum();
bool IsEnum(Ptree*& spec);
void Dereference() { --refcount; }
void Dereference(TypeInfo&);
void Reference() { ++refcount; }
void Reference(TypeInfo&);
bool NthArgument(int, TypeInfo&);
int NumOfArguments();
bool NthTemplateArgument(int, TypeInfo&);
Ptree* FullTypeName();
Ptree* MakePtree(Ptree* = 0);
private:
static Ptree* GetQualifiedName(Environment*, Ptree*);
static Ptree* GetQualifiedName2(Class*);
void Normalize();
bool ResolveTypedef(Environment*&, char*&, bool);
static char* SkipCv(char*, Environment*&);
static char* SkipName(char*, Environment*);
static char* GetReturnType(char*, Environment*);
static char* SkipType(char*, Environment*);
private:
int refcount;
char* encode;
Class* metaobject;
Environment* env;
};
}
#endif /* ! guard_opencxx_TypeInfo_h */
|