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

Side by Side Diff: runtime/lib/object.cc

Issue 14703005: Added Object._cid getter, optimized it. Added to (some) classes a static final _clCid. Use those to… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/exceptions.h" 7 #include "vm/exceptions.h"
8 #include "vm/native_entry.h" 8 #include "vm/native_entry.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/stack_frame.h" 10 #include "vm/stack_frame.h"
11 #include "vm/symbols.h" 11 #include "vm/symbols.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 DECLARE_FLAG(bool, enable_type_checks); 15 DECLARE_FLAG(bool, enable_type_checks);
16 16
17 17
18 DEFINE_NATIVE_ENTRY(Object_cid, 1) {
19 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
siva 2013/05/13 20:38:00 GET_NONE_NULL_NATIVE_ARGUMENT(Instance, instance,
Ivan Posva 2013/05/13 22:12:37 Null is a valid receiver for the _cid method. So I
srdjan 2013/05/14 17:46:31 What Ivan said.
20 const Class& cls = Class::Handle(instance.clazz());
21 return Smi::New(cls.id());
22 }
23
24
18 DEFINE_NATIVE_ENTRY(Object_toString, 1) { 25 DEFINE_NATIVE_ENTRY(Object_toString, 1) {
19 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); 26 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
20 const char* c_str = instance.ToCString(); 27 const char* c_str = instance.ToCString();
21 return String::New(c_str); 28 return String::New(c_str);
22 } 29 }
23 30
24 31
25 DEFINE_NATIVE_ENTRY(Object_noSuchMethod, 6) { 32 DEFINE_NATIVE_ENTRY(Object_noSuchMethod, 6) {
26 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); 33 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
27 GET_NON_NULL_NATIVE_ARGUMENT(Bool, is_method, arguments->NativeArgAt(1)); 34 GET_NON_NULL_NATIVE_ARGUMENT(Bool, is_method, arguments->NativeArgAt(1));
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 173 }
167 174
168 175
169 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) { 176 DEFINE_NATIVE_ENTRY(AbstractType_toString, 1) {
170 const AbstractType& type = 177 const AbstractType& type =
171 AbstractType::CheckedHandle(arguments->NativeArgAt(0)); 178 AbstractType::CheckedHandle(arguments->NativeArgAt(0));
172 return type.UserVisibleName(); 179 return type.UserVisibleName();
173 } 180 }
174 181
175 } // namespace dart 182 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698