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

Side by Side Diff: pkg/compiler/lib/src/kernel/kernel_visitor.dart

Issue 2944843002: All strong mode cleaning of dart2js. (Closed)
Patch Set: More issues discovered during testing. Created 3 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
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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 import 'package:kernel/ast.dart' as ir; 5 import 'package:kernel/ast.dart' as ir;
6 import 'package:kernel/frontend/accessors.dart' 6 import 'package:kernel/frontend/accessors.dart'
7 show 7 show
8 Accessor, 8 Accessor,
9 IndexAccessor, 9 IndexAccessor,
10 NullAwarePropertyAccessor, 10 NullAwarePropertyAccessor,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // "import foo.dart deferred as bar"). LibraryElement corresponds to the 210 // "import foo.dart deferred as bar"). LibraryElement corresponds to the
211 // imported library element. 211 // imported library element.
212 final Map<LibraryElement, Map<String, ir.LibraryDependency>> deferredImports = 212 final Map<LibraryElement, Map<String, ir.LibraryDependency>> deferredImports =
213 <LibraryElement, Map<String, ir.LibraryDependency>>{}; 213 <LibraryElement, Map<String, ir.LibraryDependency>>{};
214 214
215 ir.Node associateElement(ir.Node node, Element element) { 215 ir.Node associateElement(ir.Node node, Element element) {
216 kernel.nodeToElement[node] = element; 216 kernel.nodeToElement[node] = element;
217 return node; 217 return node;
218 } 218 }
219 219
220 ir.Node associateNode(ir.Node node, Node ast) { 220 N associateNode<N extends ir.Node>(N node, Node ast) {
221 kernel.nodeToAst[node] = ast; 221 kernel.nodeToAst[node] = ast;
222 return node; 222 return node;
223 } 223 }
224 224
225 bool isVoidContext = false; 225 bool isVoidContext = false;
226 226
227 /// If non-null, reference to a deferred library that a subsequent getter is 227 /// If non-null, reference to a deferred library that a subsequent getter is
228 /// using. 228 /// using.
229 ir.LibraryDependency _deferredLibrary; 229 ir.LibraryDependency _deferredLibrary;
230 230
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 } 1268 }
1269 1269
1270 ir.Expression buildTypeLiteralSet(TypeConstantExpression constant, Node rhs) { 1270 ir.Expression buildTypeLiteralSet(TypeConstantExpression constant, Node rhs) {
1271 return new ReadOnlyAccessor( 1271 return new ReadOnlyAccessor(
1272 buildTypeLiteral(constant), ir.TreeNode.noOffset) 1272 buildTypeLiteral(constant), ir.TreeNode.noOffset)
1273 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); 1273 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext);
1274 } 1274 }
1275 1275
1276 @override 1276 @override
1277 ir.Expression visitClassTypeLiteralSet( 1277 ir.Expression visitClassTypeLiteralSet(
1278 SendSet node, ConstantExpression constant, Node rhs, _) { 1278 SendSet node, TypeConstantExpression constant, Node rhs, _) {
1279 return buildTypeLiteralSet(constant, rhs); 1279 return buildTypeLiteralSet(constant, rhs);
1280 } 1280 }
1281 1281
1282 @override 1282 @override
1283 ir.FunctionExpression visitClosureDeclaration(FunctionExpression node, 1283 ir.FunctionExpression visitClosureDeclaration(FunctionExpression node,
1284 LocalFunctionElement closure, NodeList parameters, Node body, _) { 1284 LocalFunctionElement closure, NodeList parameters, Node body, _) {
1285 return withCurrentElement(closure, () { 1285 return withCurrentElement(closure, () {
1286 ir.FunctionExpression function = 1286 ir.FunctionExpression function =
1287 new ir.FunctionExpression(buildFunctionNode(closure, body)); 1287 new ir.FunctionExpression(buildFunctionNode(closure, body));
1288 kernel.localFunctions[closure] = function; 1288 kernel.localFunctions[closure] = function;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 Send node, 1405 Send node,
1406 ConstantExpression constant, 1406 ConstantExpression constant,
1407 NodeList arguments, 1407 NodeList arguments,
1408 CallStructure callStructure, 1408 CallStructure callStructure,
1409 _) { 1409 _) {
1410 return buildCall(buildTypeLiteral(constant), callStructure, arguments); 1410 return buildCall(buildTypeLiteral(constant), callStructure, arguments);
1411 } 1411 }
1412 1412
1413 @override 1413 @override
1414 ir.Expression visitDynamicTypeLiteralSet( 1414 ir.Expression visitDynamicTypeLiteralSet(
1415 SendSet node, ConstantExpression constant, Node rhs, _) { 1415 SendSet node, TypeConstantExpression constant, Node rhs, _) {
1416 return buildTypeLiteralSet(constant, rhs); 1416 return buildTypeLiteralSet(constant, rhs);
1417 } 1417 }
1418 1418
1419 ir.MethodInvocation buildBinaryOperator( 1419 ir.MethodInvocation buildBinaryOperator(
1420 Node left, String operator, Node right) { 1420 Node left, String operator, Node right) {
1421 ir.Name name = kernel.irName(operator, currentElement); 1421 ir.Name name = kernel.irName(operator, currentElement);
1422 return makeBinary(visitForValue(left), name, null, visitForValue(right)); 1422 return makeBinary(visitForValue(left), name, null, visitForValue(right));
1423 } 1423 }
1424 1424
1425 @override 1425 @override
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
2316 expression = 2316 expression =
2317 new ir.LoadLibrary(getDeferredImport(getter.enclosingElement)); 2317 new ir.LoadLibrary(getDeferredImport(getter.enclosingElement));
2318 } else { 2318 } else {
2319 expression = buildStaticGet(getter); 2319 expression = buildStaticGet(getter);
2320 } 2320 }
2321 return associateNode(buildCall(expression, callStructure, arguments), node); 2321 return associateNode(buildCall(expression, callStructure, arguments), node);
2322 } 2322 }
2323 2323
2324 @override 2324 @override
2325 ir.Expression handleStaticGetterSet( 2325 ir.Expression handleStaticGetterSet(
2326 SendSet node, FunctionElement getter, Node rhs, _) { 2326 SendSet node, GetterElement getter, Node rhs, _) {
2327 return buildStaticAccessor(getter) 2327 return buildStaticAccessor(getter)
2328 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); 2328 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext);
2329 } 2329 }
2330 2330
2331 @override 2331 @override
2332 IrFunction visitStaticSetterDeclaration(FunctionExpression node, 2332 IrFunction visitStaticSetterDeclaration(FunctionExpression node,
2333 MethodElement setter, NodeList parameters, Node body, _) { 2333 MethodElement setter, NodeList parameters, Node body, _) {
2334 return buildIrFunction(ir.ProcedureKind.Setter, setter, body); 2334 return buildIrFunction(ir.ProcedureKind.Setter, setter, body);
2335 } 2335 }
2336 2336
(...skipping 15 matching lines...) Expand all
2352 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); 2352 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext);
2353 } 2353 }
2354 2354
2355 @override 2355 @override
2356 ir.InvocationExpression visitStringFromEnvironmentConstructorInvoke( 2356 ir.InvocationExpression visitStringFromEnvironmentConstructorInvoke(
2357 NewExpression node, StringFromEnvironmentConstantExpression constant, _) { 2357 NewExpression node, StringFromEnvironmentConstantExpression constant, _) {
2358 return associateNode(buildConstructorInvoke(node, isConst: true), node); 2358 return associateNode(buildConstructorInvoke(node, isConst: true), node);
2359 } 2359 }
2360 2360
2361 @override 2361 @override
2362 ir.SuperMethodInvocation visitSuperBinary(Send node, FunctionElement function, 2362 ir.SuperMethodInvocation visitSuperBinary(Send node, MethodElement function,
2363 BinaryOperator operator, Node argument, _) { 2363 BinaryOperator operator, Node argument, _) {
2364 transformerFlags |= TransformerFlag.superCalls; 2364 transformerFlags |= TransformerFlag.superCalls;
2365 return new ir.SuperMethodInvocation( 2365 return new ir.SuperMethodInvocation(
2366 kernel.irName(operator.selectorName, currentElement), 2366 kernel.irName(operator.selectorName, currentElement),
2367 new ir.Arguments(<ir.Expression>[visitForValue(argument)]), 2367 new ir.Arguments(<ir.Expression>[visitForValue(argument)]),
2368 kernel.functionToIr(function)); 2368 kernel.functionToIr(function));
2369 } 2369 }
2370 2370
2371 @override 2371 @override
2372 ir.Expression visitSuperCompoundIndexSet( 2372 ir.Expression visitSuperCompoundIndexSet(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
2405 transformerFlags |= TransformerFlag.superCalls; 2405 transformerFlags |= TransformerFlag.superCalls;
2406 return new ir.SuperMethodInvocation( 2406 return new ir.SuperMethodInvocation(
2407 kernel.irName(function.name, function), 2407 kernel.irName(function.name, function),
2408 new ir.Arguments(<ir.Expression>[visitForValue(argument)], 2408 new ir.Arguments(<ir.Expression>[visitForValue(argument)],
2409 types: null, named: null), 2409 types: null, named: null),
2410 kernel.functionToIr(function)); 2410 kernel.functionToIr(function));
2411 } 2411 }
2412 2412
2413 @override 2413 @override
2414 ir.SuperMethodInvocation visitSuperEquals( 2414 ir.SuperMethodInvocation visitSuperEquals(
2415 Send node, FunctionElement function, Node argument, _) { 2415 Send node, MethodElement function, Node argument, _) {
2416 return buildSuperEquals(function, argument); 2416 return buildSuperEquals(function, argument);
2417 } 2417 }
2418 2418
2419 @override 2419 @override
2420 ir.Expression handleSuperCompounds( 2420 ir.Expression handleSuperCompounds(
2421 SendSet node, 2421 SendSet node,
2422 Element getter, 2422 Element getter,
2423 CompoundGetter getterKind, 2423 CompoundGetter getterKind,
2424 Element setter, 2424 Element setter,
2425 CompoundSetter setterKind, 2425 CompoundSetter setterKind,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2512 setter = getter; 2512 setter = getter;
2513 } 2513 }
2514 return new SuperIndexAccessor( 2514 return new SuperIndexAccessor(
2515 visitForValue(index), 2515 visitForValue(index),
2516 (getter == null) ? null : kernel.elementToIr(getter), 2516 (getter == null) ? null : kernel.elementToIr(getter),
2517 (setter == null) ? null : kernel.elementToIr(setter), 2517 (setter == null) ? null : kernel.elementToIr(setter),
2518 ir.TreeNode.noOffset); 2518 ir.TreeNode.noOffset);
2519 } 2519 }
2520 2520
2521 @override 2521 @override
2522 ir.SuperPropertyGet visitSuperGetterGet( 2522 ir.SuperPropertyGet visitSuperGetterGet(Send node, MethodElement getter, _) {
2523 Send node, FunctionElement getter, _) {
2524 return buildSuperPropertyAccessor(getter).buildSimpleRead(); 2523 return buildSuperPropertyAccessor(getter).buildSimpleRead();
2525 } 2524 }
2526 2525
2527 @override 2526 @override
2528 ir.MethodInvocation visitSuperGetterInvoke(Send node, FunctionElement getter, 2527 ir.MethodInvocation visitSuperGetterInvoke(Send node, FunctionElement getter,
2529 NodeList arguments, CallStructure callStructure, _) { 2528 NodeList arguments, CallStructure callStructure, _) {
2530 return buildCall(buildSuperPropertyAccessor(getter).buildSimpleRead(), 2529 return buildCall(buildSuperPropertyAccessor(getter).buildSimpleRead(),
2531 callStructure, arguments); 2530 callStructure, arguments);
2532 } 2531 }
2533 2532
(...skipping 15 matching lines...) Expand all
2549 _) { 2548 _) {
2550 if (setterKind == CompoundSetter.INVALID) { 2549 if (setterKind == CompoundSetter.INVALID) {
2551 setter = null; 2550 setter = null;
2552 } 2551 }
2553 return _finishSetIfNull( 2552 return _finishSetIfNull(
2554 node, buildSuperPropertyAccessor(getter, setter), rhs); 2553 node, buildSuperPropertyAccessor(getter, setter), rhs);
2555 } 2554 }
2556 2555
2557 @override 2556 @override
2558 ir.SuperMethodInvocation visitSuperIndex( 2557 ir.SuperMethodInvocation visitSuperIndex(
2559 Send node, FunctionElement function, Node index, _) { 2558 Send node, MethodElement function, Node index, _) {
2560 return buildSuperIndexAccessor(index, function).buildSimpleRead(); 2559 return buildSuperIndexAccessor(index, function).buildSimpleRead();
2561 } 2560 }
2562 2561
2563 @override 2562 @override
2564 ir.Expression visitSuperIndexPostfix(Send node, MethodElement indexFunction, 2563 ir.Expression visitSuperIndexPostfix(Send node, MethodElement indexFunction,
2565 MethodElement indexSetFunction, Node index, IncDecOperator operator, _) { 2564 MethodElement indexSetFunction, Node index, IncDecOperator operator, _) {
2566 Accessor accessor = 2565 Accessor accessor =
2567 buildSuperIndexAccessor(index, indexFunction, indexSetFunction); 2566 buildSuperIndexAccessor(index, indexFunction, indexSetFunction);
2568 return buildIndexPostfix(node, accessor, operator); 2567 return buildIndexPostfix(node, accessor, operator);
2569 } 2568 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 Send node, 2609 Send node,
2611 MethodElement method, 2610 MethodElement method,
2612 NodeList arguments, 2611 NodeList arguments,
2613 CallStructure callStructure, 2612 CallStructure callStructure,
2614 _) { 2613 _) {
2615 return associateNode(buildSuperMethodInvoke(method, arguments), node); 2614 return associateNode(buildSuperMethodInvoke(method, arguments), node);
2616 } 2615 }
2617 2616
2618 @override 2617 @override
2619 ir.Expression visitSuperMethodSet( 2618 ir.Expression visitSuperMethodSet(
2620 Send node, MethodElement method, Node rhs, _) { 2619 SendSet node, MethodElement method, Node rhs, _) {
2621 return buildSuperPropertyAccessor(method) 2620 return buildSuperPropertyAccessor(method)
2622 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); 2621 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext);
2623 } 2622 }
2624 2623
2625 @override 2624 @override
2626 ir.Not visitSuperNotEquals( 2625 ir.Not visitSuperNotEquals(
2627 Send node, FunctionElement function, Node argument, _) { 2626 Send node, MethodElement function, Node argument, _) {
2628 return new ir.Not(buildSuperEquals(function, argument)); 2627 return new ir.Not(buildSuperEquals(function, argument));
2629 } 2628 }
2630 2629
2631 @override 2630 @override
2632 ir.Expression visitSuperSetterGet(Send node, FunctionElement setter, _) { 2631 ir.Expression visitSuperSetterGet(Send node, FunctionElement setter, _) {
2633 return buildSuperPropertyAccessor(null, setter).buildSimpleRead(); 2632 return buildSuperPropertyAccessor(null, setter).buildSimpleRead();
2634 } 2633 }
2635 2634
2636 @override 2635 @override
2637 ir.MethodInvocation visitSuperSetterInvoke(Send node, FunctionElement setter, 2636 ir.MethodInvocation visitSuperSetterInvoke(Send node, FunctionElement setter,
2638 NodeList arguments, CallStructure callStructure, _) { 2637 NodeList arguments, CallStructure callStructure, _) {
2639 return buildCall(buildSuperPropertyAccessor(null, setter).buildSimpleRead(), 2638 return buildCall(buildSuperPropertyAccessor(null, setter).buildSimpleRead(),
2640 callStructure, arguments); 2639 callStructure, arguments);
2641 } 2640 }
2642 2641
2643 @override 2642 @override
2644 ir.Expression visitSuperSetterSet( 2643 ir.Expression visitSuperSetterSet(
2645 SendSet node, FunctionElement setter, Node rhs, _) { 2644 SendSet node, FunctionElement setter, Node rhs, _) {
2646 return buildSuperPropertyAccessor(null, setter) 2645 return buildSuperPropertyAccessor(null, setter)
2647 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext); 2646 .buildAssignment(visitForValue(rhs), voidContext: isVoidContext);
2648 } 2647 }
2649 2648
2650 @override 2649 @override
2651 ir.SuperMethodInvocation visitSuperUnary( 2650 ir.SuperMethodInvocation visitSuperUnary(
2652 Send node, UnaryOperator operator, FunctionElement function, _) { 2651 Send node, UnaryOperator operator, MethodElement function, _) {
2653 transformerFlags |= TransformerFlag.superCalls; 2652 transformerFlags |= TransformerFlag.superCalls;
2654 return new ir.SuperMethodInvocation(kernel.irName(function.name, function), 2653 return new ir.SuperMethodInvocation(kernel.irName(function.name, function),
2655 new ir.Arguments.empty(), kernel.functionToIr(function)); 2654 new ir.Arguments.empty(), kernel.functionToIr(function));
2656 } 2655 }
2657 2656
2658 @override 2657 @override
2659 ir.Initializer visitThisConstructorInvoke( 2658 ir.Initializer visitThisConstructorInvoke(
2660 Send node, 2659 Send node,
2661 ConstructorElement thisConstructor, 2660 ConstructorElement thisConstructor,
2662 NodeList arguments, 2661 NodeList arguments,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2820 ConstantExpression constant, 2819 ConstantExpression constant,
2821 NodeList arguments, 2820 NodeList arguments,
2822 CallStructure callStructure, 2821 CallStructure callStructure,
2823 _) { 2822 _) {
2824 return associateNode( 2823 return associateNode(
2825 buildCall(buildTypeLiteral(constant), callStructure, arguments), node); 2824 buildCall(buildTypeLiteral(constant), callStructure, arguments), node);
2826 } 2825 }
2827 2826
2828 @override 2827 @override
2829 ir.Expression visitTypedefTypeLiteralSet( 2828 ir.Expression visitTypedefTypeLiteralSet(
2830 SendSet node, ConstantExpression constant, Node rhs, _) { 2829 SendSet node, TypeConstantExpression constant, Node rhs, _) {
2831 return buildTypeLiteralSet(constant, rhs); 2830 return buildTypeLiteralSet(constant, rhs);
2832 } 2831 }
2833 2832
2834 @override 2833 @override
2835 ir.Expression handleTypeLiteralConstantSetIfNulls( 2834 ir.Expression handleTypeLiteralConstantSetIfNulls(
2836 SendSet node, ConstantExpression constant, Node rhs, _) { 2835 SendSet node, ConstantExpression constant, Node rhs, _) {
2837 // Degenerate case: ignores [rhs] as a type literal is never null. 2836 // Degenerate case: ignores [rhs] as a type literal is never null.
2838 return buildTypeLiteral(constant); 2837 return buildTypeLiteral(constant);
2839 } 2838 }
2840 2839
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2970 : this(null, true, node, initializers); 2969 : this(null, true, node, initializers);
2971 2970
2972 accept(ir.Visitor v) => throw "unsupported"; 2971 accept(ir.Visitor v) => throw "unsupported";
2973 2972
2974 visitChildren(ir.Visitor v) => throw "unsupported"; 2973 visitChildren(ir.Visitor v) => throw "unsupported";
2975 2974
2976 String toString() { 2975 String toString() {
2977 return "IrFunction($kind, $isConstructor, $node, $initializers)"; 2976 return "IrFunction($kind, $isConstructor, $node, $initializers)";
2978 } 2977 }
2979 } 2978 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/kernel_backend_strategy.dart ('k') | pkg/compiler/lib/src/kernel/types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698