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

Side by Side Diff: src/runtime/runtime-classes.cc

Issue 798243004: ES6 computed property names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable test on windows Created 5 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 handle(Smi::FromInt(end_position), isolate), STRICT)); 146 handle(Smi::FromInt(end_position), isolate), STRICT));
147 147
148 return *constructor; 148 return *constructor;
149 } 149 }
150 150
151 151
152 RUNTIME_FUNCTION(Runtime_DefineClassMethod) { 152 RUNTIME_FUNCTION(Runtime_DefineClassMethod) {
153 HandleScope scope(isolate); 153 HandleScope scope(isolate);
154 DCHECK(args.length() == 3); 154 DCHECK(args.length() == 3);
155 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 155 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
156 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 156 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
157 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2); 157 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2);
158 158
159 uint32_t index; 159 uint32_t index;
160 if (key->ToArrayIndex(&index)) {
161 RETURN_FAILURE_ON_EXCEPTION(
162 isolate, JSObject::SetOwnElement(object, index, function, STRICT));
163 }
164
165 Handle<Name> name;
166 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name,
167 Runtime::ToName(isolate, key));
168 if (name->AsArrayIndex(&index)) { 160 if (name->AsArrayIndex(&index)) {
169 RETURN_FAILURE_ON_EXCEPTION( 161 RETURN_FAILURE_ON_EXCEPTION(
170 isolate, JSObject::SetOwnElement(object, index, function, STRICT)); 162 isolate, JSObject::SetOwnElement(object, index, function, STRICT));
171 } else { 163 } else {
172 RETURN_FAILURE_ON_EXCEPTION( 164 RETURN_FAILURE_ON_EXCEPTION(
173 isolate, 165 isolate,
174 JSObject::SetOwnPropertyIgnoreAttributes(object, name, function, NONE)); 166 JSObject::SetOwnPropertyIgnoreAttributes(object, name, function, NONE));
175 } 167 }
176 return isolate->heap()->undefined_value(); 168 return isolate->heap()->undefined_value();
177 } 169 }
178 170
179 171
180 RUNTIME_FUNCTION(Runtime_DefineClassGetter) {
181 HandleScope scope(isolate);
182 DCHECK(args.length() == 3);
183 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
184 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
185 CONVERT_ARG_HANDLE_CHECKED(JSFunction, getter, 2);
186
187 Handle<Name> name;
188 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name,
189 Runtime::ToName(isolate, key));
190 RETURN_FAILURE_ON_EXCEPTION(
191 isolate,
192 JSObject::DefineAccessor(object, name, getter,
193 isolate->factory()->null_value(), NONE));
194 return isolate->heap()->undefined_value();
195 }
196
197
198 RUNTIME_FUNCTION(Runtime_DefineClassSetter) {
199 HandleScope scope(isolate);
200 DCHECK(args.length() == 3);
201 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
202 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
203 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2);
204
205 Handle<Name> name;
206 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name,
207 Runtime::ToName(isolate, key));
208 RETURN_FAILURE_ON_EXCEPTION(
209 isolate,
210 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(),
211 setter, NONE));
212 return isolate->heap()->undefined_value();
213 }
214
215
216 RUNTIME_FUNCTION(Runtime_ClassGetSourceCode) { 172 RUNTIME_FUNCTION(Runtime_ClassGetSourceCode) {
217 HandleScope shs(isolate); 173 HandleScope shs(isolate);
218 DCHECK(args.length() == 1); 174 DCHECK(args.length() == 1);
219 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 175 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
220 176
221 Handle<Object> script; 177 Handle<Object> script;
222 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 178 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
223 isolate, script, 179 isolate, script,
224 Object::GetProperty(fun, isolate->factory()->class_script_symbol())); 180 Object::GetProperty(fun, isolate->factory()->class_script_symbol()));
225 if (!script->IsScript()) { 181 if (!script->IsScript()) {
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 435 }
480 436
481 Handle<Object> result; 437 Handle<Object> result;
482 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 438 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
483 isolate, result, 439 isolate, result,
484 Execution::Call(isolate, proto_function, receiver, argc, argv, false)); 440 Execution::Call(isolate, proto_function, receiver, argc, argv, false));
485 return *result; 441 return *result;
486 } 442 }
487 } 443 }
488 } // namespace v8::internal 444 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698