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

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

Issue 169893003: Another round of cleanups for http://www.dartbug.com/15922 (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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) 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 "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 5090 matching lines...) Expand 10 before | Expand all | Expand 10 after
5101 char message_buffer[kMessageBufferSize]; 5101 char message_buffer[kMessageBufferSize];
5102 OS::SNPrint(message_buffer, 5102 OS::SNPrint(message_buffer,
5103 kMessageBufferSize, 5103 kMessageBufferSize,
5104 "%" Pd " named passed, at most %" Pd " expected", 5104 "%" Pd " named passed, at most %" Pd " expected",
5105 num_named_arguments, 5105 num_named_arguments,
5106 NumOptionalNamedParameters()); 5106 NumOptionalNamedParameters());
5107 *error_message = String::New(message_buffer); 5107 *error_message = String::New(message_buffer);
5108 } 5108 }
5109 return false; // Too many named arguments. 5109 return false; // Too many named arguments.
5110 } 5110 }
5111 const int num_pos_args = num_arguments - num_named_arguments; 5111 const intptr_t num_pos_args = num_arguments - num_named_arguments;
5112 const int num_opt_pos_params = NumOptionalPositionalParameters(); 5112 const intptr_t num_opt_pos_params = NumOptionalPositionalParameters();
5113 const int num_pos_params = num_fixed_parameters() + num_opt_pos_params; 5113 const intptr_t num_pos_params = num_fixed_parameters() + num_opt_pos_params;
5114 if (num_pos_args > num_pos_params) { 5114 if (num_pos_args > num_pos_params) {
5115 if (error_message != NULL) { 5115 if (error_message != NULL) {
5116 const intptr_t kMessageBufferSize = 64; 5116 const intptr_t kMessageBufferSize = 64;
5117 char message_buffer[kMessageBufferSize]; 5117 char message_buffer[kMessageBufferSize];
5118 // Hide implicit parameters to the user. 5118 // Hide implicit parameters to the user.
5119 const intptr_t num_hidden_params = NumImplicitParameters(); 5119 const intptr_t num_hidden_params = NumImplicitParameters();
5120 OS::SNPrint(message_buffer, 5120 OS::SNPrint(message_buffer,
5121 kMessageBufferSize, 5121 kMessageBufferSize,
5122 "%" Pd "%s passed, %s%" Pd " expected", 5122 "%" Pd "%s passed, %s%" Pd " expected",
5123 num_pos_args - num_hidden_params, 5123 num_pos_args - num_hidden_params,
(...skipping 6848 matching lines...) Expand 10 before | Expand all | Expand 10 after
11972 if (cls.EnsureIsFinalized(isolate) != Error::null()) { 11972 if (cls.EnsureIsFinalized(isolate) != Error::null()) {
11973 return Instance::null(); 11973 return Instance::null();
11974 } 11974 }
11975 intptr_t instance_size = cls.instance_size(); 11975 intptr_t instance_size = cls.instance_size();
11976 ASSERT(instance_size > 0); 11976 ASSERT(instance_size > 0);
11977 RawObject* raw = Object::Allocate(cls.id(), instance_size, space); 11977 RawObject* raw = Object::Allocate(cls.id(), instance_size, space);
11978 return reinterpret_cast<RawInstance*>(raw); 11978 return reinterpret_cast<RawInstance*>(raw);
11979 } 11979 }
11980 11980
11981 11981
11982 bool Instance::IsValidFieldOffset(int offset) const { 11982 bool Instance::IsValidFieldOffset(intptr_t offset) const {
11983 const Class& cls = Class::Handle(clazz()); 11983 const Class& cls = Class::Handle(clazz());
11984 return (offset >= 0 && offset <= (cls.instance_size() - kWordSize)); 11984 return (offset >= 0 && offset <= (cls.instance_size() - kWordSize));
11985 } 11985 }
11986 11986
11987 11987
11988 const char* Instance::ToCString() const { 11988 const char* Instance::ToCString() const {
11989 if (IsNull()) { 11989 if (IsNull()) {
11990 return "null"; 11990 return "null";
11991 } else if (raw() == Object::sentinel().raw()) { 11991 } else if (raw() == Object::sentinel().raw()) {
11992 return "sentinel"; 11992 return "sentinel";
(...skipping 4218 matching lines...) Expand 10 before | Expand all | Expand 10 after
16211 jselement.AddProperty("index", index); 16211 jselement.AddProperty("index", index);
16212 16212
16213 Instance& instance = Instance::Handle(); 16213 Instance& instance = Instance::Handle();
16214 instance ^= At(index); 16214 instance ^= At(index);
16215 jselement.AddProperty("value", instance); 16215 jselement.AddProperty("value", instance);
16216 } 16216 }
16217 } 16217 }
16218 } 16218 }
16219 16219
16220 16220
16221 RawArray* Array::Grow(const Array& source, int new_length, Heap::Space space) { 16221 RawArray* Array::Grow(const Array& source,
16222 intptr_t new_length,
16223 Heap::Space space) {
16222 const Array& result = Array::Handle(Array::New(new_length, space)); 16224 const Array& result = Array::Handle(Array::New(new_length, space));
16223 intptr_t len = 0; 16225 intptr_t len = 0;
16224 if (!source.IsNull()) { 16226 if (!source.IsNull()) {
16225 len = source.Length(); 16227 len = source.Length();
16226 result.SetTypeArguments(TypeArguments::Handle(source.GetTypeArguments())); 16228 result.SetTypeArguments(TypeArguments::Handle(source.GetTypeArguments()));
16227 } 16229 }
16228 ASSERT(new_length >= len); // Cannot copy 'source' into new array. 16230 ASSERT(new_length >= len); // Cannot copy 'source' into new array.
16229 ASSERT(new_length != len); // Unnecessary copying of array. 16231 ASSERT(new_length != len); // Unnecessary copying of array.
16230 Object& obj = Object::Handle(); 16232 Object& obj = Object::Handle();
16231 for (int i = 0; i < len; i++) { 16233 for (int i = 0; i < len; i++) {
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
17399 return "_MirrorReference"; 17401 return "_MirrorReference";
17400 } 17402 }
17401 17403
17402 17404
17403 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { 17405 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const {
17404 Instance::PrintToJSONStream(stream, ref); 17406 Instance::PrintToJSONStream(stream, ref);
17405 } 17407 }
17406 17408
17407 17409
17408 } // namespace dart 17410 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698