1 /* { dg-do compile { target arm*-*-* } } */
2 /* { dg-options "-march=armv5te -marm -mtune=xscale -mfloat-abi=soft -O1" } */
4 typedef unsigned int size_t;
6 typedef long long int int64_t;
8 template<typename T> class RefPtr {
10 inline T* operator->() const { return m_ptr; }
18 typedef int64_t EncodedJSValue;
21 static EncodedJSValue encode(JSValue);
22 JSString* toString(ExecState*) const;
25 typedef unsigned char LChar;
26 typedef short unsigned int UChar;
28 template<typename T, size_t inlineCapacity = 0>
31 template<typename U> bool tryAppend(const U*, size_t);
36 template<typename CharType> inline bool isASCIIDigit(CharType c)
39 template<typename CharType> inline bool isASCIIHexDigit(CharType c)
41 return isASCIIDigit(c) || ((c | 0x20) >= 'a' && (c | 0x20) <= 'f');
45 using WTF::StringImpl;
49 unsigned length() const { return m_length; }
58 unsigned length() const
60 return m_impl->length();
62 const LChar* characters8() const
65 RefPtr<StringImpl> m_impl;
67 class ExecState : private Register {
69 JSValue argument(size_t argument)
75 class JSString : public JSCell {
77 const UString& value(ExecState*) const;
79 class JSStringBuilder {
81 void append(const UChar u)
83 m_okay &= buffer16.tryAppend(&u, 1);
85 Vector<UChar, 64> buffer16;
91 static unsigned char convertHex(int c1, int c2);
96 int UTF8SequenceLength(char);
97 int decodeUTF8Sequence(const char*);
101 using namespace Unicode;
103 template <typename CharType>
104 static JSValue decode(ExecState* exec, const CharType* characters, int length, const char* doNotUnescape, bool strict)
106 JSStringBuilder builder;
110 const CharType* p = characters + k;
114 if (k <= length - 3 && isASCIIHexDigit(p[1]) && isASCIIHexDigit(p[2])) {
115 const char b0 = Lexer<CharType>::convertHex(p[1], p[2]);
116 const int sequenceLen = UTF8SequenceLength(b0);
117 if (sequenceLen && k <= length - sequenceLen * 3) {
118 charLen = sequenceLen * 3;
121 const int character = decodeUTF8Sequence(sequence);
122 if (character < 0 || character >= 0x110000)
124 else if (character >= 0x10000) {
125 builder.append(static_cast<UChar>(0xD800 | ((character - 0x10000) >> 10)));
127 u = static_cast<UChar>(character);
134 static JSValue decode(ExecState* exec, const char* doNotUnescape, bool strict)
136 UString str = exec->argument(0).toString(exec)->value(exec);
137 return decode(exec, str.characters8(), str.length(), doNotUnescape, strict);
139 EncodedJSValue globalFuncDecodeURI(ExecState* exec)
141 static const char do_not_unescape_when_decoding_URI[] =
143 return JSValue::encode(decode(exec, do_not_unescape_when_decoding_URI, true));