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

Side by Side Diff: vm/flow_graph_builder.cc

Issue 10693092: Remove unused code for StringConcatNode from the AST and the graph builder. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 5 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 | « vm/flow_graph_builder.h ('k') | no next file » | 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/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/code_descriptors.h" 9 #include "vm/code_descriptors.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 Join(for_test, for_true, for_right); 512 Join(for_test, for_true, for_right);
513 } 513 }
514 ReturnComputation( 514 ReturnComputation(
515 BuildLoadLocal(*owner()->parsed_function().expression_temp_var())); 515 BuildLoadLocal(*owner()->parsed_function().expression_temp_var()));
516 return; 516 return;
517 } 517 }
518 EffectGraphVisitor::VisitBinaryOpNode(node); 518 EffectGraphVisitor::VisitBinaryOpNode(node);
519 } 519 }
520 520
521 521
522 void EffectGraphVisitor::CompiletimeStringInterpolation(
523 const Function& interpol_func, const Array& literals) {
524 // Do nothing.
525 }
526
527
528 void ValueGraphVisitor::CompiletimeStringInterpolation(
529 const Function& interpol_func, const Array& literals) {
530 // Build argument array to pass to the interpolation function.
531 GrowableArray<const Object*> interpolate_arg;
532 interpolate_arg.Add(&literals);
533 const Array& kNoArgumentNames = Array::Handle();
534 // Call the interpolation function.
535 String& concatenated = String::ZoneHandle();
536 concatenated ^= DartEntry::InvokeStatic(interpol_func,
537 interpolate_arg,
538 kNoArgumentNames);
539 if (concatenated.IsUnhandledException()) {
540 // TODO(srdjan): Remove this node and this UNREACHABLE.
541 UNREACHABLE();
542 }
543 ASSERT(!concatenated.IsNull());
544 concatenated = String::NewSymbol(concatenated);
545 ReturnComputation(new ConstantVal(concatenated));
546 }
547
548
549
550 // TODO(srdjan): Remove this node once the "+" string operator has been
551 // eliminated.
552 void EffectGraphVisitor::VisitStringConcatNode(StringConcatNode* node) {
553 const String& cls_name = String::Handle(String::NewSymbol("StringBase"));
554 const Library& core_lib = Library::Handle(
555 Isolate::Current()->object_store()->core_library());
556 const Class& cls = Class::Handle(core_lib.LookupClass(cls_name));
557 ASSERT(!cls.IsNull());
558 const String& func_name = String::Handle(String::NewSymbol("_interpolate"));
559 const int number_of_parameters = 1;
560 const Function& interpol_func = Function::ZoneHandle(
561 Resolver::ResolveStatic(cls, func_name,
562 number_of_parameters,
563 Array::Handle(),
564 Resolver::kIsQualified));
565 ASSERT(!interpol_func.IsNull());
566
567 // First try to concatenate and canonicalize the values at compile time.
568 bool compile_time_interpolation = true;
569 Array& literals = Array::Handle(Array::New(node->values()->length()));
570 for (int i = 0; i < node->values()->length(); i++) {
571 if (node->values()->ElementAt(i)->IsLiteralNode()) {
572 LiteralNode* lit = node->values()->ElementAt(i)->AsLiteralNode();
573 literals.SetAt(i, lit->literal());
574 } else {
575 compile_time_interpolation = false;
576 break;
577 }
578 }
579 if (compile_time_interpolation) {
580 // Not needed for effect, only for value
581 CompiletimeStringInterpolation(interpol_func, literals);
582 return;
583 }
584 // Runtime string interpolation.
585 ZoneGrowableArray<Value*>* values = new ZoneGrowableArray<Value*>();
586 ArgumentListNode* interpol_arg = new ArgumentListNode(node->token_pos());
587 interpol_arg->Add(node->values());
588 TranslateArgumentList(*interpol_arg, values);
589 StaticCallComp* call =
590 new StaticCallComp(node->token_pos(),
591 owner()->try_index(),
592 interpol_func,
593 interpol_arg->names(),
594 values);
595 ReturnComputation(call);
596 }
597
598
599 void EffectGraphVisitor::BuildTypecheckArguments( 522 void EffectGraphVisitor::BuildTypecheckArguments(
600 intptr_t token_pos, 523 intptr_t token_pos,
601 Value** instantiator_result, 524 Value** instantiator_result,
602 Value** instantiator_type_arguments_result) { 525 Value** instantiator_type_arguments_result) {
603 Value* instantiator = NULL; 526 Value* instantiator = NULL;
604 Value* instantiator_type_arguments = NULL; 527 Value* instantiator_type_arguments = NULL;
605 const Class& instantiator_class = Class::Handle( 528 const Class& instantiator_class = Class::Handle(
606 owner()->parsed_function().function().owner()); 529 owner()->parsed_function().function().owner());
607 // Since called only when type tested against is not instantiated. 530 // Since called only when type tested against is not instantiated.
608 ASSERT(instantiator_class.NumTypeParameters() > 0); 531 ASSERT(instantiator_class.NumTypeParameters() > 0);
(...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after
2807 char* chars = reinterpret_cast<char*>( 2730 char* chars = reinterpret_cast<char*>(
2808 Isolate::Current()->current_zone()->Allocate(len)); 2731 Isolate::Current()->current_zone()->Allocate(len));
2809 OS::SNPrint(chars, len, kFormat, function_name, reason); 2732 OS::SNPrint(chars, len, kFormat, function_name, reason);
2810 const Error& error = Error::Handle( 2733 const Error& error = Error::Handle(
2811 LanguageError::New(String::Handle(String::New(chars)))); 2734 LanguageError::New(String::Handle(String::New(chars))));
2812 Isolate::Current()->long_jump_base()->Jump(1, error); 2735 Isolate::Current()->long_jump_base()->Jump(1, error);
2813 } 2736 }
2814 2737
2815 2738
2816 } // namespace dart 2739 } // namespace dart
OLDNEW
« no previous file with comments | « vm/flow_graph_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698