1 /* { dg-do compile { target arm*-*-* } } */
2 /* { dg-require-effective-target arm_arch_v5te_ok } */
3 /* { dg-require-effective-target arm_arm_ok } */
4 /* { dg-skip-if "do not override -mfloat-abi" { *-*-* } { "-mfloat-abi=*" } {"-mfloat-abi=soft" } } */
5 /* { dg-options "-march=armv5te -marm -mtune=xscale -mfloat-abi=soft -O1" } */
7 typedef unsigned int size_t;
9 typedef long long int int64_t;
11 template<typename T> class RefPtr {
13 inline T* operator->() const { return m_ptr; }
21 typedef int64_t EncodedJSValue;
24 static EncodedJSValue encode(JSValue);
25 JSString* toString(ExecState*) const;
28 typedef unsigned char LChar;
29 typedef short unsigned int UChar;
31 template<typename T, size_t inlineCapacity = 0>
34 template<typename U> bool tryAppend(const U*, size_t);
39 template<typename CharType> inline bool isASCIIDigit(CharType c)
42 template<typename CharType> inline bool isASCIIHexDigit(CharType c)
44 return isASCIIDigit(c) || ((c | 0x20) >= 'a' && (c | 0x20) <= 'f');
48 using WTF::StringImpl;
52 unsigned length() const { return m_length; }
61 unsigned length() const
63 return m_impl->length();
65 const LChar* characters8() const
68 RefPtr<StringImpl> m_impl;
70 class ExecState : private Register {
72 JSValue argument(size_t argument)
78 class JSString : public JSCell {
80 const UString& value(ExecState*) const;
82 class JSStringBuilder {
84 void append(const UChar u)
86 m_okay &= buffer16.tryAppend(&u, 1);
88 Vector<UChar, 64> buffer16;
94 static unsigned char convertHex(int c1, int c2);
99 int UTF8SequenceLength(char);
100 int decodeUTF8Sequence(const char*);
104 using namespace Unicode;
106 template <typename CharType>
107 static JSValue decode(ExecState* exec, const CharType* characters, int length, const char* doNotUnescape, bool strict)
109 JSStringBuilder builder;
113 const CharType* p = characters + k;
117 if (k <= length - 3 && isASCIIHexDigit(p[1]) && isASCIIHexDigit(p[2])) {
118 const char b0 = Lexer<CharType>::convertHex(p[1], p[2]);
119 const int sequenceLen = UTF8SequenceLength(b0);
120 if (sequenceLen && k <= length - sequenceLen * 3) {
121 charLen = sequenceLen * 3;
124 const int character = decodeUTF8Sequence(sequence);
125 if (character < 0 || character >= 0x110000)
127 else if (character >= 0x10000) {
128 builder.append(static_cast<UChar>(0xD800 | ((character - 0x10000) >> 10)));
130 u = static_cast<UChar>(character);
137 static JSValue decode(ExecState* exec, const char* doNotUnescape, bool strict)
139 UString str = exec->argument(0).toString(exec)->value(exec);
140 return decode(exec, str.characters8(), str.length(), doNotUnescape, strict);
142 EncodedJSValue globalFuncDecodeURI(ExecState* exec)
144 static const char do_not_unescape_when_decoding_URI[] =
146 return JSValue::encode(decode(exec, do_not_unescape_when_decoding_URI, true));