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

Side by Side Diff: pkg/compiler/lib/src/cps_ir/cps_ir_builder_visitor.dart

Issue 968843003: Implement type argument access and reification of runtime types. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Unbreak long line. Created 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_nodes.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) 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 part of dart2js.ir_builder; 5 part of dart2js.ir_builder;
6 6
7 /** 7 /**
8 * This task iterates through all resolved elements and builds [ir.Node]s. The 8 * This task iterates through all resolved elements and builds [ir.Node]s. The
9 * nodes are stored in the [nodes] map and accessible through [hasIr] and 9 * nodes are stored in the [nodes] map and accessible through [hasIr] and
10 * [getIr]. 10 * [getIr].
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 assert(irBuilder.isOpen); 850 assert(irBuilder.isOpen);
851 // If the user is trying to invoke the type literal or variable, 851 // If the user is trying to invoke the type literal or variable,
852 // it must be treated as a function call. 852 // it must be treated as a function call.
853 if (node.argumentsNode != null) { 853 if (node.argumentsNode != null) {
854 // TODO(sigurdm): Handle this to match proposed semantics of issue #19725. 854 // TODO(sigurdm): Handle this to match proposed semantics of issue #19725.
855 return giveup(node, 'Type literal invoked as function'); 855 return giveup(node, 'Type literal invoked as function');
856 } 856 }
857 857
858 DartType type = elements.getTypeLiteralType(node); 858 DartType type = elements.getTypeLiteralType(node);
859 if (type is TypeVariableType) { 859 if (type is TypeVariableType) {
860 ir.Primitive prim = new ir.ReifyTypeVar(type.element); 860 return buildReifyTypeVariable(irBuilder.buildThis(), type);
861 irBuilder.add(new ir.LetPrim(prim));
862 return prim;
863 } else { 861 } else {
864 return translateConstant(node); 862 return translateConstant(node);
865 } 863 }
866 } 864 }
867 865
866 ir.Primitive buildReifyTypeVariable(ir.Primitive target,
867 TypeVariableType variable);
868
868 ir.Primitive visitSendSet(ast.SendSet node) { 869 ir.Primitive visitSendSet(ast.SendSet node) {
869 assert(irBuilder.isOpen); 870 assert(irBuilder.isOpen);
870 Element element = elements[node]; 871 Element element = elements[node];
871 ast.Operator op = node.assignmentOperator; 872 ast.Operator op = node.assignmentOperator;
872 // For complex operators, this is the result of getting (before assigning) 873 // For complex operators, this is the result of getting (before assigning)
873 ir.Primitive originalValue; 874 ir.Primitive originalValue;
874 // For []+= style operators, this saves the index. 875 // For []+= style operators, this saves the index.
875 ir.Primitive index; 876 ir.Primitive index;
876 ir.Primitive receiver; 877 ir.Primitive receiver;
877 // This is what gets assigned. 878 // This is what gets assigned.
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 FunctionElement target, 1272 FunctionElement target,
1272 List<ir.Primitive> arguments) { 1273 List<ir.Primitive> arguments) {
1273 return arguments; 1274 return arguments;
1274 } 1275 }
1275 1276
1276 List<ir.Primitive> normalizeDynamicArguments( 1277 List<ir.Primitive> normalizeDynamicArguments(
1277 Selector selector, 1278 Selector selector,
1278 List<ir.Primitive> arguments) { 1279 List<ir.Primitive> arguments) {
1279 return arguments; 1280 return arguments;
1280 } 1281 }
1282
1283 @override
1284 ir.Primitive buildReifyTypeVariable(ir.Primitive target,
1285 TypeVariableType variable) {
1286 assert(target is ir.This);
1287 ir.Primitive prim = new ir.ReifyTypeVar(variable.element);
1288 irBuilder.add(new ir.LetPrim(prim));
1289 return prim;
1290 }
1281 } 1291 }
1282 1292
1283 /// IR builder specific to the JavaScript backend, coupled to the [JsIrBuilder]. 1293 /// IR builder specific to the JavaScript backend, coupled to the [JsIrBuilder].
1284 class JsIrBuilderVisitor extends IrBuilderVisitor { 1294 class JsIrBuilderVisitor extends IrBuilderVisitor {
1285 /// Promote the type of [irBuilder] to [JsIrBuilder]. 1295 /// Promote the type of [irBuilder] to [JsIrBuilder].
1286 JsIrBuilder get irBuilder => super.irBuilder; 1296 JsIrBuilder get irBuilder => super.irBuilder;
1287 1297
1288 /// Result of closure conversion for the current body of code. 1298 /// Result of closure conversion for the current body of code.
1289 /// 1299 ///
1290 /// Will be initialized upon entering the body of a function. 1300 /// Will be initialized upon entering the body of a function.
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 for (int i=0; i < selector.positionalArgumentCount; i++) { 1806 for (int i=0; i < selector.positionalArgumentCount; i++) {
1797 result.add(arguments[i]); 1807 result.add(arguments[i]);
1798 } 1808 }
1799 for (String argName in selector.getOrderedNamedArguments()) { 1809 for (String argName in selector.getOrderedNamedArguments()) {
1800 int nameIndex = selector.namedArguments.indexOf(argName); 1810 int nameIndex = selector.namedArguments.indexOf(argName);
1801 int translatedIndex = selector.positionalArgumentCount + nameIndex; 1811 int translatedIndex = selector.positionalArgumentCount + nameIndex;
1802 result.add(arguments[translatedIndex]); 1812 result.add(arguments[translatedIndex]);
1803 } 1813 }
1804 return result; 1814 return result;
1805 } 1815 }
1816
1817 @override
1818 ir.Primitive buildReifyTypeVariable(ir.Primitive target,
1819 TypeVariableType variable) {
1820 ir.Primitive typeArgument = new ir.ReadTypeVariable(variable, target);
1821 irBuilder.add(new ir.LetPrim(typeArgument));
1822 ir.Primitive type = new ir.ReifyRuntimeType(typeArgument);
1823 irBuilder.add(new ir.LetPrim(type));
1824 return type;
1825 }
1806 } 1826 }
1807 1827
1808 /// Interface for generating [SourceInformation] for the CPS. 1828 /// Interface for generating [SourceInformation] for the CPS.
1809 class SourceInformationBuilder { 1829 class SourceInformationBuilder {
1810 const SourceInformationBuilder(); 1830 const SourceInformationBuilder();
1811 1831
1812 /// Create a [SourceInformationBuilder] for [element]. 1832 /// Create a [SourceInformationBuilder] for [element].
1813 SourceInformationBuilder forContext(AstElement element) => this; 1833 SourceInformationBuilder forContext(AstElement element) => this;
1814 1834
1815 /// Generate [SourceInformation] for the read access in [node]. 1835 /// Generate [SourceInformation] for the read access in [node].
(...skipping 22 matching lines...) Expand all
1838 SourceInformation buildCall(ast.Node node) { 1858 SourceInformation buildCall(ast.Node node) {
1839 return new PositionSourceInformation( 1859 return new PositionSourceInformation(
1840 new TokenSourceLocation(sourceFile, node.getBeginToken(), name)); 1860 new TokenSourceLocation(sourceFile, node.getBeginToken(), name));
1841 } 1861 }
1842 1862
1843 @override 1863 @override
1844 SourceInformationBuilder forContext(AstElement element) { 1864 SourceInformationBuilder forContext(AstElement element) {
1845 return new PositionSourceInformationBuilder(element); 1865 return new PositionSourceInformationBuilder(element);
1846 } 1866 }
1847 } 1867 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/cps_ir/cps_ir_nodes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698