00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef _typeinfo_h
00016 #define _typeinfo_h
00017
00018 #include "types.h"
00019
00020 class Ptree;
00021 class Class;
00022 class Environment;
00023 class Bind;
00024
00025 enum TypeInfoId {
00026 UndefType,
00027 BuiltInType, ClassType, EnumType, TemplateType,
00028 PointerType, ReferenceType, PointerToMemberType,
00029 ArrayType, FunctionType
00030 };
00031
00032
00033
00034 enum {
00035 CharType = 1, IntType = 2, ShortType = 4, LongType = 8,
00036 LongLongType = 16, SignedType = 32, UnsignedType = 64, FloatType = 128,
00037 DoubleType = 256, LongDoubleType = 512, VoidType = 1024,
00038 BooleanType = 2048
00039 };
00040
00041
00042
00043
00044
00045 class OCXXMOP TypeInfo : public LightObject {
00046 public:
00047 TypeInfo();
00048 void Unknown();
00049 void Set(char*, Environment*);
00050 void Set(Class*);
00051 void SetVoid();
00052 void SetInt();
00053 void SetMember(Ptree*);
00054
00055 TypeInfoId WhatIs();
00056
00057 bool IsNoReturnType();
00058
00059 bool IsConst();
00060 bool IsVolatile();
00061
00062 uint IsBuiltInType();
00063 bool IsFunction();
00064 bool IsEllipsis();
00065 bool IsPointerType();
00066 bool IsReferenceType();
00067 bool IsArray();
00068 bool IsPointerToMember();
00069 bool IsTemplateClass();
00070 Class* ClassMetaobject();
00071 bool IsClass(Class*&);
00072 bool IsEnum();
00073 bool IsEnum(Ptree*& spec);
00074
00075 void Dereference() { --refcount; }
00076 void Dereference(TypeInfo&);
00077 void Reference() { ++refcount; }
00078 void Reference(TypeInfo&);
00079 bool NthArgument(int, TypeInfo&);
00080 int NumOfArguments();
00081 bool NthTemplateArgument(int, TypeInfo&);
00082
00083 Ptree* FullTypeName();
00084 Ptree* MakePtree(Ptree* = nil);
00085
00086 private:
00087 static Ptree* GetQualifiedName(Environment*, Ptree*);
00088 static Ptree* GetQualifiedName2(Class*);
00089 void Normalize();
00090 bool ResolveTypedef(Environment*&, char*&, bool);
00091
00092 static char* SkipCv(char*, Environment*&);
00093 static char* SkipName(char*, Environment*);
00094 static char* GetReturnType(char*, Environment*);
00095 static char* SkipType(char*, Environment*);
00096
00097 private:
00098 int refcount;
00099 char* encode;
00100 Class* metaobject;
00101 Environment* env;
00102 };
00103
00104 #endif