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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/reify_coercions.dart

Issue 2363053003: Update global_compile tool (Closed)
Patch Set: Format Created 4 years, 2 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 | « no previous file | pkg/dev_compiler/tool/global_compile.dart » ('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) 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 import 'package:analyzer/analyzer.dart' as analyzer; 5 import 'package:analyzer/analyzer.dart' as analyzer;
6 import 'package:analyzer/dart/ast/ast.dart'; 6 import 'package:analyzer/dart/ast/ast.dart';
7 import 'package:analyzer/dart/element/type.dart' show DartType; 7 import 'package:analyzer/dart/element/type.dart' show DartType;
8 import 'package:analyzer/src/dart/ast/ast.dart' show FunctionBodyImpl; 8 import 'package:analyzer/src/dart/ast/ast.dart' show FunctionBodyImpl;
9 import 'package:analyzer/src/dart/ast/utilities.dart' show NodeReplacer; 9 import 'package:analyzer/src/dart/ast/utilities.dart' show NodeReplacer;
10 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl; 10 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl;
(...skipping 13 matching lines...) Expand all
24 24
25 CoercionReifier._(); 25 CoercionReifier._();
26 26
27 /// Transforms the given compilation units, and returns a new AST with 27 /// Transforms the given compilation units, and returns a new AST with
28 /// explicit coercion nodes in appropriate places. 28 /// explicit coercion nodes in appropriate places.
29 static List<CompilationUnit> reify(List<CompilationUnit> units) { 29 static List<CompilationUnit> reify(List<CompilationUnit> units) {
30 var cr = new CoercionReifier._(); 30 var cr = new CoercionReifier._();
31 return units.map(cr.visitCompilationUnit).toList(growable: false); 31 return units.map(cr.visitCompilationUnit).toList(growable: false);
32 } 32 }
33 33
34
35 /// Returns true if the `as` [node] was created by this class. 34 /// Returns true if the `as` [node] was created by this class.
36 // TODO(sra): Find a better way to recognize reified coercion, since we 35 // TODO(sra): Find a better way to recognize reified coercion, since we
37 // can't set the isSynthetic attribute. 36 // can't set the isSynthetic attribute.
38 static bool isImplicitCast(AsExpression node) => node.asOperator.offset == 0; 37 static bool isImplicitCast(AsExpression node) => node.asOperator.offset == 0;
39 38
40 /// Creates an implicit cast for expression [e] to [toType]. 39 /// Creates an implicit cast for expression [e] to [toType].
41 static Expression castExpression(Expression e, DartType toType) { 40 static Expression castExpression(Expression e, DartType toType) {
42 // We use an empty name in the AST, because the JS code generator only cares 41 // We use an empty name in the AST, because the JS code generator only cares
43 // about the target type. It does not look at the AST name. 42 // about the target type. It does not look at the AST name.
44 var typeName = new TypeName(AstBuilder.identifierFromString(''), null); 43 var typeName = new TypeName(AstBuilder.identifierFromString(''), null);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 171
173 // TODO(jmesserly): workaround for 172 // TODO(jmesserly): workaround for
174 // https://github.com/dart-lang/sdk/issues/26368 173 // https://github.com/dart-lang/sdk/issues/26368
175 @override 174 @override
176 TypeName visitTypeName(TypeName node) { 175 TypeName visitTypeName(TypeName node) {
177 var clone = super.visitTypeName(node); 176 var clone = super.visitTypeName(node);
178 clone.type = node.type; 177 clone.type = node.type;
179 return clone; 178 return clone;
180 } 179 }
181 } 180 }
OLDNEW
« no previous file with comments | « no previous file | pkg/dev_compiler/tool/global_compile.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698