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

Side by Side Diff: lib/src/info.dart

Issue 1169873002: dead code elimination in reify_coercions (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « lib/src/codegen/reify_coercions.dart ('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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Defines static information collected by the type checker and used later by 5 /// Defines static information collected by the type checker and used later by
6 /// emitters to generate code. 6 /// emitters to generate code.
7 library dev_compiler.src.info; 7 library dev_compiler.src.info;
8 8
9 import 'dart:mirrors'; 9 import 'dart:mirrors';
10 10
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 /// <http://goo.gl/q1T4BB> 646 /// <http://goo.gl/q1T4BB>
647 /// 647 ///
648 /// For now this is the only pattern we support. 648 /// For now this is the only pattern we support.
649 class InvalidSuperInvocation extends StaticError { 649 class InvalidSuperInvocation extends StaticError {
650 InvalidSuperInvocation(SuperConstructorInvocation node) : super(node); 650 InvalidSuperInvocation(SuperConstructorInvocation node) : super(node);
651 651
652 String get message => "super call must be last in an initializer list " 652 String get message => "super call must be last in an initializer list "
653 "(see http://goo.gl/q1T4BB): $node"; 653 "(see http://goo.gl/q1T4BB): $node";
654 } 654 }
655 655
656 /// Calls into the runtime support library
657 class RuntimeOperation extends Expression {
658 final List<Expression> arguments;
659 final String operation;
660 Token opToken;
661
662 RuntimeOperation(this.operation, this.arguments) {
663 opToken = new SyntheticStringToken(TokenType.IDENTIFIER, this.operation, 0);
664 }
665
666 Token get beginToken => opToken;
667 Token get endToken => opToken;
668
669 @override
670 accept(AstVisitor visitor) {
671 if (visitor is ConversionVisitor) {
672 return visitor.visitRuntimeOperation(this);
673 } else if (visitor is AstCloner) {
674 var l = arguments.map((e) => e.accept(visitor)).toList();
675 return new RuntimeOperation(operation, l);
676 } else {
677 visitChildren(visitor);
678 }
679 }
680
681 @override
682 void visitChildren(AstVisitor visitor) {
683 arguments.forEach((e) => e.accept(visitor));
684 }
685
686 // Use same precedence as MethodInvocation.
687 int get precedence => 15;
688
689 @override
690 Iterable get childEntities => new ChildEntities()
691 ..add(opToken)
692 ..addAll(arguments);
693 }
694
695 /// A simple generalizing visitor interface for the conversion nodes. 656 /// A simple generalizing visitor interface for the conversion nodes.
696 /// This can be mixed in to your visitor if the AST can contain these nodes. 657 /// This can be mixed in to your visitor if the AST can contain these nodes.
697 /// TODO(leafp): Rename to something appropriate if RuntimeOperation stays
698 /// around
699 abstract class ConversionVisitor<R> implements AstVisitor<R> { 658 abstract class ConversionVisitor<R> implements AstVisitor<R> {
700 /// This method must be implemented. It is typically supplied by the base 659 /// This method must be implemented. It is typically supplied by the base
701 /// GeneralizingAstVisitor<R>. 660 /// GeneralizingAstVisitor<R>.
702 R visitNode(AstNode node); 661 R visitNode(AstNode node);
703 662
704 // Handle runtime operations
705 R visitRuntimeOperation(RuntimeOperation node) => visitNode(node);
706
707 /// The catch-all for any kind of conversion 663 /// The catch-all for any kind of conversion
708 R visitConversion(Conversion node) => visitNode(node); 664 R visitConversion(Conversion node) => visitNode(node);
709 665
710 // Methods for conversion subtypes: 666 // Methods for conversion subtypes:
711 R visitDownCast(DownCast node) => visitConversion(node); 667 R visitDownCast(DownCast node) => visitConversion(node);
712 R visitClosureWrapBase(ClosureWrapBase node) => visitConversion(node); 668 R visitClosureWrapBase(ClosureWrapBase node) => visitConversion(node);
713 R visitClosureWrap(ClosureWrap node) => visitClosureWrapBase(node); 669 R visitClosureWrap(ClosureWrap node) => visitClosureWrapBase(node);
714 R visitDynamicInvoke(DynamicInvoke node) => visitConversion(node); 670 R visitDynamicInvoke(DynamicInvoke node) => visitConversion(node);
715 R visitInferredTypeBase(InferredTypeBase node) => visitConversion(node); 671 R visitInferredTypeBase(InferredTypeBase node) => visitConversion(node);
716 } 672 }
(...skipping 22 matching lines...) Expand all
739 var isError = severity == analyzer.ErrorSeverity.WARNING; 695 var isError = severity == analyzer.ErrorSeverity.WARNING;
740 var level = isError ? Level.SEVERE : Level.WARNING; 696 var level = isError ? Level.SEVERE : Level.WARNING;
741 int begin = error.offset; 697 int begin = error.offset;
742 int end = begin + error.length; 698 int end = begin + error.length;
743 return new AnalyzerError(error.message, level, begin, end); 699 return new AnalyzerError(error.message, level, begin, end);
744 } 700 }
745 701
746 const AnalyzerError(String message, Level level, int begin, int end) 702 const AnalyzerError(String message, Level level, int begin, int end)
747 : super(message, level, begin, end); 703 : super(message, level, begin, end);
748 } 704 }
OLDNEW
« no previous file with comments | « lib/src/codegen/reify_coercions.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698