OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 function DerivedHasOwnTrap(name) { | 147 function DerivedHasOwnTrap(name) { |
148 return !!this.getOwnPropertyDescriptor(name) | 148 return !!this.getOwnPropertyDescriptor(name) |
149 } | 149 } |
150 | 150 |
151 function DerivedKeysTrap() { | 151 function DerivedKeysTrap() { |
152 var names = this.getOwnPropertyNames() | 152 var names = this.getOwnPropertyNames() |
153 var enumerableNames = [] | 153 var enumerableNames = [] |
154 for (var i = 0, count = 0; i < names.length; ++i) { | 154 for (var i = 0, count = 0; i < names.length; ++i) { |
155 var name = names[i] | 155 var name = names[i] |
156 if (this.getOwnPropertyDescriptor(TO_STRING_INLINE(name)).enumerable) { | 156 var desc = this.getOwnPropertyDescriptor(TO_STRING_INLINE(name)) |
| 157 if (!IS_UNDEFINED(desc) && desc.enumerable) { |
157 enumerableNames[count++] = names[i] | 158 enumerableNames[count++] = names[i] |
158 } | 159 } |
159 } | 160 } |
160 return enumerableNames | 161 return enumerableNames |
161 } | 162 } |
| 163 |
| 164 function DerivedEnumerateTrap() { |
| 165 var names = this.getPropertyNames() |
| 166 var enumerableNames = [] |
| 167 for (var i = 0, count = 0; i < names.length; ++i) { |
| 168 var name = names[i] |
| 169 var desc = this.getPropertyDescriptor(TO_STRING_INLINE(name)) |
| 170 if (!IS_UNDEFINED(desc) && desc.enumerable) { |
| 171 enumerableNames[count++] = names[i] |
| 172 } |
| 173 } |
| 174 return enumerableNames |
| 175 } |
| 176 |
| 177 function ProxyEnumerate(proxy) { |
| 178 var handler = %GetHandler(proxy) |
| 179 if (IS_UNDEFINED(handler.enumerate)) { |
| 180 return %Apply(DerivedEnumerateTrap, handler, [], 0, 0) |
| 181 } else { |
| 182 return ToStringArray(handler.enumerate(), "enumerate") |
| 183 } |
| 184 } |
OLD | NEW |