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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/ir/ir_builder.dart

Issue 355373002: dart2dart: Fixed treatment of dynamic type literals in new IR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Pass DartType to LiteralType Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ir/const_expression.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library dart2js.ir_builder; 5 library dart2js.ir_builder;
6 6
7 import 'ir_nodes.dart' as ir; 7 import 'ir_nodes.dart' as ir;
8 import '../elements/elements.dart'; 8 import '../elements/elements.dart';
9 import '../dart2jslib.dart'; 9 import '../dart2jslib.dart';
10 import '../dart_types.dart'; 10 import '../dart_types.dart';
(...skipping 1217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 assert(isOpen); 1228 assert(isOpen);
1229 if (node.isPropertyAccess) { 1229 if (node.isPropertyAccess) {
1230 return visitGetterSend(node); 1230 return visitGetterSend(node);
1231 } else { 1231 } else {
1232 return visitDynamicSend(node); 1232 return visitDynamicSend(node);
1233 } 1233 }
1234 } 1234 }
1235 1235
1236 ir.Primitive visitTypeReferenceSend(ast.Send node) { 1236 ir.Primitive visitTypeReferenceSend(ast.Send node) {
1237 assert(isOpen); 1237 assert(isOpen);
1238 Element element = elements[node];
1239 assert(element is TypeDeclarationElement || element.isTypeVariable);
1240
1241 // If the user is trying to invoke the type literal or variable, 1238 // If the user is trying to invoke the type literal or variable,
1242 // it must be treated as a function call. 1239 // it must be treated as a function call.
1243 if (node.argumentsNode != null) { 1240 if (node.argumentsNode != null) {
1244 return visitDynamicSend(node); 1241 return visitDynamicSend(node);
1245 } 1242 }
1246 1243
1247 if (element is TypeDeclarationElement) { 1244 DartType type = elements.getTypeLiteralType(node);
1248 return translateConstant(node); 1245 if (type is TypeVariableType) {
1249 } else { 1246 ir.Primitive prim = new ir.ReifyTypeVar(type.element);
1250 ir.Primitive prim = new ir.ReifyTypeVar(element);
1251 add(new ir.LetPrim(prim)); 1247 add(new ir.LetPrim(prim));
1252 return prim; 1248 return prim;
1249 } else {
1250 return translateConstant(node);
1253 } 1251 }
1254 } 1252 }
1255 1253
1256 ir.Primitive visitSendSet(ast.SendSet node) { 1254 ir.Primitive visitSendSet(ast.SendSet node) {
1257 assert(isOpen); 1255 assert(isOpen);
1258 Element element = elements[node]; 1256 Element element = elements[node];
1259 ast.Operator op = node.assignmentOperator; 1257 ast.Operator op = node.assignmentOperator;
1260 // For complex operators, this is the result of getting (before assigning) 1258 // For complex operators, this is the result of getting (before assigning)
1261 ir.Primitive originalValue; 1259 ir.Primitive originalValue;
1262 // For []+= style operators, this saves the index. 1260 // For []+= style operators, this saves the index.
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 } 1519 }
1522 if (Elements.isLocal(element) || 1520 if (Elements.isLocal(element) ||
1523 Elements.isStaticOrTopLevelField(element)) { 1521 Elements.isStaticOrTopLevelField(element)) {
1524 // If the constant is small, inline it instead of using the declared const 1522 // If the constant is small, inline it instead of using the declared const
1525 Constant value = constantCompiler.getConstantForVariable(element); 1523 Constant value = constantCompiler.getConstantForVariable(element);
1526 if (isSmallConstant(value)) 1524 if (isSmallConstant(value))
1527 return new PrimitiveConstExp(value); 1525 return new PrimitiveConstExp(value);
1528 else 1526 else
1529 return new VariableConstExp(element); 1527 return new VariableConstExp(element);
1530 } 1528 }
1531 if (Elements.isClass(element) || Elements.isTypedef(element)) { 1529 DartType type = elements.getTypeLiteralType(node);
1532 return new TypeConstExp(element); 1530 if (type != null) {
1531 return new TypeConstExp(type);
1533 } 1532 }
1534 throw "Unexpected constant Send: $node"; 1533 throw "Unexpected constant Send: $node";
1535 } 1534 }
1536 1535
1537 ConstExp visitParenthesizedExpression(ast.ParenthesizedExpression node) { 1536 ConstExp visitParenthesizedExpression(ast.ParenthesizedExpression node) {
1538 return visit(node.expression); 1537 return visit(node.expression);
1539 } 1538 }
1540 1539
1541 ConstExp visitLiteralList(ast.LiteralList node) { 1540 ConstExp visitLiteralList(ast.LiteralList node) {
1542 List<ConstExp> values = node.elements.nodes.mapToList(visit); 1541 List<ConstExp> values = node.elements.nodes.mapToList(visit);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 ConstExp visitConditional(ast.Conditional node) { 1581 ConstExp visitConditional(ast.Conditional node) {
1583 BoolConstant condition = computeConstant(node.condition); 1582 BoolConstant condition = computeConstant(node.condition);
1584 return visit(condition.isTrue ? node.thenExpression : node.elseExpression); 1583 return visit(condition.isTrue ? node.thenExpression : node.elseExpression);
1585 } 1584 }
1586 1585
1587 ConstExp visitNode(ast.Node node) { 1586 ConstExp visitNode(ast.Node node) {
1588 throw "Unexpected constant: $node"; 1587 throw "Unexpected constant: $node";
1589 } 1588 }
1590 1589
1591 } 1590 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ir/const_expression.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698