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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/js_emitter/code_emitter_task.dart

Issue 26472002: Add TypeVariable object on runtime to support reflection on type variables. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments. Created 7 years, 2 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 /** 7 /**
8 * Generates the code for all used classes in the program. Static fields (even 8 * Generates the code for all used classes in the program. Static fields (even
9 * in classes) are ignored, since they can be treated as non-class elements. 9 * in classes) are ignored, since they can be treated as non-class elements.
10 * 10 *
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 /// type, and return types. 42 /// type, and return types.
43 final List<String> globalMetadata = []; 43 final List<String> globalMetadata = [];
44 44
45 /// A map used to canonicalize the entries of globalMetadata. 45 /// A map used to canonicalize the entries of globalMetadata.
46 final Map<String, int> globalMetadataMap = <String, int>{}; 46 final Map<String, int> globalMetadataMap = <String, int>{};
47 47
48 // TODO(ngeoffray): remove this field. 48 // TODO(ngeoffray): remove this field.
49 Set<ClassElement> instantiatedClasses; 49 Set<ClassElement> instantiatedClasses;
50 50
51 JavaScriptBackend get backend => compiler.backend; 51 JavaScriptBackend get backend => compiler.backend;
52 TypeVariableHandler get typeVariableHandler => backend.typeVariableHandler;
52 53
53 String get _ => space; 54 String get _ => space;
54 String get space => compiler.enableMinification ? "" : " "; 55 String get space => compiler.enableMinification ? "" : " ";
55 String get n => compiler.enableMinification ? "" : "\n"; 56 String get n => compiler.enableMinification ? "" : "\n";
56 String get N => compiler.enableMinification ? "\n" : ";\n"; 57 String get N => compiler.enableMinification ? "\n" : ";\n";
57 58
58 /** 59 /**
59 * List of expressions and statements that will be included in the 60 * List of expressions and statements that will be included in the
60 * precompiled function. 61 * precompiled function.
61 * 62 *
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 if (value == null) { 1615 if (value == null) {
1615 compiler.reportInternalError( 1616 compiler.reportInternalError(
1616 annotation, 'Internal error: value is null'); 1617 annotation, 'Internal error: value is null');
1617 return -1; 1618 return -1;
1618 } 1619 }
1619 return addGlobalMetadata( 1620 return addGlobalMetadata(
1620 jsAst.prettyPrint(constantReference(value), compiler).getText()); 1621 jsAst.prettyPrint(constantReference(value), compiler).getText());
1621 } 1622 }
1622 1623
1623 int reifyType(DartType type) { 1624 int reifyType(DartType type) {
1624 // TODO(ahe): Handle type variables correctly instead of using "#". 1625 jsAst.Expression representation =
1625 String representation = backend.rti.getTypeRepresentation(type, (_) {}); 1626 backend.rti.getTypeRepresentation(type, (variable) {
1626 return addGlobalMetadata(representation.replaceAll('#', 'null')); 1627 return js.toExpression(typeVariableHandler.reifyTypeVariable(variable) );
ahe 2013/10/15 14:56:31 Long line.
zarah 2013/10/16 07:00:47 Done.
1628 });
1629
1630 return addGlobalMetadata(
1631 jsAst.prettyPrint(representation, compiler).getText());
1627 } 1632 }
1628 1633
1629 int reifyName(SourceString name) { 1634 int reifyName(SourceString name) {
1630 return addGlobalMetadata('"${name.slowToString()}"'); 1635 return addGlobalMetadata('"${name.slowToString()}"');
1631 } 1636 }
1632 1637
1633 int addGlobalMetadata(String string) { 1638 int addGlobalMetadata(String string) {
1634 return globalMetadataMap.putIfAbsent(string, () { 1639 return globalMetadataMap.putIfAbsent(string, () {
1635 globalMetadata.add(string); 1640 globalMetadata.add(string);
1636 return globalMetadata.length - 1; 1641 return globalMetadata.length - 1;
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 return compiler.deferredLoadTask.isDeferred(element); 2151 return compiler.deferredLoadTask.isDeferred(element);
2147 } 2152 }
2148 2153
2149 bool get areAnyElementsDeferred { 2154 bool get areAnyElementsDeferred {
2150 return compiler.deferredLoadTask.areAnyElementsDeferred; 2155 return compiler.deferredLoadTask.areAnyElementsDeferred;
2151 } 2156 }
2152 } 2157 }
2153 2158
2154 // TODO(ahe): Move code for interceptors to own file. 2159 // TODO(ahe): Move code for interceptors to own file.
2155 // TODO(ahe): Move code for reifying metadata/types to own file. 2160 // TODO(ahe): Move code for reifying metadata/types to own file.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698