OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 257 |
258 | 258 |
259 RUNTIME_FUNCTION(Runtime_URIEscape) { | 259 RUNTIME_FUNCTION(Runtime_URIEscape) { |
260 HandleScope scope(isolate); | 260 HandleScope scope(isolate); |
261 DCHECK_EQ(1, args.length()); | 261 DCHECK_EQ(1, args.length()); |
262 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 262 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
263 Handle<String> source; | 263 Handle<String> source; |
264 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, source, | 264 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, source, |
265 Object::ToString(isolate, input)); | 265 Object::ToString(isolate, input)); |
266 source = String::Flatten(source); | 266 source = String::Flatten(source); |
267 Handle<String> result; | 267 RETURN_RESULT_OR_FAILURE(isolate, |
268 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 268 source->IsOneByteRepresentationUnderneath() |
269 isolate, result, source->IsOneByteRepresentationUnderneath() | 269 ? URIEscape::Escape<uint8_t>(isolate, source) |
270 ? URIEscape::Escape<uint8_t>(isolate, source) | 270 : URIEscape::Escape<uc16>(isolate, source)); |
271 : URIEscape::Escape<uc16>(isolate, source)); | |
272 return *result; | |
273 } | 271 } |
274 | 272 |
275 | 273 |
276 RUNTIME_FUNCTION(Runtime_URIUnescape) { | 274 RUNTIME_FUNCTION(Runtime_URIUnescape) { |
277 HandleScope scope(isolate); | 275 HandleScope scope(isolate); |
278 DCHECK(args.length() == 1); | 276 DCHECK(args.length() == 1); |
279 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); | 277 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
280 Handle<String> source; | 278 Handle<String> source; |
281 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, source, | 279 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, source, |
282 Object::ToString(isolate, input)); | 280 Object::ToString(isolate, input)); |
283 source = String::Flatten(source); | 281 source = String::Flatten(source); |
284 Handle<String> result; | 282 RETURN_RESULT_OR_FAILURE(isolate, |
285 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 283 source->IsOneByteRepresentationUnderneath() |
286 isolate, result, source->IsOneByteRepresentationUnderneath() | 284 ? URIUnescape::Unescape<uint8_t>(isolate, source) |
287 ? URIUnescape::Unescape<uint8_t>(isolate, source) | 285 : URIUnescape::Unescape<uc16>(isolate, source)); |
288 : URIUnescape::Unescape<uc16>(isolate, source)); | |
289 return *result; | |
290 } | 286 } |
291 | 287 |
292 } // namespace internal | 288 } // namespace internal |
293 } // namespace v8 | 289 } // namespace v8 |
OLD | NEW |