OLD | NEW |
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/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 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1378 // - Smi -> compile time subtype check (only if dst class is not parameterized). | 1378 // - Smi -> compile time subtype check (only if dst class is not parameterized). |
1379 // - Class equality (only if class is not parameterized). | 1379 // - Class equality (only if class is not parameterized). |
1380 // Inputs: | 1380 // Inputs: |
1381 // - EAX: object. | 1381 // - EAX: object. |
1382 // Destroys ECX. | 1382 // Destroys ECX. |
1383 // Returns: | 1383 // Returns: |
1384 // - true or false on stack. | 1384 // - true or false on stack. |
1385 void CodeGenerator::GenerateInstanceOf(intptr_t token_index, | 1385 void CodeGenerator::GenerateInstanceOf(intptr_t token_index, |
1386 const Type& type, | 1386 const Type& type, |
1387 bool negate_result) { | 1387 bool negate_result) { |
| 1388 ASSERT(type.IsFinalized()); |
1388 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); | 1389 const Bool& bool_true = Bool::ZoneHandle(Bool::True()); |
1389 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); | 1390 const Bool& bool_false = Bool::ZoneHandle(Bool::False()); |
1390 | 1391 |
1391 // All instances are of type Object. | 1392 // All instances are of type Object. |
1392 const Type& object_type = | 1393 const Type& object_type = |
1393 Type::Handle(Isolate::Current()->object_store()->object_type()); | 1394 Type::Handle(Isolate::Current()->object_store()->object_type()); |
1394 if (type.IsInstantiated() && object_type.IsSubtypeOf(type)) { | 1395 if (type.IsInstantiated() && object_type.IsSubtypeOf(type)) { |
1395 // All objects are an instance of the Object class. | 1396 // All objects are an instance of the Object class. |
1396 __ PushObject(negate_result ? bool_false : bool_true); | 1397 __ PushObject(negate_result ? bool_false : bool_true); |
1397 return; | 1398 return; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 // - EAX: object. | 1498 // - EAX: object. |
1498 // Destroys ECX and EDX. | 1499 // Destroys ECX and EDX. |
1499 // Returns: | 1500 // Returns: |
1500 // - object in EAX for successful assignable check (or throws TypeError). | 1501 // - object in EAX for successful assignable check (or throws TypeError). |
1501 void CodeGenerator::GenerateAssertAssignable(intptr_t token_index, | 1502 void CodeGenerator::GenerateAssertAssignable(intptr_t token_index, |
1502 const Type& dst_type, | 1503 const Type& dst_type, |
1503 const String& dst_name) { | 1504 const String& dst_name) { |
1504 ASSERT(FLAG_enable_type_checks); | 1505 ASSERT(FLAG_enable_type_checks); |
1505 ASSERT(token_index >= 0); | 1506 ASSERT(token_index >= 0); |
1506 ASSERT(!dst_type.IsNull()); | 1507 ASSERT(!dst_type.IsNull()); |
1507 ASSERT(dst_type.IsResolved()); | 1508 ASSERT(dst_type.IsFinalized()); |
1508 | 1509 |
1509 // Any expression is assignable to the VarType. Skip the test. | 1510 // Any expression is assignable to the VarType. Skip the test. |
1510 if (dst_type.IsVarType()) { | 1511 if (dst_type.IsVarType()) { |
1511 return; | 1512 return; |
1512 } | 1513 } |
1513 | 1514 |
1514 // It is a compile-time error to explicitly return a value (including null) | 1515 // It is a compile-time error to explicitly return a value (including null) |
1515 // from a void function. However, functions that do not explicitly return a | 1516 // from a void function. However, functions that do not explicitly return a |
1516 // value, implicitly return null. This includes void functions. Therefore, we | 1517 // value, implicitly return null. This includes void functions. Therefore, we |
1517 // skip the type test here and trust the parser to only return null in void | 1518 // skip the type test here and trust the parser to only return null in void |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2654 const Class& cls = Class::Handle(parsed_function_.function().owner()); | 2655 const Class& cls = Class::Handle(parsed_function_.function().owner()); |
2655 const Script& script = Script::Handle(cls.script()); | 2656 const Script& script = Script::Handle(cls.script()); |
2656 Parser::ReportMsg(script, token_index, "Error", error_msg, format, args); | 2657 Parser::ReportMsg(script, token_index, "Error", error_msg, format, args); |
2657 Isolate::Current()->long_jump_base()->Jump(1, error_msg); | 2658 Isolate::Current()->long_jump_base()->Jump(1, error_msg); |
2658 UNREACHABLE(); | 2659 UNREACHABLE(); |
2659 } | 2660 } |
2660 | 2661 |
2661 } // namespace dart | 2662 } // namespace dart |
2662 | 2663 |
2663 #endif // defined TARGET_ARCH_IA32 | 2664 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |