00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include <string.h>
00039 #include "ptree.h"
00040 #include "quote-class.h"
00041 #include "buffer.h"
00042
00043 Ptree* QuoteClass::TranslateMemberCall(Environment* env,
00044 Ptree* member, Ptree* args)
00045 {
00046 Ptree* name = StripClassQualifier(member);
00047 char* str;
00048
00049 if(Ptree::Eq(name, "qMake")){
00050 Ptree* arg1 = Ptree::First(Ptree::Second(args));
00051 if(arg1->Reify(str) && str != nil)
00052 return ProcessBackQuote(env, str, arg1, name);
00053 else
00054 ErrorMessage(env, "bad argument for qMake()", arg1, name);
00055 }
00056 else if(Ptree::Eq(name, "qMakeStatement")){
00057 WarnObsoleteness("Ptree::qMakeStatement()", "Ptree::qMake()");
00058 Ptree* arg1 = Ptree::First(Ptree::Second(args));
00059 if(arg1->Reify(str) && str != nil)
00060 return ProcessBackQuote(env, str, arg1, name);
00061 else
00062 ErrorMessage(env, "bad argument for qMakeStatement()", arg1, name);
00063 }
00064
00065 return Class::TranslateMemberCall(env, member, args);
00066 }
00067
00068 Ptree* QuoteClass::ProcessBackQuote(Environment* env,
00069 char* str, Ptree* arg, Ptree* exp)
00070 {
00071 ProgramString result;
00072
00073 result << "(Ptree*)(PtreeHead()";
00074 while(*str != '\0')
00075 if(*str == '`'){
00076 result << '+';
00077 while(*++str != '`')
00078 if(*str != '\0')
00079 result << *str;
00080 else{
00081 ErrorMessage(env,
00082 "unmatched backquote for Ptree::qMake(): ",
00083 arg, exp);
00084 break;
00085 }
00086
00087 ++str;
00088 }
00089 else{
00090 result << "+\"";
00091 while(*str != '`' && *str != '\0')
00092 result << *str++;
00093
00094 result << '"';
00095 }
00096
00097 result << ')';
00098 char* rstr = (char*)result.Read(0);
00099 return new DupLeaf(rstr, strlen(rstr));
00100 }