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

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

Issue 8776020: Ongoing renaming of type classes: (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 | « runtime/lib/double.cc ('k') | runtime/lib/isolate.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 "lib/error.h" 5 #include "lib/error.h"
6 6
7 #include "vm/bootstrap_natives.h" 7 #include "vm/bootstrap_natives.h"
8 #include "vm/exceptions.h" 8 #include "vm/exceptions.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/runtime_entry.h" 10 #include "vm/runtime_entry.h"
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 // Arg1: instance being assigned. 208 // Arg1: instance being assigned.
209 // Arg2: type being assigned to. 209 // Arg2: type being assigned to.
210 // Arg3: type arguments of the instantiator of the type being assigned to. 210 // Arg3: type arguments of the instantiator of the type being assigned to.
211 // Arg4: name of instance being assigned to. 211 // Arg4: name of instance being assigned to.
212 // Return value: instance if assignable, otherwise throw a TypeError. 212 // Return value: instance if assignable, otherwise throw a TypeError.
213 DEFINE_RUNTIME_ENTRY(TypeCheck, 5) { 213 DEFINE_RUNTIME_ENTRY(TypeCheck, 5) {
214 ASSERT(arguments.Count() == kTypeCheckRuntimeEntry.argument_count()); 214 ASSERT(arguments.Count() == kTypeCheckRuntimeEntry.argument_count());
215 intptr_t location = Smi::CheckedHandle(arguments.At(0)).Value(); 215 intptr_t location = Smi::CheckedHandle(arguments.At(0)).Value();
216 const Instance& src_instance = Instance::CheckedHandle(arguments.At(1)); 216 const Instance& src_instance = Instance::CheckedHandle(arguments.At(1));
217 const AbstractType& dst_type = AbstractType::CheckedHandle(arguments.At(2)); 217 const AbstractType& dst_type = AbstractType::CheckedHandle(arguments.At(2));
218 const TypeArguments& dst_type_instantiator = 218 const AbstractTypeArguments& dst_type_instantiator =
219 TypeArguments::CheckedHandle(arguments.At(3)); 219 AbstractTypeArguments::CheckedHandle(arguments.At(3));
220 const String& dst_name = String::CheckedHandle(arguments.At(4)); 220 const String& dst_name = String::CheckedHandle(arguments.At(4));
221 ASSERT(!dst_type.IsDynamicType()); // No need to check assignment. 221 ASSERT(!dst_type.IsDynamicType()); // No need to check assignment.
222 ASSERT(!src_instance.IsNull()); // Already checked in inlined code. 222 ASSERT(!src_instance.IsNull()); // Already checked in inlined code.
223 223
224 const bool is_assignable = 224 const bool is_assignable =
225 src_instance.IsAssignableTo(dst_type, dst_type_instantiator); 225 src_instance.IsAssignableTo(dst_type, dst_type_instantiator);
226 226
227 if (FLAG_trace_type_checks) { 227 if (FLAG_trace_type_checks) {
228 const Type& src_type = Type::Handle(src_instance.GetType()); 228 const Type& src_type = Type::Handle(src_instance.GetType());
229 AbstractType& instantiated_dst_type = AbstractType::Handle(dst_type.raw()); 229 AbstractType& instantiated_dst_type = AbstractType::Handle(dst_type.raw());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 // Arg3: type arguments of the instantiator of the element declaration type. 285 // Arg3: type arguments of the instantiator of the element declaration type.
286 // Arg4: name of object being assigned to, i.e. name of rest argument. 286 // Arg4: name of object being assigned to, i.e. name of rest argument.
287 // Return value: null if assignable, otherwise allocate and throw a TypeError. 287 // Return value: null if assignable, otherwise allocate and throw a TypeError.
288 DEFINE_RUNTIME_ENTRY(RestArgumentTypeCheck, 5) { 288 DEFINE_RUNTIME_ENTRY(RestArgumentTypeCheck, 5) {
289 ASSERT(arguments.Count() == 289 ASSERT(arguments.Count() ==
290 kRestArgumentTypeCheckRuntimeEntry.argument_count()); 290 kRestArgumentTypeCheckRuntimeEntry.argument_count());
291 intptr_t location = Smi::CheckedHandle(arguments.At(0)).Value(); 291 intptr_t location = Smi::CheckedHandle(arguments.At(0)).Value();
292 const Array& rest_array = Array::CheckedHandle(arguments.At(1)); 292 const Array& rest_array = Array::CheckedHandle(arguments.At(1));
293 const AbstractType& element_type = 293 const AbstractType& element_type =
294 AbstractType::CheckedHandle(arguments.At(2)); 294 AbstractType::CheckedHandle(arguments.At(2));
295 const TypeArguments& element_type_instantiator = 295 const AbstractTypeArguments& element_type_instantiator =
296 TypeArguments::CheckedHandle(arguments.At(3)); 296 AbstractTypeArguments::CheckedHandle(arguments.At(3));
297 const String& rest_name = String::CheckedHandle(arguments.At(4)); 297 const String& rest_name = String::CheckedHandle(arguments.At(4));
298 ASSERT(!element_type.IsDynamicType()); // No need to check assignment. 298 ASSERT(!element_type.IsDynamicType()); // No need to check assignment.
299 ASSERT(!rest_array.IsNull()); 299 ASSERT(!rest_array.IsNull());
300 300
301 Instance& elem = Instance::Handle(); 301 Instance& elem = Instance::Handle();
302 for (intptr_t i = 0; i < rest_array.Length(); i++) { 302 for (intptr_t i = 0; i < rest_array.Length(); i++) {
303 elem ^= rest_array.At(i); 303 elem ^= rest_array.At(i);
304 if (!elem.IsNull() && 304 if (!elem.IsNull() &&
305 !elem.IsAssignableTo(element_type, element_type_instantiator)) { 305 !elem.IsAssignableTo(element_type, element_type_instantiator)) {
306 // Allocate and throw a new instance of TypeError. 306 // Allocate and throw a new instance of TypeError.
(...skipping 12 matching lines...) Expand all
319 dst_type_name = element_type.Name(); 319 dst_type_name = element_type.Name();
320 } 320 }
321 const String& dst_name = String::Handle(String::New(buf)); 321 const String& dst_name = String::Handle(String::New(buf));
322 ThrowTypeError(location, src_type_name, dst_type_name, dst_name); 322 ThrowTypeError(location, src_type_name, dst_type_name, dst_name);
323 UNREACHABLE(); 323 UNREACHABLE();
324 } 324 }
325 } 325 }
326 } 326 }
327 327
328 } // namespace dart 328 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/double.cc ('k') | runtime/lib/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698