| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 return JSRegExp::Flags(flags); | 92 return JSRegExp::Flags(flags); |
| 93 } | 93 } |
| 94 | 94 |
| 95 | 95 |
| 96 static inline void ThrowRegExpException(Handle<JSRegExp> re, | 96 static inline void ThrowRegExpException(Handle<JSRegExp> re, |
| 97 Handle<String> pattern, | 97 Handle<String> pattern, |
| 98 Handle<String> error_text, | 98 Handle<String> error_text, |
| 99 const char* message) { | 99 const char* message) { |
| 100 Handle<JSArray> array = Factory::NewJSArray(2); | 100 Handle<FixedArray> elements = Factory::NewFixedArray(2); |
| 101 SetElement(array, 0, pattern); | 101 elements->set(0, *pattern); |
| 102 SetElement(array, 1, error_text); | 102 elements->set(1, *error_text); |
| 103 Handle<JSArray> array = Factory::NewJSArrayWithElements(elements); |
| 103 Handle<Object> regexp_err = Factory::NewSyntaxError(message, array); | 104 Handle<Object> regexp_err = Factory::NewSyntaxError(message, array); |
| 104 Top::Throw(*regexp_err); | 105 Top::Throw(*regexp_err); |
| 105 } | 106 } |
| 106 | 107 |
| 107 | 108 |
| 108 // Generic RegExp methods. Dispatches to implementation specific methods. | 109 // Generic RegExp methods. Dispatches to implementation specific methods. |
| 109 | 110 |
| 110 | 111 |
| 111 Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re, | 112 Handle<Object> RegExpImpl::Compile(Handle<JSRegExp> re, |
| 112 Handle<String> pattern, | 113 Handle<String> pattern, |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 return false; | 319 return false; |
| 319 } | 320 } |
| 320 RegExpEngine::CompilationResult result = | 321 RegExpEngine::CompilationResult result = |
| 321 RegExpEngine::Compile(&compile_data, | 322 RegExpEngine::Compile(&compile_data, |
| 322 flags.is_ignore_case(), | 323 flags.is_ignore_case(), |
| 323 flags.is_multiline(), | 324 flags.is_multiline(), |
| 324 pattern, | 325 pattern, |
| 325 is_ascii); | 326 is_ascii); |
| 326 if (result.error_message != NULL) { | 327 if (result.error_message != NULL) { |
| 327 // Unable to compile regexp. | 328 // Unable to compile regexp. |
| 328 Handle<JSArray> array = Factory::NewJSArray(2); | 329 Handle<FixedArray> elements = Factory::NewFixedArray(2); |
| 329 SetElement(array, 0, pattern); | 330 elements->set(0, *pattern); |
| 330 SetElement(array, | 331 Handle<String> error_message = |
| 331 1, | 332 Factory::NewStringFromUtf8(CStrVector(result.error_message)); |
| 332 Factory::NewStringFromUtf8(CStrVector(result.error_message))); | 333 elements->set(1, *error_message); |
| 334 Handle<JSArray> array = Factory::NewJSArrayWithElements(elements); |
| 333 Handle<Object> regexp_err = | 335 Handle<Object> regexp_err = |
| 334 Factory::NewSyntaxError("malformed_regexp", array); | 336 Factory::NewSyntaxError("malformed_regexp", array); |
| 335 Top::Throw(*regexp_err); | 337 Top::Throw(*regexp_err); |
| 336 re->SetDataAt(JSRegExp::code_index(is_ascii), *regexp_err); | 338 re->SetDataAt(JSRegExp::code_index(is_ascii), *regexp_err); |
| 337 return false; | 339 return false; |
| 338 } | 340 } |
| 339 | 341 |
| 340 Handle<FixedArray> data = Handle<FixedArray>(FixedArray::cast(re->data())); | 342 Handle<FixedArray> data = Handle<FixedArray>(FixedArray::cast(re->data())); |
| 341 data->set(JSRegExp::code_index(is_ascii), result.code); | 343 data->set(JSRegExp::code_index(is_ascii), result.code); |
| 342 int register_max = IrregexpMaxRegisterCount(*data); | 344 int register_max = IrregexpMaxRegisterCount(*data); |
| (...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 Trace new_trace; | 853 Trace new_trace; |
| 852 start->Emit(this, &new_trace); | 854 start->Emit(this, &new_trace); |
| 853 macro_assembler_->Bind(&fail); | 855 macro_assembler_->Bind(&fail); |
| 854 macro_assembler_->Fail(); | 856 macro_assembler_->Fail(); |
| 855 while (!work_list.is_empty()) { | 857 while (!work_list.is_empty()) { |
| 856 work_list.RemoveLast()->Emit(this, &new_trace); | 858 work_list.RemoveLast()->Emit(this, &new_trace); |
| 857 } | 859 } |
| 858 if (reg_exp_too_big_) return IrregexpRegExpTooBig(); | 860 if (reg_exp_too_big_) return IrregexpRegExpTooBig(); |
| 859 | 861 |
| 860 Handle<Object> code = macro_assembler_->GetCode(pattern); | 862 Handle<Object> code = macro_assembler_->GetCode(pattern); |
| 861 | |
| 862 work_list_ = NULL; | 863 work_list_ = NULL; |
| 863 #ifdef DEBUG | 864 #ifdef DEBUG |
| 865 if (FLAG_print_code) { |
| 866 Handle<Code>::cast(code)->Disassemble(*pattern->ToCString()); |
| 867 } |
| 864 if (FLAG_trace_regexp_assembler) { | 868 if (FLAG_trace_regexp_assembler) { |
| 865 delete macro_assembler_; | 869 delete macro_assembler_; |
| 866 } | 870 } |
| 867 #endif | 871 #endif |
| 868 return RegExpEngine::CompilationResult(*code, next_register_); | 872 return RegExpEngine::CompilationResult(*code, next_register_); |
| 869 } | 873 } |
| 870 | 874 |
| 871 | 875 |
| 872 bool Trace::DeferredAction::Mentions(int that) { | 876 bool Trace::DeferredAction::Mentions(int that) { |
| 873 if (type() == ActionNode::CLEAR_CAPTURES) { | 877 if (type() == ActionNode::CLEAR_CAPTURES) { |
| (...skipping 4457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5331 node, | 5335 node, |
| 5332 data->capture_count, | 5336 data->capture_count, |
| 5333 pattern); | 5337 pattern); |
| 5334 } | 5338 } |
| 5335 | 5339 |
| 5336 | 5340 |
| 5337 int OffsetsVector::static_offsets_vector_[ | 5341 int OffsetsVector::static_offsets_vector_[ |
| 5338 OffsetsVector::kStaticOffsetsVectorSize]; | 5342 OffsetsVector::kStaticOffsetsVectorSize]; |
| 5339 | 5343 |
| 5340 }} // namespace v8::internal | 5344 }} // namespace v8::internal |
| OLD | NEW |