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

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

Issue 8390021: Cleanups. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 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 | « runtime/vm/code_generator_ia32.cc ('k') | runtime/vm/parser.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 (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/object.h" 5 #include "vm/object.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/assert.h" 8 #include "vm/assert.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/bootstrap.h" 10 #include "vm/bootstrap.h"
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 return raw() == Type::Handle(Type::ObjectType()).type_class(); 1203 return raw() == Type::Handle(Type::ObjectType()).type_class();
1204 } 1204 }
1205 1205
1206 1206
1207 bool Class::IsCanonicalSignatureClass() const { 1207 bool Class::IsCanonicalSignatureClass() const {
1208 const Function& function = Function::Handle(signature_function()); 1208 const Function& function = Function::Handle(signature_function());
1209 return (!function.IsNull() && (function.signature_class() == raw())); 1209 return (!function.IsNull() && (function.signature_class() == raw()));
1210 } 1210 }
1211 1211
1212 1212
1213 // TODO(regis): We can probably merge this function with IsSubtypeOf, but since
1214 // the spec is not definitive, we still follow it somewhat closely, to make it
1215 // easier to implement spec changes.
1216 bool Class::IsMoreSpecificThan( 1213 bool Class::IsMoreSpecificThan(
1217 const TypeArguments& type_arguments, 1214 const TypeArguments& type_arguments,
1218 const Class& other, 1215 const Class& other,
1219 const TypeArguments& other_type_arguments) const { 1216 const TypeArguments& other_type_arguments) const {
1220 // Check for VarType. 1217 // Check for VarType.
1221 // The VarType on the lefthand side is replaced by the bottom type, which is 1218 // The VarType on the lefthand side is replaced by the bottom type, which is
1222 // more specific than any type. 1219 // more specific than any type.
1223 // Any type is more specific than the VarType on the righthand side. 1220 // Any type is more specific than the VarType on the righthand side.
1224 if (IsVarClass() || other.IsVarClass()) { 1221 if (IsVarClass() || other.IsVarClass()) {
1225 return true; 1222 return true;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 return src_fun.IsAssignableTo(type_arguments, 1331 return src_fun.IsAssignableTo(type_arguments,
1335 dst_fun, 1332 dst_fun,
1336 other_type_arguments); 1333 other_type_arguments);
1337 } 1334 }
1338 // Continue with a subtype test. 1335 // Continue with a subtype test.
1339 test = kIsSubtypeOf; 1336 test = kIsSubtypeOf;
1340 } 1337 }
1341 ASSERT(test == kIsSubtypeOf); 1338 ASSERT(test == kIsSubtypeOf);
1342 1339
1343 // Check for "more specific" relation. 1340 // Check for "more specific" relation.
1344 if (IsMoreSpecificThan(type_arguments, other, other_type_arguments)) { 1341 return IsMoreSpecificThan(type_arguments, other, other_type_arguments);
1345 return true;
1346 }
1347 // TODO(regis): Merge IsMoreSpecificThan here after type checks for
1348 // function types are finalized and implemented.
1349 // For now, keep the assert below.
1350
1351 // The optionality and dubious bliss rules described in the guide have
1352 // already been checked in IsMoreSpecificThan call above.
1353 if (raw() != other.raw()) {
1354 return false;
1355 }
1356 ASSERT(HasTypeArguments()); // Otherwise, IsMoreSpecificThan would be true.
1357 return false;
1358 } 1342 }
1359 1343
1360 1344
1361 RawFunction* Class::LookupDynamicFunction(const String& name) const { 1345 RawFunction* Class::LookupDynamicFunction(const String& name) const {
1362 Function& function = Function::Handle(LookupFunction(name)); 1346 Function& function = Function::Handle(LookupFunction(name));
1363 if (function.IsNull() || function.is_static()) { 1347 if (function.IsNull() || function.is_static()) {
1364 return Function::null(); 1348 return Function::null();
1365 } 1349 }
1366 switch (function.kind()) { 1350 switch (function.kind()) {
1367 case RawFunction::kFunction: 1351 case RawFunction::kFunction:
(...skipping 3462 matching lines...) Expand 10 before | Expand all | Expand 10 after
4830 bool Instance::IsValidFieldOffset(int offset) const { 4814 bool Instance::IsValidFieldOffset(int offset) const {
4831 const Class& cls = Class::Handle(clazz()); 4815 const Class& cls = Class::Handle(clazz());
4832 return (offset >= 0 && offset <= (cls.instance_size() - kWordSize)); 4816 return (offset >= 0 && offset <= (cls.instance_size() - kWordSize));
4833 } 4817 }
4834 4818
4835 4819
4836 const char* Instance::ToCString() const { 4820 const char* Instance::ToCString() const {
4837 if (IsNull()) { 4821 if (IsNull()) {
4838 return "null"; 4822 return "null";
4839 } else { 4823 } else {
4840 // TODO(regis): Print type arguments if any.
4841 const char* kFormat = "Instance of '%s'"; 4824 const char* kFormat = "Instance of '%s'";
4842 Class& cls = Class::Handle(clazz()); 4825 Class& cls = Class::Handle(clazz());
4826 TypeArguments& type_arguments = TypeArguments::Handle();
4827 const intptr_t num_type_arguments = cls.NumTypeArguments();
4828 if (num_type_arguments > 0) {
4829 type_arguments = GetTypeArguments();
4830 }
4831 const Type& type = Type::Handle(
4832 Type::NewParameterizedType(cls, type_arguments));
4833 const String& type_name = String::Handle(type.Name());
4843 // Calculate the size of the string. 4834 // Calculate the size of the string.
4844 intptr_t len = OS::SNPrint(NULL, 0, kFormat, cls.ToCString()) + 1; 4835 intptr_t len = OS::SNPrint(NULL, 0, kFormat, type_name.ToCString()) + 1;
4845 char* chars = reinterpret_cast<char*>( 4836 char* chars = reinterpret_cast<char*>(
4846 Isolate::Current()->current_zone()->Allocate(len)); 4837 Isolate::Current()->current_zone()->Allocate(len));
4847 OS::SNPrint(chars, len, kFormat, cls.ToCString()); 4838 OS::SNPrint(chars, len, kFormat, type_name.ToCString());
4848 return chars; 4839 return chars;
4849 } 4840 }
4850 } 4841 }
4851 4842
4852 4843
4853 const char* Number::ToCString() const { 4844 const char* Number::ToCString() const {
4854 // Number is an interface. No instances of Number should exist. 4845 // Number is an interface. No instances of Number should exist.
4855 UNREACHABLE(); 4846 UNREACHABLE();
4856 return "Number"; 4847 return "Number";
4857 } 4848 }
(...skipping 1942 matching lines...) Expand 10 before | Expand all | Expand 10 after
6800 const String& str = String::Handle(pattern()); 6791 const String& str = String::Handle(pattern());
6801 const char* format = "JSRegExp: pattern=%s flags=%s"; 6792 const char* format = "JSRegExp: pattern=%s flags=%s";
6802 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 6793 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
6803 char* chars = reinterpret_cast<char*>( 6794 char* chars = reinterpret_cast<char*>(
6804 Isolate::Current()->current_zone()->Allocate(len + 1)); 6795 Isolate::Current()->current_zone()->Allocate(len + 1));
6805 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 6796 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
6806 return chars; 6797 return chars;
6807 } 6798 }
6808 6799
6809 } // namespace dart 6800 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator_ia32.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698