Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals

tplconstantnormalizer.cpp

Go to the documentation of this file.
00001 #include "tplconstantnormalizer.h"
00002 #include "stree.h"
00003 #include "streeconstant.h"
00004 
00005 Node* TPLConstantNormalizer::transform(Node *node) const{
00006   if (node->getName() != CConstantString) return node;
00007   Constant* constant = dynamic_cast<Constant*>(((dynamic_cast<ConstantString*>(node))->getStatement1()));
00008 
00009   char* newstr = (char*)malloc(constant->getValue().length()+1);  
00010   char* t = newstr;
00011   const char* s =  constant->getValue().c_str();
00012   const char* end = s + constant->getValue().length();
00013   
00014   while (s<end) {
00015     if (*s=='\\') {
00016       s++;
00017       if (s>=end) {
00018         continue;
00019       }
00020       switch(*s) {
00021       case '\\':
00022       case '\'':
00023         *t++ = *s;
00024         break;
00025       default:
00026         *t++ = '\\';
00027         *t++ = *s;
00028         break;
00029       }
00030       s++;
00031     } else {
00032       *t++ = *s++;
00033     }
00034   }
00035   *t = 0;
00036   ConstantString *result = new ConstantString(new Constant(newstr));
00037   free(newstr);
00038   return result;
00039 };

Generated on Fri Nov 21 17:54:04 2003 for PHPX by doxygen 1.3.3