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

Side by Side Diff: pkg/analyzer/lib/src/kernel/ast_from_analyzer.dart

Issue 2777883002: Remove Fasta's copy of accessors.dart. (Closed)
Patch Set: Remove type checking of Rasta, not strong mode clean. Created 3 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
« no previous file with comments | « no previous file | pkg/compiler/lib/src/kernel/accessors.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 library kernel.analyzer.ast_from_analyzer; 4 library kernel.analyzer.ast_from_analyzer;
5 5
6 import 'package:kernel/ast.dart' as ast; 6 import 'package:kernel/ast.dart' as ast;
7 import 'package:kernel/frontend/accessors.dart'; 7 import 'package:kernel/frontend/accessors.dart';
8 import 'package:kernel/frontend/super_initializers.dart'; 8 import 'package:kernel/frontend/super_initializers.dart';
9 import 'package:kernel/log.dart'; 9 import 'package:kernel/log.dart';
10 import 'package:kernel/type_algebra.dart'; 10 import 'package:kernel/type_algebra.dart';
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1410 return node.leftBracket.offset; 1410 return node.leftBracket.offset;
1411 } 1411 }
1412 return node.offset; 1412 return node.offset;
1413 } 1413 }
1414 1414
1415 Accessor buildLeftHandValue(Expression node) { 1415 Accessor buildLeftHandValue(Expression node) {
1416 var result = node.accept(this); 1416 var result = node.accept(this);
1417 if (result is Accessor) { 1417 if (result is Accessor) {
1418 return result; 1418 return result;
1419 } else { 1419 } else {
1420 return new ReadOnlyAccessor(result); 1420 return new ReadOnlyAccessor(result, ast.TreeNode.noOffset);
1421 } 1421 }
1422 } 1422 }
1423 1423
1424 ast.Expression visitAsExpression(AsExpression node) { 1424 ast.Expression visitAsExpression(AsExpression node) {
1425 return new ast.AsExpression( 1425 return new ast.AsExpression(
1426 build(node.expression), scope.buildTypeAnnotation(node.type)); 1426 build(node.expression), scope.buildTypeAnnotation(node.type));
1427 } 1427 }
1428 1428
1429 ast.Expression visitAssignmentExpression(AssignmentExpression node) { 1429 ast.Expression visitAssignmentExpression(AssignmentExpression node) {
1430 bool voidContext = isInVoidContext(node); 1430 bool voidContext = isInVoidContext(node);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 scope.resolveInterfaceSet(element, auxiliary)); 1720 scope.resolveInterfaceSet(element, auxiliary));
1721 1721
1722 case ElementKind.FUNCTION: 1722 case ElementKind.FUNCTION:
1723 FunctionElement function = element; 1723 FunctionElement function = element;
1724 if (isTopLevelFunction(function)) { 1724 if (isTopLevelFunction(function)) {
1725 return scope.staticAccess(node.name, function); 1725 return scope.staticAccess(node.name, function);
1726 } 1726 }
1727 if (function == function.library.loadLibraryFunction) { 1727 if (function == function.library.loadLibraryFunction) {
1728 return scope.unsupportedFeature('Deferred loading'); 1728 return scope.unsupportedFeature('Deferred loading');
1729 } 1729 }
1730 return new VariableAccessor(scope.getVariableReference(function)); 1730 return new VariableAccessor(
1731 scope.getVariableReference(function), null, ast.TreeNode.noOffset);
1731 1732
1732 case ElementKind.LOCAL_VARIABLE: 1733 case ElementKind.LOCAL_VARIABLE:
1733 case ElementKind.PARAMETER: 1734 case ElementKind.PARAMETER:
1734 VariableElement variable = element; 1735 VariableElement variable = element;
1735 var type = identical(node.staticType, variable.type) 1736 var type = identical(node.staticType, variable.type)
1736 ? null 1737 ? null
1737 : scope.buildType(node.staticType); 1738 : scope.buildType(node.staticType);
1738 return new VariableAccessor(scope.getVariableReference(element), type); 1739 return new VariableAccessor(
1740 scope.getVariableReference(element), type, ast.TreeNode.noOffset);
1739 1741
1740 case ElementKind.IMPORT: 1742 case ElementKind.IMPORT:
1741 case ElementKind.LIBRARY: 1743 case ElementKind.LIBRARY:
1742 case ElementKind.PREFIX: 1744 case ElementKind.PREFIX:
1743 return scope.emitCompileTimeError( 1745 return scope.emitCompileTimeError(
1744 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 1746 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT,
1745 [node.name]); 1747 [node.name]);
1746 1748
1747 case ElementKind.COMPILATION_UNIT: 1749 case ElementKind.COMPILATION_UNIT:
1748 case ElementKind.CONSTRUCTOR: 1750 case ElementKind.CONSTRUCTOR:
(...skipping 13 matching lines...) Expand all
1762 return IndexAccessor.make( 1764 return IndexAccessor.make(
1763 makeCascadeReceiver(), 1765 makeCascadeReceiver(),
1764 build(node.index), 1766 build(node.index),
1765 scope.resolveInterfaceIndexGet(element, auxiliary), 1767 scope.resolveInterfaceIndexGet(element, auxiliary),
1766 scope.resolveInterfaceIndexSet(element, auxiliary)); 1768 scope.resolveInterfaceIndexSet(element, auxiliary));
1767 } else if (node.target is SuperExpression) { 1769 } else if (node.target is SuperExpression) {
1768 scope.addTransformerFlag(TransformerFlag.superCalls); 1770 scope.addTransformerFlag(TransformerFlag.superCalls);
1769 return new SuperIndexAccessor( 1771 return new SuperIndexAccessor(
1770 build(node.index), 1772 build(node.index),
1771 scope.resolveConcreteIndexGet(element, auxiliary), 1773 scope.resolveConcreteIndexGet(element, auxiliary),
1772 scope.resolveConcreteIndexSet(element, auxiliary)); 1774 scope.resolveConcreteIndexSet(element, auxiliary),
1775 ast.TreeNode.noOffset);
1773 } else { 1776 } else {
1774 return IndexAccessor.make( 1777 return IndexAccessor.make(
1775 build(node.target), 1778 build(node.target),
1776 build(node.index), 1779 build(node.index),
1777 scope.resolveInterfaceIndexGet(element, auxiliary), 1780 scope.resolveInterfaceIndexGet(element, auxiliary),
1778 scope.resolveInterfaceIndexSet(element, auxiliary)); 1781 scope.resolveInterfaceIndexSet(element, auxiliary));
1779 } 1782 }
1780 } 1783 }
1781 1784
1782 /// Follows any number of redirecting factories, returning the effective 1785 /// Follows any number of redirecting factories, returning the effective
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 var setter = scope.resolveInterfaceSet(element, auxiliary); 2085 var setter = scope.resolveInterfaceSet(element, auxiliary);
2083 Expression target = node.target; 2086 Expression target = node.target;
2084 if (node.isCascaded) { 2087 if (node.isCascaded) {
2085 return PropertyAccessor.make(makeCascadeReceiver(), 2088 return PropertyAccessor.make(makeCascadeReceiver(),
2086 scope.buildName(node.propertyName), getter, setter); 2089 scope.buildName(node.propertyName), getter, setter);
2087 } else if (node.target is SuperExpression) { 2090 } else if (node.target is SuperExpression) {
2088 scope.addTransformerFlag(TransformerFlag.superCalls); 2091 scope.addTransformerFlag(TransformerFlag.superCalls);
2089 return new SuperPropertyAccessor( 2092 return new SuperPropertyAccessor(
2090 scope.buildName(node.propertyName), 2093 scope.buildName(node.propertyName),
2091 scope.resolveConcreteGet(element, auxiliary), 2094 scope.resolveConcreteGet(element, auxiliary),
2092 scope.resolveConcreteSet(element, auxiliary)); 2095 scope.resolveConcreteSet(element, auxiliary),
2096 ast.TreeNode.noOffset);
2093 } else if (target is Identifier && target.staticElement is ClassElement) { 2097 } else if (target is Identifier && target.staticElement is ClassElement) {
2094 // Note that this case also covers null-aware static access on a class, 2098 // Note that this case also covers null-aware static access on a class,
2095 // which is equivalent to a regular static access. 2099 // which is equivalent to a regular static access.
2096 return scope.staticAccess(node.propertyName.name, element, auxiliary); 2100 return scope.staticAccess(node.propertyName.name, element, auxiliary);
2097 } else if (node.operator.value() == '?.') { 2101 } else if (node.operator.value() == '?.') {
2098 return new NullAwarePropertyAccessor( 2102 return new NullAwarePropertyAccessor(
2099 build(target), 2103 build(target),
2100 scope.buildName(node.propertyName), 2104 scope.buildName(node.propertyName),
2101 getter, 2105 getter,
2102 setter, 2106 setter,
2103 scope.buildType(node.staticType)); 2107 scope.buildType(node.staticType),
2108 ast.TreeNode.noOffset);
2104 } else { 2109 } else {
2105 return PropertyAccessor.make( 2110 return PropertyAccessor.make(
2106 build(target), scope.buildName(node.propertyName), getter, setter); 2111 build(target), scope.buildName(node.propertyName), getter, setter);
2107 } 2112 }
2108 } 2113 }
2109 2114
2110 ast.Expression visitRethrowExpression(RethrowExpression node) { 2115 ast.Expression visitRethrowExpression(RethrowExpression node) {
2111 return new ast.Rethrow(); 2116 return new ast.Rethrow();
2112 } 2117 }
2113 2118
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
2997 } 3002 }
2998 3003
2999 /// A [StaticAccessor] that throws a NoSuchMethodError when a suitable target 3004 /// A [StaticAccessor] that throws a NoSuchMethodError when a suitable target
3000 /// could not be resolved. 3005 /// could not be resolved.
3001 class _StaticAccessor extends StaticAccessor { 3006 class _StaticAccessor extends StaticAccessor {
3002 final ExpressionScope scope; 3007 final ExpressionScope scope;
3003 final String name; 3008 final String name;
3004 3009
3005 _StaticAccessor( 3010 _StaticAccessor(
3006 this.scope, this.name, ast.Member readTarget, ast.Member writeTarget) 3011 this.scope, this.name, ast.Member readTarget, ast.Member writeTarget)
3007 : super(readTarget, writeTarget); 3012 : super(readTarget, writeTarget, ast.TreeNode.noOffset);
3008 3013
3009 @override 3014 @override
3010 makeInvalidRead() { 3015 makeInvalidRead() {
3011 return scope.buildThrowNoSuchMethodError( 3016 return scope.buildThrowNoSuchMethodError(
3012 new ast.NullLiteral(), name, new ast.Arguments([])); 3017 new ast.NullLiteral(), name, new ast.Arguments([]));
3013 } 3018 }
3014 3019
3015 @override 3020 @override
3016 makeInvalidWrite(ast.Expression value) { 3021 makeInvalidWrite(ast.Expression value) {
3017 return scope.buildThrowNoSuchMethodError( 3022 return scope.buildThrowNoSuchMethodError(
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
3073 if (list[i - 1].compareTo(item) == 0) { 3078 if (list[i - 1].compareTo(item) == 0) {
3074 ++deleted; 3079 ++deleted;
3075 } else if (deleted > 0) { 3080 } else if (deleted > 0) {
3076 list[i - deleted] = item; 3081 list[i - deleted] = item;
3077 } 3082 }
3078 } 3083 }
3079 if (deleted > 0) { 3084 if (deleted > 0) {
3080 list.length -= deleted; 3085 list.length -= deleted;
3081 } 3086 }
3082 } 3087 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/kernel/accessors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698