Index: src/js/macros.py |
diff --git a/src/js/macros.py b/src/js/macros.py |
index 57e931e0c28ab1e83893bc0a57ebb1d2020bb3f2..cdc3d0ae0c1a187ee9cb5b1ceaf55d4d23781843 100644 |
--- a/src/js/macros.py |
+++ b/src/js/macros.py |
@@ -117,9 +117,18 @@ define UNDEFINED = (void 0); |
# Macros implemented in Python. |
python macro CHAR_CODE(str) = ord(str[1]); |
-# Constants used on an array to implement the properties of the RegExp object. |
+# Layout of internal RegExpLastMatchInfo object. |
define REGEXP_NUMBER_OF_CAPTURES = 0; |
+define REGEXP_LAST_SUBJECT = 1; |
+define REGEXP_LAST_INPUT = 2; |
define REGEXP_FIRST_CAPTURE = 3; |
+define CAPTURE0 = 3; # Aliases REGEXP_FIRST_CAPTURE. |
+define CAPTURE1 = 4; |
+ |
+macro NUMBER_OF_CAPTURES(array) = ((array)[REGEXP_NUMBER_OF_CAPTURES]); |
+macro LAST_SUBJECT(array) = ((array)[REGEXP_LAST_SUBJECT]); |
+macro LAST_INPUT(array) = ((array)[REGEXP_LAST_INPUT]); |
+macro CAPTURE(index) = (REGEXP_FIRST_CAPTURE + (index)); |
# Macros for internal slot access. |
macro REGEXP_GLOBAL(regexp) = (%_RegExpFlags(regexp) & 1); |
@@ -129,20 +138,6 @@ macro REGEXP_STICKY(regexp) = (%_RegExpFlags(regexp) & 8); |
macro REGEXP_UNICODE(regexp) = (%_RegExpFlags(regexp) & 16); |
macro REGEXP_SOURCE(regexp) = (%_RegExpSource(regexp)); |
-# We can't put macros in macros so we use constants here. |
-# REGEXP_NUMBER_OF_CAPTURES |
-macro NUMBER_OF_CAPTURES(array) = ((array)[0]); |
- |
-# Last input and last subject of regexp matches. |
-define LAST_SUBJECT_INDEX = 1; |
-macro LAST_SUBJECT(array) = ((array)[1]); |
-macro LAST_INPUT(array) = ((array)[2]); |
- |
-# REGEXP_FIRST_CAPTURE |
-macro CAPTURE(index) = (3 + (index)); |
-define CAPTURE0 = 3; |
-define CAPTURE1 = 4; |
- |
# For the regexp capture override array. This has the same |
# format as the arguments to a function called from |
# String.prototype.replace. |