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

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

Issue 2996723002: Support typedef type literals (Closed)
Patch Set: Cleanup Created 3 years, 4 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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:js_runtime/shared/embedded_names.dart'; 5 import 'package:js_runtime/shared/embedded_names.dart';
6 import 'package:kernel/ast.dart' as ir; 6 import 'package:kernel/ast.dart' as ir;
7 7
8 import '../common.dart'; 8 import '../common.dart';
9 import '../common/names.dart'; 9 import '../common/names.dart';
10 import '../constants/constructors.dart'; 10 import '../constants/constructors.dart';
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 ConstantExpression value = visit(expression); 617 ConstantExpression value = visit(expression);
618 if (value == null) return null; 618 if (value == null) return null;
619 values.add(value); 619 values.add(value);
620 } 620 }
621 return new ListConstantExpression( 621 return new ListConstantExpression(
622 _commonElements.listType(elementType), values); 622 _commonElements.listType(elementType), values);
623 } 623 }
624 624
625 @override 625 @override
626 ConstantExpression visitTypeLiteral(ir.TypeLiteral node) { 626 ConstantExpression visitTypeLiteral(ir.TypeLiteral node) {
627 String name;
627 DartType type = elementMap.getDartType(node.type); 628 DartType type = elementMap.getDartType(node.type);
628 String name;
629 if (type.isDynamic) { 629 if (type.isDynamic) {
630 name = 'dynamic'; 630 name = 'dynamic';
631 } else if (type is InterfaceType) { 631 } else if (type is InterfaceType) {
632 name = type.element.name; 632 name = type.element.name;
633 } else if (type.isFunctionType || type.isTypedef) { 633 } else if (type.isTypedef) {
634 // TODO(johnniwinther): Compute a name for the type literal? It is only 634 // TODO(johnniwinther): Compute a name for the type literal? It is only
635 // used in error messages in the old SSA builder. 635 // used in error messages in the old SSA builder.
636 name = '?'; 636 name = '?';
637 } else if (node.type is ir.FunctionType) {
638 ir.FunctionType functionType = node.type;
639 if (functionType.typedef != null) {
640 type = elementMap.getTypedefType(functionType.typedef);
641 name = functionType.typedef.name;
642 } else {
643 // TODO(johnniwinther): Remove branch when [KernelAstAdapter] is
644 // removed.
645 name = '?';
646 }
637 } else { 647 } else {
638 return defaultExpression(node); 648 return defaultExpression(node);
639 } 649 }
640 return new TypeConstantExpression(type, name); 650 return new TypeConstantExpression(type, name);
641 } 651 }
642 652
643 @override 653 @override
644 ConstantExpression visitNot(ir.Not node) { 654 ConstantExpression visitNot(ir.Not node) {
645 ConstantExpression expression = visit(node.operand); 655 ConstantExpression expression = visit(node.operand);
646 if (expression == null) return null; 656 if (expression == null) return null;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 } 860 }
851 if (isRedirecting) { 861 if (isRedirecting) {
852 return new RedirectingGenerativeConstantConstructor( 862 return new RedirectingGenerativeConstantConstructor(
853 defaultValues, superConstructorInvocation); 863 defaultValues, superConstructorInvocation);
854 } else { 864 } else {
855 return new GenerativeConstantConstructor( 865 return new GenerativeConstantConstructor(
856 type, defaultValues, fieldMap, superConstructorInvocation); 866 type, defaultValues, fieldMap, superConstructorInvocation);
857 } 867 }
858 } 868 }
859 } 869 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698