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

Side by Side Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 1019923005: Dart2js deferred loading. Follow types of functions when calculating dependencies. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Responding to review + Adding a computeSignature call. Created 5 years, 8 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) 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 elements.modelx; 5 library elements.modelx;
6 6
7 import 'elements.dart'; 7 import 'elements.dart';
8 import '../constants/expressions.dart'; 8 import '../constants/expressions.dart';
9 import '../helpers/helpers.dart'; // Included for debug helpers. 9 import '../helpers/helpers.dart'; // Included for debug helpers.
10 import '../tree/tree.dart'; 10 import '../tree/tree.dart';
(...skipping 2036 matching lines...) Expand 10 before | Expand all | Expand 10 after
2047 * A constructor that is not defined in the source code but rather implied by 2047 * A constructor that is not defined in the source code but rather implied by
2048 * the language semantics. 2048 * the language semantics.
2049 * 2049 *
2050 * This class is used to represent default constructors and forwarding 2050 * This class is used to represent default constructors and forwarding
2051 * constructors for mixin applications. 2051 * constructors for mixin applications.
2052 */ 2052 */
2053 class SynthesizedConstructorElementX extends ConstructorElementX { 2053 class SynthesizedConstructorElementX extends ConstructorElementX {
2054 final ConstructorElement definingConstructor; 2054 final ConstructorElement definingConstructor;
2055 final bool isDefaultConstructor; 2055 final bool isDefaultConstructor;
2056 2056
2057 SynthesizedConstructorElementX(String name, 2057 SynthesizedConstructorElementX.notForDefault(String name,
2058 this.definingConstructor, 2058 this.definingConstructor,
2059 Element enclosing, 2059 Element enclosing)
2060 this.isDefaultConstructor) 2060 : isDefaultConstructor = false,
2061 : super(name, 2061 super(name,
2062 ElementKind.GENERATIVE_CONSTRUCTOR, 2062 ElementKind.GENERATIVE_CONSTRUCTOR,
2063 Modifiers.EMPTY, 2063 Modifiers.EMPTY,
2064 enclosing); 2064 enclosing) ;
2065 2065
2066 SynthesizedConstructorElementX.forDefault(superMember, Element enclosing) 2066 SynthesizedConstructorElementX.forDefault(this.definingConstructor,
2067 : this('', superMember, enclosing, true); 2067 Element enclosing)
2068 : isDefaultConstructor = true,
2069 super('',
2070 ElementKind.GENERATIVE_CONSTRUCTOR,
2071 Modifiers.EMPTY,
2072 enclosing) {
2073 typeCache = new FunctionType.synthesized(enclosingClass.thisType);
2074 }
2068 2075
2069 FunctionExpression parseNode(DiagnosticListener listener) => null; 2076 FunctionExpression parseNode(DiagnosticListener listener) => null;
2070 2077
2071 bool get hasNode => false; 2078 bool get hasNode => false;
2072 2079
2073 FunctionExpression get node => null; 2080 FunctionExpression get node => null;
2074 2081
2075 Token get position => enclosingElement.position; 2082 Token get position => enclosingElement.position;
2076 2083
2077 bool get isSynthesized => true; 2084 bool get isSynthesized => true;
2078 2085
2086 DartType get type {
2087 if (isDefaultConstructor) {
2088 return super.type;
2089 } else {
2090 // TODO(johnniwinther): Ensure that the function type substitutes type
2091 // variables correctly.
2092 return definingConstructor.type;
2093 }
2094 }
2095
2079 FunctionSignature computeSignature(compiler) { 2096 FunctionSignature computeSignature(compiler) {
2080 if (functionSignatureCache != null) return functionSignatureCache; 2097 if (functionSignatureCache != null) return functionSignatureCache;
2081 if (isDefaultConstructor) { 2098 if (isDefaultConstructor) {
2082 return functionSignatureCache = new FunctionSignatureX( 2099 return functionSignatureCache = new FunctionSignatureX(
2083 type: new FunctionType(this, enclosingClass.thisType)); 2100 type: type);
2084 } 2101 }
2085 if (definingConstructor.isErroneous) { 2102 if (definingConstructor.isErroneous) {
2086 return functionSignatureCache = 2103 return functionSignatureCache =
2087 compiler.objectClass.localLookup('').computeSignature(compiler); 2104 compiler.objectClass.localLookup('').computeSignature(compiler);
2088 } 2105 }
2089 // TODO(johnniwinther): Ensure that the function signature (and with it the 2106 // TODO(johnniwinther): Ensure that the function signature (and with it the
2090 // function type) substitutes type variables correctly. 2107 // function type) substitutes type variables correctly.
2091 return functionSignatureCache = 2108 return functionSignatureCache =
2092 definingConstructor.computeSignature(compiler); 2109 definingConstructor.computeSignature(compiler);
2093 } 2110 }
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after
3070 AstElement get definingElement; 3087 AstElement get definingElement;
3071 3088
3072 bool get hasResolvedAst => definingElement.hasTreeElements; 3089 bool get hasResolvedAst => definingElement.hasTreeElements;
3073 3090
3074 ResolvedAst get resolvedAst { 3091 ResolvedAst get resolvedAst {
3075 return new ResolvedAst(declaration, 3092 return new ResolvedAst(declaration,
3076 definingElement.node, definingElement.treeElements); 3093 definingElement.node, definingElement.treeElements);
3077 } 3094 }
3078 3095
3079 } 3096 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698