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/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
6 | 6 |
7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
10 #include "vm/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 | 847 |
848 // Type nodes are used when a type is referenced as a literal. Type nodes | 848 // Type nodes are used when a type is referenced as a literal. Type nodes |
849 // can also be used for the right-hand side of instanceof comparisons, | 849 // can also be used for the right-hand side of instanceof comparisons, |
850 // but they are handled specially in that context, not here. | 850 // but they are handled specially in that context, not here. |
851 void EffectGraphVisitor::VisitTypeNode(TypeNode* node) { | 851 void EffectGraphVisitor::VisitTypeNode(TypeNode* node) { |
852 return; | 852 return; |
853 } | 853 } |
854 | 854 |
855 | 855 |
856 void ValueGraphVisitor::VisitTypeNode(TypeNode* node) { | 856 void ValueGraphVisitor::VisitTypeNode(TypeNode* node) { |
857 ReturnDefinition(new ConstantInstr(node->type())); | 857 const AbstractType& type = node->type(); |
| 858 ASSERT(type.IsFinalized() && !type.IsMalformed()); |
| 859 if (type.IsInstantiated()) { |
| 860 ReturnDefinition(new ConstantInstr(type)); |
| 861 } else { |
| 862 const Class& instantiator_class = Class::ZoneHandle( |
| 863 owner()->parsed_function()->function().Owner()); |
| 864 Value* instantiator_value = BuildInstantiatorTypeArguments( |
| 865 node->token_pos(), instantiator_class, NULL); |
| 866 ReturnDefinition(new InstantiateTypeInstr( |
| 867 node->token_pos(), type, instantiator_class, instantiator_value)); |
| 868 } |
858 } | 869 } |
859 | 870 |
860 | 871 |
861 // Returns true if the type check can be skipped, for example, if the | 872 // Returns true if the type check can be skipped, for example, if the |
862 // destination type is dynamic or if the compile type of the value is a subtype | 873 // destination type is dynamic or if the compile type of the value is a subtype |
863 // of the destination type. | 874 // of the destination type. |
864 bool EffectGraphVisitor::CanSkipTypeCheck(intptr_t token_pos, | 875 bool EffectGraphVisitor::CanSkipTypeCheck(intptr_t token_pos, |
865 Value* value, | 876 Value* value, |
866 const AbstractType& dst_type, | 877 const AbstractType& dst_type, |
867 const String& dst_name) { | 878 const String& dst_name) { |
(...skipping 2667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3535 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3546 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
3536 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3547 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
3537 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3548 OS::SNPrint(chars, len, kFormat, function_name, reason); |
3538 const Error& error = Error::Handle( | 3549 const Error& error = Error::Handle( |
3539 LanguageError::New(String::Handle(String::New(chars)))); | 3550 LanguageError::New(String::Handle(String::New(chars)))); |
3540 Isolate::Current()->long_jump_base()->Jump(1, error); | 3551 Isolate::Current()->long_jump_base()->Jump(1, error); |
3541 } | 3552 } |
3542 | 3553 |
3543 | 3554 |
3544 } // namespace dart | 3555 } // namespace dart |
OLD | NEW |