#include "CallFrame.h"
#include "GlobalEvalFunction.h"
+#include "Interpreter.h"
#include "JSGlobalObject.h"
-#include "LiteralParser.h"
#include "JSString.h"
-#include "Interpreter.h"
-#include "Parser.h"
-#include "dtoa.h"
#include "Lexer.h"
+#include "LiteralParser.h"
#include "Nodes.h"
+#include "Parser.h"
+#include "StringBuilder.h"
+#include "StringExtras.h"
+#include "dtoa.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
if (!cstr.c_str())
return throwError(exec, URIError, "String contained an illegal UTF-16 sequence.");
- UString result = "";
+ StringBuilder builder;
const char* p = cstr.c_str();
for (size_t k = 0; k < cstr.size(); k++, p++) {
char c = *p;
if (c && strchr(doNotEscape, c))
- result.append(c);
+ builder.append(c);
else {
char tmp[4];
snprintf(tmp, sizeof(tmp), "%%%02X", static_cast<unsigned char>(c));
- result += tmp;
+ builder.append((const char*)tmp);
}
}
- return jsString(exec, result);
+ return jsString(exec, builder.release());
}
static JSValue decode(ExecState* exec, const ArgList& args, const char* doNotUnescape, bool strict)
{
- UString result = "";
+ StringBuilder builder;
UString str = args.at(0).toString(exec);
int k = 0;
int len = str.size();
charLen = 0;
else if (character >= 0x10000) {
// Convert to surrogate pair.
- result.append(static_cast<UChar>(0xD800 | ((character - 0x10000) >> 10)));
+ builder.append(static_cast<UChar>(0xD800 | ((character - 0x10000) >> 10)));
u = static_cast<UChar>(0xDC00 | ((character - 0x10000) & 0x3FF));
} else
u = static_cast<UChar>(character);
}
}
k++;
- result.append(c);
+ builder.append(c);
}
- return jsString(exec, result);
+ return jsString(exec, builder.release());
}
bool isStrWhiteSpace(UChar c)
if (JSValue parsedObject = preparser.tryLiteralParse())
return parsedObject;
- int errLine;
- UString errMsg;
-
- SourceCode source = makeSource(s);
- RefPtr<EvalNode> evalNode = exec->globalData().parser->parse<EvalNode>(exec, exec->dynamicGlobalObject()->debugger(), source, &errLine, &errMsg);
-
- if (!evalNode)
- return throwError(exec, SyntaxError, errMsg, errLine, source.provider()->asID(), NULL);
+ RefPtr<EvalExecutable> eval = EvalExecutable::create(exec, makeSource(s));
+ JSObject* error = eval->compile(exec, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node());
+ if (error)
+ return throwError(exec, error);
- return exec->interpreter()->execute(evalNode.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot());
+ return exec->interpreter()->execute(eval.get(), exec, thisObject, static_cast<JSGlobalObject*>(unwrappedObject)->globalScopeChain().node(), exec->exceptionSlot());
}
JSValue JSC_HOST_CALL globalFuncParseInt(ExecState* exec, JSObject*, JSValue, const ArgList& args)
"0123456789"
"*+-./@_";
- UString result = "";
+ StringBuilder builder;
UString s;
UString str = args.at(0).toString(exec);
const UChar* c = str.data();
snprintf(tmp, sizeof(tmp), "%%%02X", u);
s = UString(tmp);
}
- result += s;
+ builder.append(s);
}
- return jsString(exec, result);
+ return jsString(exec, builder.release());
}
JSValue JSC_HOST_CALL globalFuncUnescape(ExecState* exec, JSObject*, JSValue, const ArgList& args)
{
- UString result = "";
+ StringBuilder builder;
UString str = args.at(0).toString(exec);
int k = 0;
int len = str.size();
k += 2;
}
k++;
- result.append(*c);
+ builder.append(*c);
}
- return jsString(exec, result);
+ return jsString(exec, builder.release());
}
#ifndef NDEBUG