Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

encoding.h

Go to the documentation of this file.
00001 /*
00002   Copyright (C) 1997-2001 Shigeru Chiba, Tokyo Institute of Technology.
00003 
00004   Permission to use, copy, distribute and modify this software and   
00005   its documentation for any purpose is hereby granted without fee,        
00006   provided that the above copyright notice appear in all copies and that 
00007   both that copyright notice and this permission notice appear in 
00008   supporting documentation.
00009 
00010   Shigeru Chiba makes no representations about the suitability of this 
00011   software for any purpose.  It is provided "as is" without express or
00012   implied warranty.
00013 */
00014 
00015 #ifndef _encoding_h
00016 #define _encoding_h
00017 
00018 #include "types.h"
00019 
00020 #include <iostream>
00021 
00022 class Ptree;
00023 class Environment;
00024 class Bind;
00025 
00026 class Encoding {
00027 public:
00028     enum { MaxNameLen = 256 }; // const MaxNameLen = 256;
00029                                // MSVC doesn't compile
00030     Encoding() { len = 0; }
00031     Encoding(Encoding& e) { Reset(e); }
00032     void Clear() { len = 0; }
00033     void Reset(Encoding&);
00034     char* Get();
00035     bool IsEmpty() { return len == 0; }
00036 
00037     void CvQualify(Ptree*, Ptree* = nil);
00038     void SimpleConst() { Append("Ci", 2); }
00039     void GlobalScope();                         // ::Type
00040     void SimpleName(Ptree*);
00041     void NoName();
00042     void Template(Ptree*, Encoding&);
00043     void Qualified(int);
00044     void Destructor(Ptree*);
00045     void PtrOperator(int);
00046     void PtrToMember(Encoding&, int);
00047     void CastOperator(Encoding&);
00048     void Array() { Insert('A'); }
00049     void Function(Encoding& args) { Insert((char*)args.name, args.len); }
00050     void Recursion(Encoding& e) { Insert((char*)e.name, e.len); }
00051     void StartFuncArgs() { Append((unsigned char)'F'); }
00052     void EndFuncArgs() { Append((unsigned char)'_'); }
00053     void Void() { Append((unsigned char)'v'); }
00054     void EllipsisArg() { Append((unsigned char)'e'); }
00055     void NoReturnType() { Append((unsigned char)'?'); }
00056     void ValueTempParam() { Append((unsigned char)'*'); }
00057 
00058     void Insert(unsigned char);
00059     void Insert(char*, int);
00060     void Append(unsigned char);
00061     void Append(char*, int);
00062     void Append(Encoding& e) { Append((char*)e.name, e.len); }
00063     void AppendWithLen(char*, int);
00064     void AppendWithLen(Encoding& e) { AppendWithLen((char*)e.name, e.len); }
00065 
00066     static void Print(ostream&, char*);
00067     static char* GetBaseName(char*, int&, Environment*&);
00068     static Ptree* MakePtree(unsigned char*&, Ptree*);
00069 
00070     static Ptree* MakeQname(unsigned char*&);
00071     static Ptree* MakeLeaf(unsigned char*&);
00072     static bool IsSimpleName(unsigned char*);
00073     static Ptree* NameToPtree(char*, int);
00074 
00075     static unsigned char* GetTemplateArguments(unsigned char*, int&);
00076 
00077 private:
00078     static Environment* ResolveTypedefName(Environment*, char*, int);
00079     static int GetBaseNameIfTemplate(unsigned char*, Environment*&);
00080 
00081 private:
00082     unsigned char name[MaxNameLen];
00083     int len;
00084 
00085 public:
00086     static Ptree *bool_t, *char_t, *int_t, *short_t, *long_t,
00087                  *float_t, *double_t, *void_t;
00088 
00089     static Ptree *signed_t, *unsigned_t, *const_t, *volatile_t;
00090 
00091     static Ptree *operator_name, *new_operator, *anew_operator,
00092                  *delete_operator, *adelete_operator;
00093 
00094     static Ptree *star, *ampersand, *comma, *dots, *scope, *tilder,
00095                  *left_paren, *right_paren, *left_bracket, *right_bracket,
00096                  *left_angle, *right_angle;
00097 };
00098 
00099 #endif /* _encoding_h */

Generated on Mon Feb 10 17:32:46 2003 for VFiasco Semantics Compiler by doxygen1.2.15