| 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/globals.h" // Needed here to get TARGET_ARCH_IA32. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_IA32. |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 | 9 |
| 10 #include "lib/error.h" | 10 #include "lib/error.h" |
| (...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1425 intptr_t token_index, | 1425 intptr_t token_index, |
| 1426 const AbstractType& dst_type, | 1426 const AbstractType& dst_type, |
| 1427 const String& dst_name) { | 1427 const String& dst_name) { |
| 1428 ASSERT(FLAG_enable_type_checks); | 1428 ASSERT(FLAG_enable_type_checks); |
| 1429 ASSERT(token_index >= 0); | 1429 ASSERT(token_index >= 0); |
| 1430 ASSERT(!dst_type.IsNull()); | 1430 ASSERT(!dst_type.IsNull()); |
| 1431 ASSERT(dst_type.IsFinalized()); | 1431 ASSERT(dst_type.IsFinalized()); |
| 1432 | 1432 |
| 1433 // Any expression is assignable to the Dynamic type and to the Object type. | 1433 // Any expression is assignable to the Dynamic type and to the Object type. |
| 1434 // Skip the test. | 1434 // Skip the test. |
| 1435 if (dst_type.IsDynamicType() || dst_type.IsObjectType()) { | 1435 if (!dst_type.IsMalformed() && |
| 1436 (dst_type.IsDynamicType() || dst_type.IsObjectType())) { |
| 1436 return; | 1437 return; |
| 1437 } | 1438 } |
| 1438 | 1439 |
| 1439 // It is a compile-time error to explicitly return a value (including null) | 1440 // It is a compile-time error to explicitly return a value (including null) |
| 1440 // from a void function. However, functions that do not explicitly return a | 1441 // from a void function. However, functions that do not explicitly return a |
| 1441 // value, implicitly return null. This includes void functions. Therefore, we | 1442 // value, implicitly return null. This includes void functions. Therefore, we |
| 1442 // skip the type test here and trust the parser to only return null in void | 1443 // skip the type test here and trust the parser to only return null in void |
| 1443 // function. | 1444 // function. |
| 1444 if (dst_type.IsVoidType()) { | 1445 if (dst_type.IsVoidType()) { |
| 1445 return; | 1446 return; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1460 __ PushObject(Object::ZoneHandle()); // Make room for the result. | 1461 __ PushObject(Object::ZoneHandle()); // Make room for the result. |
| 1461 const Immediate location = | 1462 const Immediate location = |
| 1462 Immediate(reinterpret_cast<int32_t>(Smi::New(token_index))); | 1463 Immediate(reinterpret_cast<int32_t>(Smi::New(token_index))); |
| 1463 __ pushl(location); // Push the source location. | 1464 __ pushl(location); // Push the source location. |
| 1464 __ pushl(EAX); // Push the source object. | 1465 __ pushl(EAX); // Push the source object. |
| 1465 __ PushObject(dst_name); // Push the name of the destination. | 1466 __ PushObject(dst_name); // Push the name of the destination. |
| 1466 __ PushObject(error_message); | 1467 __ PushObject(error_message); |
| 1467 GenerateCallRuntime(node_id, token_index, kMalformedTypeErrorRuntimeEntry); | 1468 GenerateCallRuntime(node_id, token_index, kMalformedTypeErrorRuntimeEntry); |
| 1468 // We should never return here. | 1469 // We should never return here. |
| 1469 __ int3(); | 1470 __ int3(); |
| 1471 |
| 1472 __ Bind(&done); // For a null object. |
| 1470 return; | 1473 return; |
| 1471 } | 1474 } |
| 1472 | 1475 |
| 1473 // If dst_type is instantiated and non-parameterized, we can inline code | 1476 // If dst_type is instantiated and non-parameterized, we can inline code |
| 1474 // checking whether the assigned instance is a Smi. | 1477 // checking whether the assigned instance is a Smi. |
| 1475 if (dst_type.IsInstantiated()) { | 1478 if (dst_type.IsInstantiated()) { |
| 1476 const Class& dst_type_class = Class::ZoneHandle(dst_type.type_class()); | 1479 const Class& dst_type_class = Class::ZoneHandle(dst_type.type_class()); |
| 1477 const bool dst_class_has_type_arguments = dst_type_class.HasTypeArguments(); | 1480 const bool dst_class_has_type_arguments = dst_type_class.HasTypeArguments(); |
| 1478 // A Smi object cannot be the instance of a parameterized class. | 1481 // A Smi object cannot be the instance of a parameterized class. |
| 1479 // A class equality check is only applicable with a dst type of a | 1482 // A class equality check is only applicable with a dst type of a |
| (...skipping 1202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2682 const Error& error = Error::Handle( | 2685 const Error& error = Error::Handle( |
| 2683 Parser::FormatError(script, token_index, "Error", format, args)); | 2686 Parser::FormatError(script, token_index, "Error", format, args)); |
| 2684 va_end(args); | 2687 va_end(args); |
| 2685 Isolate::Current()->long_jump_base()->Jump(1, error); | 2688 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2686 UNREACHABLE(); | 2689 UNREACHABLE(); |
| 2687 } | 2690 } |
| 2688 | 2691 |
| 2689 } // namespace dart | 2692 } // namespace dart |
| 2690 | 2693 |
| 2691 #endif // defined TARGET_ARCH_IA32 | 2694 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |