Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 | 37 |
| 38 DEFINE_FLAG(bool, generate_gdb_symbols, false, | 38 DEFINE_FLAG(bool, generate_gdb_symbols, false, |
| 39 "Generate symbols of generated dart functions for debugging with GDB"); | 39 "Generate symbols of generated dart functions for debugging with GDB"); |
| 40 DEFINE_FLAG(bool, reject_named_argument_as_positional, false, | 40 DEFINE_FLAG(bool, reject_named_argument_as_positional, false, |
| 41 "Enforce new rules for optional parameters and disallow passing of named " | 41 "Enforce new rules for optional parameters and disallow passing of named " |
| 42 "arguments to optional positional formal parameters"); | 42 "arguments to optional positional formal parameters"); |
| 43 DEFINE_FLAG(bool, show_internal_names, false, | 43 DEFINE_FLAG(bool, show_internal_names, false, |
| 44 "Show names of internal classes (e.g. \"OneByteString\") in error messages " | 44 "Show names of internal classes (e.g. \"OneByteString\") in error messages " |
| 45 "instead of showing the corresponding interface names (e.g. \"String\")"); | 45 "instead of showing the corresponding interface names (e.g. \"String\")"); |
| 46 DECLARE_FLAG(bool, trace_compiler); | 46 DECLARE_FLAG(bool, trace_compiler); |
| 47 DECLARE_FLAG(bool, eliminate_type_checks); | |
| 47 DECLARE_FLAG(bool, enable_type_checks); | 48 DECLARE_FLAG(bool, enable_type_checks); |
| 48 | 49 |
| 49 static const char* kGetterPrefix = "get:"; | 50 static const char* kGetterPrefix = "get:"; |
| 50 static const intptr_t kGetterPrefixLength = strlen(kGetterPrefix); | 51 static const intptr_t kGetterPrefixLength = strlen(kGetterPrefix); |
| 51 static const char* kSetterPrefix = "set:"; | 52 static const char* kSetterPrefix = "set:"; |
| 52 static const intptr_t kSetterPrefixLength = strlen(kSetterPrefix); | 53 static const intptr_t kSetterPrefixLength = strlen(kSetterPrefix); |
| 53 | 54 |
| 54 cpp_vtable Object::handle_vtable_ = 0; | 55 cpp_vtable Object::handle_vtable_ = 0; |
| 55 cpp_vtable Object::builtin_vtables_[kNumPredefinedCids] = { 0 }; | 56 cpp_vtable Object::builtin_vtables_[kNumPredefinedCids] = { 0 }; |
| 56 cpp_vtable Smi::handle_vtable_ = 0; | 57 cpp_vtable Smi::handle_vtable_ = 0; |
| (...skipping 8469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8526 SetFieldAtOffset(field_offset, value); | 8527 SetFieldAtOffset(field_offset, value); |
| 8527 } | 8528 } |
| 8528 | 8529 |
| 8529 | 8530 |
| 8530 bool Instance::IsInstanceOf(const AbstractType& other, | 8531 bool Instance::IsInstanceOf(const AbstractType& other, |
| 8531 const AbstractTypeArguments& other_instantiator, | 8532 const AbstractTypeArguments& other_instantiator, |
| 8532 Error* malformed_error) const { | 8533 Error* malformed_error) const { |
| 8533 ASSERT(other.IsFinalized()); | 8534 ASSERT(other.IsFinalized()); |
| 8534 ASSERT(!other.IsDynamicType()); | 8535 ASSERT(!other.IsDynamicType()); |
| 8535 ASSERT(!other.IsMalformed()); | 8536 ASSERT(!other.IsMalformed()); |
| 8536 if (IsNull()) { | 8537 const Class& cls = Class::Handle(clazz()); |
| 8538 if (cls.IsNullClass()) { | |
| 8539 if (!IsNull()) { | |
| 8540 // We can only encounter Object::sentinel() or | |
| 8541 // Object::transition_sentinel() if type checks were not eliminated at | |
| 8542 // compile time. Both sentinels are instances of the Null class, but they | |
|
zerny-google
2012/09/18 11:20:24
Can we assert that?
regis
2012/09/18 14:55:44
There is already an assert for !FLAG_eliminate_typ
| |
| 8543 // are not the Object::null() instance. | |
| 8544 ASSERT(!FLAG_eliminate_type_checks); | |
| 8545 return true; // We are doing an instance of test as part of a type check. | |
| 8546 } | |
| 8537 // The null instance can be returned from a void function. | 8547 // The null instance can be returned from a void function. |
| 8538 if (other.IsVoidType()) { | 8548 if (other.IsVoidType()) { |
| 8539 return true; | 8549 return true; |
| 8540 } | 8550 } |
| 8541 // Otherwise, null is only an instance of Object and of Dynamic. | 8551 // Otherwise, null is only an instance of Object and of Dynamic. |
| 8542 // It is not necessary to fully instantiate the other type for this test. | 8552 // It is not necessary to fully instantiate the other type for this test. |
| 8543 Class& other_class = Class::Handle(); | 8553 Class& other_class = Class::Handle(); |
| 8544 if (other.IsTypeParameter()) { | 8554 if (other.IsTypeParameter()) { |
| 8545 if (other_instantiator.IsNull()) { | 8555 if (other_instantiator.IsNull()) { |
| 8546 return true; // Other type is uninstantiated, i.e. Dynamic. | 8556 return true; // Other type is uninstantiated, i.e. Dynamic. |
| 8547 } | 8557 } |
| 8548 const TypeParameter& other_type_param = TypeParameter::Cast(other); | 8558 const TypeParameter& other_type_param = TypeParameter::Cast(other); |
| 8549 const AbstractType& instantiated_other = AbstractType::Handle( | 8559 const AbstractType& instantiated_other = AbstractType::Handle( |
| 8550 other_instantiator.TypeAt(other_type_param.index())); | 8560 other_instantiator.TypeAt(other_type_param.index())); |
| 8551 ASSERT(instantiated_other.IsInstantiated()); | 8561 ASSERT(instantiated_other.IsInstantiated()); |
| 8552 other_class = instantiated_other.type_class(); | 8562 other_class = instantiated_other.type_class(); |
| 8553 } else { | 8563 } else { |
| 8554 other_class = other.type_class(); | 8564 other_class = other.type_class(); |
| 8555 } | 8565 } |
| 8556 return other_class.IsObjectClass() || other_class.IsDynamicClass(); | 8566 return other_class.IsObjectClass() || other_class.IsDynamicClass(); |
| 8557 } | 8567 } |
| 8558 if (other.IsVoidType()) { | 8568 if (other.IsVoidType()) { |
| 8559 return false; | 8569 return false; |
| 8560 } | 8570 } |
| 8561 const Class& cls = Class::Handle(clazz()); | |
| 8562 // We must not encounter Object::sentinel() or Object::transition_sentinel(), | |
| 8563 // both instances of class NullClass, but not instance Object::null(). | |
| 8564 ASSERT(!cls.IsNullClass()); | |
| 8565 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); | 8571 AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle(); |
| 8566 const intptr_t num_type_arguments = cls.NumTypeArguments(); | 8572 const intptr_t num_type_arguments = cls.NumTypeArguments(); |
| 8567 if (num_type_arguments > 0) { | 8573 if (num_type_arguments > 0) { |
| 8568 type_arguments = GetTypeArguments(); | 8574 type_arguments = GetTypeArguments(); |
| 8569 if (!type_arguments.IsNull() && !type_arguments.IsCanonical()) { | 8575 if (!type_arguments.IsNull() && !type_arguments.IsCanonical()) { |
| 8570 type_arguments = type_arguments.Canonicalize(); | 8576 type_arguments = type_arguments.Canonicalize(); |
| 8571 SetTypeArguments(type_arguments); | 8577 SetTypeArguments(type_arguments); |
| 8572 } | 8578 } |
| 8573 // Verify that the number of type arguments in the instance matches the | 8579 // Verify that the number of type arguments in the instance matches the |
| 8574 // number of type arguments expected by the instance class. | 8580 // number of type arguments expected by the instance class. |
| (...skipping 3040 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 11615 } | 11621 } |
| 11616 return result.raw(); | 11622 return result.raw(); |
| 11617 } | 11623 } |
| 11618 | 11624 |
| 11619 | 11625 |
| 11620 const char* WeakProperty::ToCString() const { | 11626 const char* WeakProperty::ToCString() const { |
| 11621 return "_WeakProperty"; | 11627 return "_WeakProperty"; |
| 11622 } | 11628 } |
| 11623 | 11629 |
| 11624 } // namespace dart | 11630 } // namespace dart |
| OLD | NEW |