| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 + (pattern.multiline ? 'm' : ''); | 43 + (pattern.multiline ? 'm' : ''); |
| 44 pattern = pattern.source; | 44 pattern = pattern.source; |
| 45 } | 45 } |
| 46 | 46 |
| 47 pattern = IS_UNDEFINED(pattern) ? '' : ToString(pattern); | 47 pattern = IS_UNDEFINED(pattern) ? '' : ToString(pattern); |
| 48 flags = IS_UNDEFINED(flags) ? '' : ToString(flags); | 48 flags = IS_UNDEFINED(flags) ? '' : ToString(flags); |
| 49 | 49 |
| 50 var global = false; | 50 var global = false; |
| 51 var ignoreCase = false; | 51 var ignoreCase = false; |
| 52 var multiline = false; | 52 var multiline = false; |
| 53 | |
| 54 for (var i = 0; i < flags.length; i++) { | 53 for (var i = 0; i < flags.length; i++) { |
| 55 var c = %_CallFunction(flags, i, StringCharAt); | 54 var c = %_CallFunction(flags, i, StringCharAt); |
| 56 switch (c) { | 55 switch (c) { |
| 57 case 'g': | 56 case 'g': |
| 58 // Allow duplicate flags to be consistent with JSC and others. | 57 if (global) { |
| 58 throw MakeSyntaxError("invalid_regexp_flags", [flags]); |
| 59 } |
| 59 global = true; | 60 global = true; |
| 60 break; | 61 break; |
| 61 case 'i': | 62 case 'i': |
| 63 if (ignoreCase) { |
| 64 throw MakeSyntaxError("invalid_regexp_flags", [flags]); |
| 65 } |
| 62 ignoreCase = true; | 66 ignoreCase = true; |
| 63 break; | 67 break; |
| 64 case 'm': | 68 case 'm': |
| 69 if (multiline) { |
| 70 throw MakeSyntaxError("invalid_regexp_flags", [flags]); |
| 71 } |
| 65 multiline = true; | 72 multiline = true; |
| 66 break; | 73 break; |
| 67 default: | 74 default: |
| 68 // Ignore flags that have no meaning to be consistent with | 75 throw MakeSyntaxError("invalid_regexp_flags", [flags]); |
| 69 // JSC. | |
| 70 break; | |
| 71 } | 76 } |
| 72 } | 77 } |
| 73 | 78 |
| 74 %RegExpInitializeObject(object, pattern, global, ignoreCase, multiline); | 79 %RegExpInitializeObject(object, pattern, global, ignoreCase, multiline); |
| 75 | 80 |
| 76 // Call internal function to compile the pattern. | 81 // Call internal function to compile the pattern. |
| 77 %RegExpCompile(object, pattern, flags); | 82 %RegExpCompile(object, pattern, flags); |
| 78 } | 83 } |
| 79 | 84 |
| 80 | 85 |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); | 479 %DefineAccessor($RegExp, "$'", SETTER, NoOpSetter, DONT_ENUM | DONT_DELETE); |
| 475 | 480 |
| 476 for (var i = 1; i < 10; ++i) { | 481 for (var i = 1; i < 10; ++i) { |
| 477 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); | 482 %DefineAccessor($RegExp, '$' + i, GETTER, RegExpMakeCaptureGetter(i), DONT_D
ELETE); |
| 478 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); | 483 %DefineAccessor($RegExp, '$' + i, SETTER, NoOpSetter, DONT_DELETE); |
| 479 } | 484 } |
| 480 } | 485 } |
| 481 | 486 |
| 482 | 487 |
| 483 SetupRegExp(); | 488 SetupRegExp(); |
| OLD | NEW |