Chromium Code Reviews| 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" |
| 11 #include "vm/ast_printer.h" | 11 #include "vm/ast_printer.h" |
| 12 #include "vm/class_finalizer.h" | 12 #include "vm/class_finalizer.h" |
| 13 #include "vm/dart_entry.h" | 13 #include "vm/dart_entry.h" |
| 14 #include "vm/ic_data.h" | 14 #include "vm/ic_data.h" |
| 15 #include "vm/longjump.h" | 15 #include "vm/longjump.h" |
| 16 #include "vm/object.h" | 16 #include "vm/object.h" |
| 17 #include "vm/object_store.h" | 17 #include "vm/object_store.h" |
| 18 #include "vm/parser.h" | 18 #include "vm/parser.h" |
| 19 #include "vm/resolver.h" | 19 #include "vm/resolver.h" |
| 20 #include "vm/stub_code.h" | 20 #include "vm/stub_code.h" |
| 21 | 21 |
| 22 namespace dart { | 22 namespace dart { |
| 23 | 23 |
| 24 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 24 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
| 25 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); | 25 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); |
| 26 DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function."); | 26 DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function."); |
| 27 DEFINE_FLAG(int, optimization_invocation_threshold, 1000, | 27 DEFINE_FLAG(int, optimization_invocation_threshold, 1000, |
| 28 "number of invocations before a fucntion is optimized, -1 means never."); | 28 "number of invocations before a function is optimized, -1 means never."); |
| 29 DECLARE_FLAG(bool, enable_type_checks); | 29 DECLARE_FLAG(bool, enable_type_checks); |
| 30 DECLARE_FLAG(bool, report_invocation_count); | 30 DECLARE_FLAG(bool, report_invocation_count); |
| 31 DECLARE_FLAG(bool, trace_compiler); | 31 DECLARE_FLAG(bool, trace_compiler); |
| 32 | 32 |
| 33 #define __ assembler_-> | 33 #define __ assembler_-> |
| 34 | 34 |
| 35 | 35 |
| 36 class CodeGeneratorState : public StackResource { | 36 class CodeGeneratorState : public StackResource { |
| 37 public: | 37 public: |
| 38 explicit CodeGeneratorState(CodeGenerator* codegen) | 38 explicit CodeGeneratorState(CodeGenerator* codegen) |
| (...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1501 // - object in EAX for successful assignable check (or throws TypeError). | 1501 // - object in EAX for successful assignable check (or throws TypeError). |
| 1502 void CodeGenerator::GenerateAssertAssignable(intptr_t node_id, | 1502 void CodeGenerator::GenerateAssertAssignable(intptr_t node_id, |
| 1503 intptr_t token_index, | 1503 intptr_t token_index, |
| 1504 const Type& dst_type, | 1504 const Type& dst_type, |
| 1505 const String& dst_name) { | 1505 const String& dst_name) { |
| 1506 ASSERT(FLAG_enable_type_checks); | 1506 ASSERT(FLAG_enable_type_checks); |
| 1507 ASSERT(token_index >= 0); | 1507 ASSERT(token_index >= 0); |
| 1508 ASSERT(!dst_type.IsNull()); | 1508 ASSERT(!dst_type.IsNull()); |
| 1509 ASSERT(dst_type.IsFinalized()); | 1509 ASSERT(dst_type.IsFinalized()); |
| 1510 | 1510 |
| 1511 // Any expression is assignable to the DynamicType. Skip the test. | 1511 // Any expression is assignable to the DynamicType or Object. Skip the test. |
|
regis
2011/11/08 21:18:10
Any expression is always assignable to the Dynamic
srdjan
2011/11/08 21:28:47
Done.
| |
| 1512 if (dst_type.IsDynamicType()) { | 1512 if (dst_type.IsDynamicType() || dst_type.IsObjectType()) { |
| 1513 return; | 1513 return; |
| 1514 } | 1514 } |
| 1515 | 1515 |
| 1516 // It is a compile-time error to explicitly return a value (including null) | 1516 // It is a compile-time error to explicitly return a value (including null) |
| 1517 // from a void function. However, functions that do not explicitly return a | 1517 // from a void function. However, functions that do not explicitly return a |
| 1518 // value, implicitly return null. This includes void functions. Therefore, we | 1518 // value, implicitly return null. This includes void functions. Therefore, we |
| 1519 // skip the type test here and trust the parser to only return null in void | 1519 // skip the type test here and trust the parser to only return null in void |
| 1520 // function. | 1520 // function. |
| 1521 if (dst_type.IsVoidType()) { | 1521 if (dst_type.IsVoidType()) { |
| 1522 return; | 1522 return; |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2679 const Class& cls = Class::Handle(parsed_function_.function().owner()); | 2679 const Class& cls = Class::Handle(parsed_function_.function().owner()); |
| 2680 const Script& script = Script::Handle(cls.script()); | 2680 const Script& script = Script::Handle(cls.script()); |
| 2681 Parser::ReportMsg(script, token_index, "Error", error_msg, format, args); | 2681 Parser::ReportMsg(script, token_index, "Error", error_msg, format, args); |
| 2682 Isolate::Current()->long_jump_base()->Jump(1, error_msg); | 2682 Isolate::Current()->long_jump_base()->Jump(1, error_msg); |
| 2683 UNREACHABLE(); | 2683 UNREACHABLE(); |
| 2684 } | 2684 } |
| 2685 | 2685 |
| 2686 } // namespace dart | 2686 } // namespace dart |
| 2687 | 2687 |
| 2688 #endif // defined TARGET_ARCH_IA32 | 2688 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |