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

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

Issue 8761004: Better fix for printing (after discussing it with Ivan and Regis) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years 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 | « no previous file | 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) 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 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 void ParameterizedType::set_type_state(int8_t state) const { 2202 void ParameterizedType::set_type_state(int8_t state) const {
2203 ASSERT(state == RawParameterizedType::kAllocated || 2203 ASSERT(state == RawParameterizedType::kAllocated ||
2204 state == RawParameterizedType::kBeingFinalized || 2204 state == RawParameterizedType::kBeingFinalized ||
2205 state == RawParameterizedType::kFinalized); 2205 state == RawParameterizedType::kFinalized);
2206 raw_ptr()->type_state_ = state; 2206 raw_ptr()->type_state_ = state;
2207 } 2207 }
2208 2208
2209 2209
2210 const char* ParameterizedType::ToCString() const { 2210 const char* ParameterizedType::ToCString() const {
2211 if (IsResolved()) { 2211 if (IsResolved()) {
2212 const char* format = "ParameterizedType: class '%s', args:[%s]"; 2212 const TypeArguments& type_arguments = TypeArguments::Handle(arguments());
2213 const char* class_name = 2213 if (type_arguments.IsNull()) {
2214 String::Handle(Class::Handle(type_class()).Name()).ToCString(); 2214 const char* format = "ParameterizedType: class '%s'";
2215 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString(); 2215 const char* class_name =
2216 intptr_t len = OS::SNPrint(NULL, 0, format, class_name, args_cstr) + 1; 2216 String::Handle(Class::Handle(type_class()).Name()).ToCString();
2217 char* chars = reinterpret_cast<char*>( 2217 intptr_t len = OS::SNPrint(NULL, 0, format, class_name) + 1;
2218 Isolate::Current()->current_zone()->Allocate(len)); 2218 char* chars = reinterpret_cast<char*>(
2219 OS::SNPrint(chars, len, format, class_name, args_cstr); 2219 Isolate::Current()->current_zone()->Allocate(len));
2220 return chars; 2220 OS::SNPrint(chars, len, format, class_name);
2221 return chars;
2222 } else {
2223 const char* format = "ParameterizedType: class '%s', args:[%s]";
2224 const char* class_name =
2225 String::Handle(Class::Handle(type_class()).Name()).ToCString();
2226 const char* args_cstr = TypeArguments::Handle(arguments()).ToCString();
2227 intptr_t len = OS::SNPrint(NULL, 0, format, class_name, args_cstr) + 1;
2228 char* chars = reinterpret_cast<char*>(
2229 Isolate::Current()->current_zone()->Allocate(len));
2230 OS::SNPrint(chars, len, format, class_name, args_cstr);
2231 return chars;
2232 }
2221 } else { 2233 } else {
2222 return "Unresolved ParameterizedType"; 2234 return "Unresolved ParameterizedType";
2223 } 2235 }
2224 } 2236 }
2225 2237
2226 2238
2227 bool TypeParameter::Equals(const Type& other) const { 2239 bool TypeParameter::Equals(const Type& other) const {
2228 if (raw() == other.raw()) { 2240 if (raw() == other.raw()) {
2229 return true; 2241 return true;
2230 } 2242 }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 2468
2457 RawTypeArguments* TypeArguments::NewInstantiatedTypeArguments( 2469 RawTypeArguments* TypeArguments::NewInstantiatedTypeArguments(
2458 const TypeArguments& uninstantiated_type_arguments, 2470 const TypeArguments& uninstantiated_type_arguments,
2459 const TypeArguments& instantiator_type_arguments) { 2471 const TypeArguments& instantiator_type_arguments) {
2460 return InstantiatedTypeArguments::New(uninstantiated_type_arguments, 2472 return InstantiatedTypeArguments::New(uninstantiated_type_arguments,
2461 instantiator_type_arguments); 2473 instantiator_type_arguments);
2462 } 2474 }
2463 2475
2464 2476
2465 const char* TypeArguments::ToCString() const { 2477 const char* TypeArguments::ToCString() const {
2466 // TypeArguments is an abstract class, however it may wrap a null. 2478 // TypeArguments is an abstract class, however it may wrap a null.
regis 2011/11/30 22:53:29 You can remove ", however it may wrap a null".
srdjan 2011/11/30 22:55:55 Done.
2467 if (IsNull()) {
2468 return "NULL TypeArguments";
2469 }
2470 UNREACHABLE(); 2479 UNREACHABLE();
2471 return "TypeArguments"; 2480 return "TypeArguments";
2472 } 2481 }
2473 2482
2474 2483
2475 intptr_t TypeArray::Length() const { 2484 intptr_t TypeArray::Length() const {
2476 ASSERT(!IsNull()); 2485 ASSERT(!IsNull());
2477 return Smi::Value(raw_ptr()->length_); 2486 return Smi::Value(raw_ptr()->length_);
2478 } 2487 }
2479 2488
(...skipping 4780 matching lines...) Expand 10 before | Expand all | Expand 10 after
7260 const String& str = String::Handle(pattern()); 7269 const String& str = String::Handle(pattern());
7261 const char* format = "JSRegExp: pattern=%s flags=%s"; 7270 const char* format = "JSRegExp: pattern=%s flags=%s";
7262 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags()); 7271 intptr_t len = OS::SNPrint(NULL, 0, format, str.ToCString(), Flags());
7263 char* chars = reinterpret_cast<char*>( 7272 char* chars = reinterpret_cast<char*>(
7264 Isolate::Current()->current_zone()->Allocate(len + 1)); 7273 Isolate::Current()->current_zone()->Allocate(len + 1));
7265 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags()); 7274 OS::SNPrint(chars, (len + 1), format, str.ToCString(), Flags());
7266 return chars; 7275 return chars;
7267 } 7276 }
7268 7277
7269 } // namespace dart 7278 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698