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

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

Issue 683893002: Classes: Add super support in methods and accessors (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Change test slightly Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/full-codegen-x64.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(start_position), isolate), STRICT)); 146 handle(Smi::FromInt(start_position), isolate), STRICT));
147 RETURN_FAILURE_ON_EXCEPTION( 147 RETURN_FAILURE_ON_EXCEPTION(
148 isolate, 148 isolate,
149 Object::SetProperty(ctor, isolate->factory()->class_end_position_symbol(), 149 Object::SetProperty(ctor, isolate->factory()->class_end_position_symbol(),
150 handle(Smi::FromInt(end_position), isolate), STRICT)); 150 handle(Smi::FromInt(end_position), isolate), STRICT));
151 151
152 return *ctor; 152 return *ctor;
153 } 153 }
154 154
155 155
156 RUNTIME_FUNCTION(Runtime_DefineClassMethod) {
157 HandleScope scope(isolate);
158 DCHECK(args.length() == 3);
159 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
160 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
161 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 2);
162
163 RETURN_FAILURE_ON_EXCEPTION(
164 isolate, JSObject::SetOwnPropertyIgnoreAttributes(
165 function, isolate->factory()->home_object_symbol(), object,
166 DONT_ENUM));
167
168 uint32_t index;
169 if (key->ToArrayIndex(&index)) {
170 RETURN_FAILURE_ON_EXCEPTION(
171 isolate, JSObject::SetOwnElement(object, index, function, STRICT));
172 }
173
174 Handle<Name> name;
175 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name,
176 Runtime::ToName(isolate, key));
177 if (name->AsArrayIndex(&index)) {
178 RETURN_FAILURE_ON_EXCEPTION(
179 isolate, JSObject::SetOwnElement(object, index, function, STRICT));
180 } else {
181 RETURN_FAILURE_ON_EXCEPTION(
182 isolate,
183 JSObject::SetOwnPropertyIgnoreAttributes(object, name, function, NONE));
184 }
185 return isolate->heap()->undefined_value();
186 }
187
188
189 RUNTIME_FUNCTION(Runtime_DefineClassGetter) {
190 HandleScope scope(isolate);
191 DCHECK(args.length() == 3);
192 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
193 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
194 CONVERT_ARG_HANDLE_CHECKED(JSFunction, getter, 2);
195
196 Handle<Name> name;
197 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name,
198 Runtime::ToName(isolate, key));
199 RETURN_FAILURE_ON_EXCEPTION(
200 isolate,
201 JSObject::SetOwnPropertyIgnoreAttributes(
202 getter, isolate->factory()->home_object_symbol(), object, DONT_ENUM));
203
204 RETURN_FAILURE_ON_EXCEPTION(
205 isolate,
206 JSObject::DefineAccessor(object, name, getter,
207 isolate->factory()->null_value(), NONE));
208 return isolate->heap()->undefined_value();
209 }
210
211
212 RUNTIME_FUNCTION(Runtime_DefineClassSetter) {
213 HandleScope scope(isolate);
214 DCHECK(args.length() == 3);
215 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
216 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
217 CONVERT_ARG_HANDLE_CHECKED(JSFunction, setter, 2);
218
219 Handle<Name> name;
220 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, name,
221 Runtime::ToName(isolate, key));
222 RETURN_FAILURE_ON_EXCEPTION(
223 isolate,
224 JSObject::SetOwnPropertyIgnoreAttributes(
225 setter, isolate->factory()->home_object_symbol(), object, DONT_ENUM));
226 RETURN_FAILURE_ON_EXCEPTION(
227 isolate,
228 JSObject::DefineAccessor(object, name, isolate->factory()->null_value(),
229 setter, NONE));
230 return isolate->heap()->undefined_value();
231 }
232
233
156 RUNTIME_FUNCTION(Runtime_ClassGetSourceCode) { 234 RUNTIME_FUNCTION(Runtime_ClassGetSourceCode) {
157 HandleScope shs(isolate); 235 HandleScope shs(isolate);
158 DCHECK(args.length() == 1); 236 DCHECK(args.length() == 1);
159 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); 237 CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
160 238
161 Handle<Object> script; 239 Handle<Object> script;
162 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 240 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
163 isolate, script, 241 isolate, script,
164 Object::GetProperty(fun, isolate->factory()->class_script_symbol())); 242 Object::GetProperty(fun, isolate->factory()->class_script_symbol()));
165 if (!script->IsScript()) { 243 if (!script->IsScript()) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 DCHECK(args.length() == 4); 450 DCHECK(args.length() == 4);
373 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0); 451 CONVERT_ARG_HANDLE_CHECKED(Object, receiver, 0);
374 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1); 452 CONVERT_ARG_HANDLE_CHECKED(JSObject, home_object, 1);
375 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2); 453 CONVERT_ARG_HANDLE_CHECKED(Object, key, 2);
376 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3); 454 CONVERT_ARG_HANDLE_CHECKED(Object, value, 3);
377 455
378 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, SLOPPY); 456 return StoreKeyedToSuper(isolate, home_object, receiver, key, value, SLOPPY);
379 } 457 }
380 } 458 }
381 } // namespace v8::internal 459 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698