Index: src/array.js |
diff --git a/src/array.js b/src/array.js |
index d61183779c7a283e73218dd3032bf08421aac04c..26dbcd8fbea491d279ea97ace2287040f89d5bb5 100644 |
--- a/src/array.js |
+++ b/src/array.js |
@@ -1027,11 +1027,24 @@ function ArrayFilter(f, receiver) { |
var result = new $Array(); |
var accumulator = new InternalArray(); |
var accumulator_length = 0; |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- if (%_CallFunction(receiver, element, i, array, f)) { |
- accumulator[accumulator_length++] = element; |
+ if (%DebugStepIntoBuiltinCallback(f)) { |
Søren Gjesse
2012/04/20 08:33:25
Maybe rename DebugStepIntoBuiltinCallback to somet
Søren Gjesse
2012/04/20 08:33:25
The only thing I don't like here is the code dupli
Søren Gjesse
2012/04/20 08:33:25
An important thing performance wise is that it sho
Yang
2012/04/20 11:06:54
This would be great, but I have no idea how to che
Yang
2012/04/20 11:06:54
I don't see anything simple either. The one way I
|
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ %PrepareBreakSlotsForCallback(f); |
Søren Gjesse
2012/04/20 08:33:25
I think the name here i somewhat misleading. Maybe
Yang
2012/04/20 11:06:54
Done.
|
+ if (%_CallFunction(receiver, element, i, array, f)) { |
+ accumulator[accumulator_length++] = element; |
+ } |
+ } |
+ } |
+ } else { |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ if (%_CallFunction(receiver, element, i, array, f)) { |
+ accumulator[accumulator_length++] = element; |
+ } |
} |
} |
} |
@@ -1059,11 +1072,21 @@ function ArrayForEach(f, receiver) { |
} else if (!IS_SPEC_OBJECT(receiver)) { |
receiver = ToObject(receiver); |
} |
- |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- %_CallFunction(receiver, element, i, array, f); |
+ if (%DebugStepIntoBuiltinCallback(f)) { |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ %PrepareBreakSlotsForCallback(f); |
+ %_CallFunction(receiver, element, i, array, f); |
+ } |
+ } |
+ } else { |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ %_CallFunction(receiver, element, i, array, f); |
+ } |
} |
} |
} |
@@ -1091,10 +1114,21 @@ function ArraySome(f, receiver) { |
receiver = ToObject(receiver); |
} |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- if (%_CallFunction(receiver, element, i, array, f)) return true; |
+ if (%DebugStepIntoBuiltinCallback(f)) { |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ %PrepareBreakSlotsForCallback(f); |
+ if (%_CallFunction(receiver, element, i, array, f)) return true; |
+ } |
+ } |
+ } else { |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ if (%_CallFunction(receiver, element, i, array, f)) return true; |
+ } |
} |
} |
return false; |
@@ -1121,10 +1155,21 @@ function ArrayEvery(f, receiver) { |
receiver = ToObject(receiver); |
} |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- if (!%_CallFunction(receiver, element, i, array, f)) return false; |
+ if (%DebugStepIntoBuiltinCallback(f)) { |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ %PrepareBreakSlotsForCallback(f); |
+ if (!%_CallFunction(receiver, element, i, array, f)) return false; |
+ } |
+ } |
+ } else { |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ if (!%_CallFunction(receiver, element, i, array, f)) return false; |
+ } |
} |
} |
return true; |
@@ -1152,10 +1197,21 @@ function ArrayMap(f, receiver) { |
var result = new $Array(); |
var accumulator = new InternalArray(length); |
- for (var i = 0; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- accumulator[i] = %_CallFunction(receiver, element, i, array, f); |
+ if (%DebugStepIntoBuiltinCallback(f)) { |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ %PrepareBreakSlotsForCallback(f); |
+ accumulator[i] = %_CallFunction(receiver, element, i, array, f); |
+ } |
+ } |
+ } else { |
+ for (var i = 0; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ accumulator[i] = %_CallFunction(receiver, element, i, array, f); |
+ } |
} |
} |
%MoveArrayContents(accumulator, result); |
@@ -1311,10 +1367,24 @@ function ArrayReduce(callback, current) { |
} |
var receiver = %GetDefaultReceiver(callback); |
- for (; i < length; i++) { |
- if (i in array) { |
- var element = array[i]; |
- current = %_CallFunction(receiver, current, element, i, array, callback); |
+ |
+ if (%DebugStepIntoBuiltinCallback(callback)) { |
+ for (; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ %PrepareBreakSlotsForCallback(callback); |
+ current = |
+ %_CallFunction(receiver, current, element, i, array, callback); |
+ } |
+ } |
+ } else { |
+ for (; i < length; i++) { |
+ if (i in array) { |
+ var element = array[i]; |
+ current = |
+ %_CallFunction(receiver, current, element, i, array, callback); |
+ } |
} |
} |
return current; |
@@ -1348,10 +1418,24 @@ function ArrayReduceRight(callback, current) { |
} |
var receiver = %GetDefaultReceiver(callback); |
- for (; i >= 0; i--) { |
- if (i in array) { |
- var element = array[i]; |
- current = %_CallFunction(receiver, current, element, i, array, callback); |
+ |
+ if (%DebugStepIntoBuiltinCallback(callback)) { |
+ for (; i >= 0; i--) { |
+ if (i in array) { |
+ var element = array[i]; |
+ // Prepare break slots for debugger step in. |
+ %PrepareBreakSlotsForCallback(callback); |
+ current = |
+ %_CallFunction(receiver, current, element, i, array, callback); |
+ } |
+ } |
+ } else { |
+ for (; i >= 0; i--) { |
+ if (i in array) { |
+ var element = array[i]; |
+ current = |
+ %_CallFunction(receiver, current, element, i, array, callback); |
+ } |
} |
} |
return current; |