Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: runtime/vm/flow_graph_builder.cc

Issue 9664023: Implement factory call. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "vm/ast_printer.h" 7 #include "vm/ast_printer.h"
8 #include "vm/flags.h" 8 #include "vm/flags.h"
9 #include "vm/intermediate_language.h" 9 #include "vm/intermediate_language.h"
10 #include "vm/longjump.h" 10 #include "vm/longjump.h"
(...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 Bailout("EffectGraphVisitor::VisitClosureCallNode"); 862 Bailout("EffectGraphVisitor::VisitClosureCallNode");
863 } 863 }
864 864
865 865
866 void EffectGraphVisitor::VisitCloneContextNode(CloneContextNode* node) { 866 void EffectGraphVisitor::VisitCloneContextNode(CloneContextNode* node) {
867 Bailout("EffectGraphVisitor::VisitCloneContextNode"); 867 Bailout("EffectGraphVisitor::VisitCloneContextNode");
868 } 868 }
869 869
870 870
871 void EffectGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) { 871 void EffectGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) {
872 if (node->constructor().IsFactory()) {
873 ZoneGrowableArray<Value*>* factory_arguments =
874 new ZoneGrowableArray<Value*>();
875 BuildTypeArguments(node, factory_arguments);
876 ASSERT(factory_arguments->length() == 1);
877 TranslateArgumentList(*node->arguments(),
878 temp_index() + 1,
879 factory_arguments);
880 StaticCallComp* call =
881 new StaticCallComp(node->token_index(),
882 node->constructor(),
883 node->arguments()->names(),
884 factory_arguments);
885 ReturnComputation(call);
886 return;
887 }
872 Bailout("EffectGraphVisitor::VisitConstructorCallNode"); 888 Bailout("EffectGraphVisitor::VisitConstructorCallNode");
873 } 889 }
874 890
875 891
876 void EffectGraphVisitor::BuildTypeArguments(ConstructorCallNode* node, 892 void EffectGraphVisitor::BuildTypeArguments(ConstructorCallNode* node,
877 ZoneGrowableArray<Value*>* args) { 893 ZoneGrowableArray<Value*>* args) {
878 const Class& cls = Class::ZoneHandle(node->constructor().owner()); 894 const Class& cls = Class::ZoneHandle(node->constructor().owner());
879 ASSERT(cls.HasTypeArguments()); 895 ASSERT(cls.HasTypeArguments() || node->constructor().IsFactory());
880 if (node->type_arguments().IsNull() || 896 if (node->type_arguments().IsNull() ||
881 node->type_arguments().IsInstantiated()) { 897 node->type_arguments().IsInstantiated()) {
882 AddInstruction( 898 AddInstruction(
883 new BindInstr(temp_index(), new ConstantVal(node->type_arguments()))); 899 new BindInstr(temp_index(), new ConstantVal(node->type_arguments())));
884 args->Add(new TempVal(temp_index())); 900 args->Add(new TempVal(temp_index()));
885 if (node->constructor().IsFactory()) { 901 if (!node->constructor().IsFactory()) {
886 UNIMPLEMENTED();
887 } else {
888 // Null instantiator. 902 // Null instantiator.
889 AddInstruction(new BindInstr( 903 AddInstruction(new BindInstr(
890 temp_index() + 1, new ConstantVal(Object::ZoneHandle()))); 904 temp_index() + 1, new ConstantVal(Object::ZoneHandle())));
891 args->Add(new TempVal(temp_index() + 1)); 905 args->Add(new TempVal(temp_index() + 1));
892 } 906 }
893 return; 907 return;
894 } 908 }
895 Bailout("EffectGraphVisitor::BuildTypeArguments"); 909 Bailout("EffectGraphVisitor::BuildTypeArguments");
896 } 910 }
897 911
898 912
899 void ValueGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) { 913 void ValueGraphVisitor::VisitConstructorCallNode(ConstructorCallNode* node) {
900 if (node->constructor().IsFactory()) { 914 if (node->constructor().IsFactory()) {
901 Bailout("EffectGraphVisitor::VisitConstructorCallNode Factory"); 915 EffectGraphVisitor::VisitConstructorCallNode(node);
916 return;
902 } 917 }
903 918
904 const Class& cls = Class::ZoneHandle(node->constructor().owner()); 919 const Class& cls = Class::ZoneHandle(node->constructor().owner());
905 const bool requires_type_arguments = cls.HasTypeArguments(); 920 const bool requires_type_arguments = cls.HasTypeArguments();
921
906 ZoneGrowableArray<Value*>* allocate_arguments = 922 ZoneGrowableArray<Value*>* allocate_arguments =
907 new ZoneGrowableArray<Value*>(); 923 new ZoneGrowableArray<Value*>();
908
909 if (requires_type_arguments) { 924 if (requires_type_arguments) {
910 BuildTypeArguments(node, allocate_arguments); 925 BuildTypeArguments(node, allocate_arguments);
911 } 926 }
912 // t_n contains the allocated and initialized object. 927 // t_n contains the allocated and initialized object.
913 // t_n <- AllocateObject(class) 928 // t_n <- AllocateObject(class)
914 // t_n+1 <- Pick(t_n) 929 // t_n+1 <- Pick(t_n)
915 // t_n+2 <- ctor-arg 930 // t_n+2 <- ctor-arg
916 // t_n+3... <- constructor arguments start here 931 // t_n+3... <- constructor arguments start here
917 // StaticCall(constructor, t_n+1, t_n+2, ...) 932 // StaticCall(constructor, t_n+1, t_n+2, ...)
918 933
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 char* chars = reinterpret_cast<char*>( 1464 char* chars = reinterpret_cast<char*>(
1450 Isolate::Current()->current_zone()->Allocate(len)); 1465 Isolate::Current()->current_zone()->Allocate(len));
1451 OS::SNPrint(chars, len, kFormat, function_name, reason); 1466 OS::SNPrint(chars, len, kFormat, function_name, reason);
1452 const Error& error = Error::Handle( 1467 const Error& error = Error::Handle(
1453 LanguageError::New(String::Handle(String::New(chars)))); 1468 LanguageError::New(String::Handle(String::New(chars))));
1454 Isolate::Current()->long_jump_base()->Jump(1, error); 1469 Isolate::Current()->long_jump_base()->Jump(1, error);
1455 } 1470 }
1456 1471
1457 1472
1458 } // namespace dart 1473 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698