Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(671)

Unified Diff: src/macros.py

Issue 28184: Avoids allocating a JSArray of capture information on each non-global... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/macros.py
===================================================================
--- src/macros.py (revision 1374)
+++ src/macros.py (working copy)
@@ -1,4 +1,4 @@
-# Copyright 2006-2008 the V8 project authors. All rights reserved.
+# Copyright 2006-2009 the V8 project authors. All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
@@ -99,3 +99,21 @@
# Accessors for original global properties that ensure they have been loaded.
const ORIGINAL_REGEXP = (global.RegExp, $RegExp);
const ORIGINAL_DATE = (global.Date, $Date);
+
+# Constants used on an array to implement the properties of the RegExp object.
+const REGEXP_NUMBER_OF_CAPTURES = 0;
+const REGEXP_FIRST_CAPTURE = 1;
+
+# 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 are after the captures so we can omit them on
+# results returned from global searches.
+macro LAST_SUBJECT(array) = ((array)[(array)[0] + 1]);
Christian Plesner Hansen 2009/02/26 15:18:53 Beware: this evaluates its argument twice.
+macro LAST_INPUT(array) = ((array)[(array)[0] + 2]);
+
+# REGEXP_FIRST_CAPTURE
+macro CAPTURE(index) = (1 + (index));
+const CAPTURE0 = 1;
+const CAPTURE1 = 2;

Powered by Google App Engine
This is Rietveld 408576698