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