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

Side by Side Diff: vm/object.cc

Issue 10433003: Make Dart_GetClass work for private classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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
« no previous file with comments | « vm/object.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 5177 matching lines...) Expand 10 before | Expand all | Expand 10 after
5188 5188
5189 RawClass* Library::LookupLocalClass(const String& name) const { 5189 RawClass* Library::LookupLocalClass(const String& name) const {
5190 Object& obj = Object::Handle(LookupLocalObject(name)); 5190 Object& obj = Object::Handle(LookupLocalObject(name));
5191 if (!obj.IsNull() && obj.IsClass()) { 5191 if (!obj.IsNull() && obj.IsClass()) {
5192 return Class::CheckedHandle(obj.raw()).raw(); 5192 return Class::CheckedHandle(obj.raw()).raw();
5193 } 5193 }
5194 return Class::null(); 5194 return Class::null();
5195 } 5195 }
5196 5196
5197 5197
5198 RawClass* Library::LookupClassAllowPrivate(const String& name) const {
5199 // See if the class is available in this library or in the top level
5200 // scope of any imported library.
5201 Isolate* isolate = Isolate::Current();
5202 Class& cls = Class::Handle(isolate);
5203 cls = LookupClass(name);
5204 if (!cls.IsNull()) {
5205 return cls.raw();
5206 }
5207
5208 // Now try to lookup the class using its private name, but only in
5209 // this library (not in imported libraries).
5210 if (ShouldBePrivate(name)) {
5211 String& private_name = String::Handle(isolate, PrivateName(name));
5212 const Object& obj = Object::Handle(LookupLocalObject(private_name));
5213 if (!obj.IsNull()) {
5214 if (obj.IsClass()) {
5215 cls ^= obj.raw();
5216 return cls.raw();
5217 }
5218 }
5219 }
5220
5221 return Class::null();
5222 }
5223
5224
5198 RawLibraryPrefix* Library::LookupLocalLibraryPrefix(const String& name) const { 5225 RawLibraryPrefix* Library::LookupLocalLibraryPrefix(const String& name) const {
5199 Object& obj = Object::Handle(LookupLocalObject(name)); 5226 Object& obj = Object::Handle(LookupLocalObject(name));
5200 if (!obj.IsNull() && obj.IsLibraryPrefix()) { 5227 if (!obj.IsNull() && obj.IsLibraryPrefix()) {
5201 return LibraryPrefix::CheckedHandle(obj.raw()).raw(); 5228 return LibraryPrefix::CheckedHandle(obj.raw()).raw();
5202 } 5229 }
5203 return LibraryPrefix::null(); 5230 return LibraryPrefix::null();
5204 } 5231 }
5205 5232
5206 5233
5207 void Library::AddAnonymousClass(const Class& cls) const { 5234 void Library::AddAnonymousClass(const Class& cls) const {
(...skipping 4835 matching lines...) Expand 10 before | Expand all | Expand 10 after
10043 const String& str = String::Handle(pattern()); 10070 const String& str = String::Handle(pattern());
10044 const char* format = "JSRegExp: pattern=%s flags=%s"; 10071 const char* format = "JSRegExp: pattern=%s flags=%s";
10045 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 10072 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
10046 char* chars = reinterpret_cast<char*>( 10073 char* chars = reinterpret_cast<char*>(
10047 Isolate::Current()->current_zone()->Allocate(len + 1)); 10074 Isolate::Current()->current_zone()->Allocate(len + 1));
10048 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 10075 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
10049 return chars; 10076 return chars;
10050 } 10077 }
10051 10078
10052 } // namespace dart 10079 } // namespace dart
OLDNEW
« no previous file with comments | « vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698