OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 6095 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6106 i::Smi::FromInt(i::Smi::cast(date_cache_version->get(0))->value() + 1)); | 6106 i::Smi::FromInt(i::Smi::cast(date_cache_version->get(0))->value() + 1)); |
6107 } | 6107 } |
6108 | 6108 |
6109 | 6109 |
6110 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { | 6110 static i::Handle<i::String> RegExpFlagsToString(RegExp::Flags flags) { |
6111 i::Isolate* isolate = i::Isolate::Current(); | 6111 i::Isolate* isolate = i::Isolate::Current(); |
6112 uint8_t flags_buf[3]; | 6112 uint8_t flags_buf[3]; |
6113 int num_flags = 0; | 6113 int num_flags = 0; |
6114 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; | 6114 if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g'; |
6115 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; | 6115 if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm'; |
6116 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; | 6116 if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i'; |
Igor Sheludko
2015/11/19 09:30:52
Yang, this function does not support new flags yet
Toon Verwaest
2015/11/19 09:39:53
Acknowledged.
Yang
2015/11/19 09:46:32
Good catch. See https://codereview.chromium.org/14
| |
6117 DCHECK(num_flags <= static_cast<int>(arraysize(flags_buf))); | 6117 DCHECK(num_flags <= static_cast<int>(arraysize(flags_buf))); |
6118 return isolate->factory()->InternalizeOneByteString( | 6118 return isolate->factory()->InternalizeOneByteString( |
6119 i::Vector<const uint8_t>(flags_buf, num_flags)); | 6119 i::Vector<const uint8_t>(flags_buf, num_flags)); |
6120 } | 6120 } |
6121 | 6121 |
6122 | 6122 |
6123 MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context, | 6123 MaybeLocal<v8::RegExp> v8::RegExp::New(Local<Context> context, |
6124 Local<String> pattern, Flags flags) { | 6124 Local<String> pattern, Flags flags) { |
6125 PREPARE_FOR_EXECUTION(context, "RegExp::New", RegExp); | 6125 PREPARE_FOR_EXECUTION(context, "RegExp::New", RegExp); |
6126 Local<v8::RegExp> result; | 6126 Local<v8::RegExp> result; |
6127 has_pending_exception = | 6127 has_pending_exception = !ToLocal<RegExp>( |
6128 !ToLocal<RegExp>(i::Execution::NewJSRegExp(Utils::OpenHandle(*pattern), | 6128 i::JSRegExp::New(Utils::OpenHandle(*pattern), RegExpFlagsToString(flags)), |
6129 RegExpFlagsToString(flags)), | 6129 &result); |
6130 &result); | |
6131 RETURN_ON_FAILED_EXECUTION(RegExp); | 6130 RETURN_ON_FAILED_EXECUTION(RegExp); |
6132 RETURN_ESCAPED(result); | 6131 RETURN_ESCAPED(result); |
6133 } | 6132 } |
6134 | 6133 |
6135 | 6134 |
6136 Local<v8::RegExp> v8::RegExp::New(Local<String> pattern, Flags flags) { | 6135 Local<v8::RegExp> v8::RegExp::New(Local<String> pattern, Flags flags) { |
6137 auto isolate = | 6136 auto isolate = |
6138 reinterpret_cast<Isolate*>(Utils::OpenHandle(*pattern)->GetIsolate()); | 6137 reinterpret_cast<Isolate*>(Utils::OpenHandle(*pattern)->GetIsolate()); |
6139 auto context = isolate->GetCurrentContext(); | 6138 auto context = isolate->GetCurrentContext(); |
6140 RETURN_TO_LOCAL_UNCHECKED(New(context, pattern, flags), RegExp); | 6139 RETURN_TO_LOCAL_UNCHECKED(New(context, pattern, flags), RegExp); |
(...skipping 2387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8528 Address callback_address = | 8527 Address callback_address = |
8529 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8528 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8530 VMState<EXTERNAL> state(isolate); | 8529 VMState<EXTERNAL> state(isolate); |
8531 ExternalCallbackScope call_scope(isolate, callback_address); | 8530 ExternalCallbackScope call_scope(isolate, callback_address); |
8532 callback(info); | 8531 callback(info); |
8533 } | 8532 } |
8534 | 8533 |
8535 | 8534 |
8536 } // namespace internal | 8535 } // namespace internal |
8537 } // namespace v8 | 8536 } // namespace v8 |
OLD | NEW |