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

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

Issue 1391193002: Make computeSignature private to modelx. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « pkg/compiler/lib/src/closure.dart ('k') | pkg/compiler/lib/src/resolution/enum_creator.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 library elements.modelx; 5 library elements.modelx;
6 6
7 import '../common/resolution.dart' show 7 import '../common/resolution.dart' show
8 Resolution, 8 Resolution,
9 Parsing; 9 Parsing;
10 import '../compiler.dart' show 10 import '../compiler.dart' show
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 get immediateRedirectionTarget => unsupported(); 308 get immediateRedirectionTarget => unsupported();
309 get nestedClosures => unsupported(); 309 get nestedClosures => unsupported();
310 get memberContext => unsupported(); 310 get memberContext => unsupported();
311 get executableContext => unsupported(); 311 get executableContext => unsupported();
312 get isExternal => unsupported(); 312 get isExternal => unsupported();
313 get constantConstructor => null; 313 get constantConstructor => null;
314 314
315 bool get isRedirectingGenerative => unsupported(); 315 bool get isRedirectingGenerative => unsupported();
316 bool get isRedirectingFactory => unsupported(); 316 bool get isRedirectingFactory => unsupported();
317 317
318 computeSignature(Resolution resolution) => unsupported();
319 computeType(Resolution resolution) => unsupported(); 318 computeType(Resolution resolution) => unsupported();
320 319
321 bool get hasFunctionSignature => false; 320 bool get hasFunctionSignature => false;
322 321
323 get effectiveTarget => this; 322 get effectiveTarget => this;
324 323
325 computeEffectiveTargetType(InterfaceType newType) => unsupported(); 324 computeEffectiveTargetType(InterfaceType newType) => unsupported();
326 325
327 get definingConstructor => null; 326 get definingConstructor => null;
328 327
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 388 }
390 389
391 get effectiveTargetType { 390 get effectiveTargetType {
392 throw new UnsupportedError("effectiveTargetType"); 391 throw new UnsupportedError("effectiveTargetType");
393 } 392 }
394 393
395 set effectiveTargetType(_) { 394 set effectiveTargetType(_) {
396 throw new UnsupportedError("effectiveTargetType="); 395 throw new UnsupportedError("effectiveTargetType=");
397 } 396 }
398 397
398 void _computeSignature(Resolution resolution) {
399 throw new UnsupportedError("_computeSignature");
400 }
401
399 get typeCache { 402 get typeCache {
400 throw new UnsupportedError("typeCache"); 403 throw new UnsupportedError("typeCache");
401 } 404 }
402 405
403 set typeCache(_) { 406 set typeCache(_) {
404 throw new UnsupportedError("typeCache="); 407 throw new UnsupportedError("typeCache=");
405 } 408 }
406 409
407 get immediateRedirectionTarget { 410 get immediateRedirectionTarget {
408 throw new UnsupportedError("immediateRedirectionTarget"); 411 throw new UnsupportedError("immediateRedirectionTarget");
409 } 412 }
410 413
411 set immediateRedirectionTarget(_) { 414 set immediateRedirectionTarget(_) {
412 throw new UnsupportedError("immediateRedirectionTarget="); 415 throw new UnsupportedError("immediateRedirectionTarget=");
413 } 416 }
414 417
415 get functionSignatureCache { 418 get functionSignatureCache {
416 throw new UnsupportedError("functionSignatureCache"); 419 throw new UnsupportedError("functionSignatureCache");
417 } 420 }
418 421
419 set functionSignatureCache(_) { 422 set functionSignatureCache(_) {
420 throw new UnsupportedError("functionSignatureCache="); 423 throw new UnsupportedError("functionSignatureCache=");
421 } 424 }
422 425
426 set functionSignature(_) {
427 throw new UnsupportedError("functionSignatureCache=");
428 }
429
423 get nestedClosures { 430 get nestedClosures {
424 throw new UnsupportedError("nestedClosures"); 431 throw new UnsupportedError("nestedClosures");
425 } 432 }
426 433
427 set nestedClosures(_) { 434 set nestedClosures(_) {
428 throw new UnsupportedError("nestedClosures="); 435 throw new UnsupportedError("nestedClosures=");
429 } 436 }
430 437
431 set redirectionDeferredPrefix(_) { 438 set redirectionDeferredPrefix(_) {
432 throw new UnsupportedError("redirectionDeferredPrefix="); 439 throw new UnsupportedError("redirectionDeferredPrefix=");
(...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 bool get isExternal => modifiers.isExternal; 1975 bool get isExternal => modifiers.isExternal;
1969 1976
1970 bool get isInstanceMember { 1977 bool get isInstanceMember {
1971 return isClassMember 1978 return isClassMember
1972 && !isConstructor 1979 && !isConstructor
1973 && !isStatic; 1980 && !isStatic;
1974 } 1981 }
1975 1982
1976 bool get hasFunctionSignature => functionSignatureCache != null; 1983 bool get hasFunctionSignature => functionSignatureCache != null;
1977 1984
1978 FunctionSignature computeSignature(Resolution resolution) { 1985 void _computeSignature(Resolution resolution) {
1979 if (functionSignatureCache != null) return functionSignatureCache; 1986 if (hasFunctionSignature) return;
1980 functionSignatureCache = resolution.resolveSignature(this); 1987 functionSignature = resolution.resolveSignature(this);
1988 }
1989
1990 FunctionSignature get functionSignature {
1991 assert(invariant(this, hasFunctionSignature,
1992 message: "Function signature has not been computed for $this."));
1981 return functionSignatureCache; 1993 return functionSignatureCache;
1982 } 1994 }
1983 1995
1984 FunctionSignature get functionSignature { 1996 void set functionSignature(FunctionSignature value) {
sigurdm 2015/10/07 11:53:07 The setter could be pushed down the element class-
Johnni Winther 2015/10/07 12:15:03 This is currently the lowest common point.
1985 assert(invariant(this, functionSignatureCache != null, 1997 // TODO(johnniwinther): Strengthen the invariant to `!hasFunctionSignature`
1986 message: "Function signature has not been computed for $this.")); 1998 // when checked mode checks are not enqueued eagerly.
1987 return functionSignatureCache; 1999 assert(invariant(this, !hasFunctionSignature || type == value.type,
2000 message: "Function signature has already been computed for $this."));
2001 functionSignatureCache = value;
sigurdm 2015/10/07 11:53:07 functionSignaturePrivate could be private
Johnni Winther 2015/10/07 12:15:03 Done.
2002 typeCache = functionSignatureCache.type;
1988 } 2003 }
1989 2004
1990 List<ParameterElement> get parameters { 2005 List<ParameterElement> get parameters {
1991 // TODO(johnniwinther): Store the list directly, possibly by using List 2006 // TODO(johnniwinther): Store the list directly, possibly by using List
1992 // instead of Link in FunctionSignature. 2007 // instead of Link in FunctionSignature.
1993 List<ParameterElement> list = <ParameterElement>[]; 2008 List<ParameterElement> list = <ParameterElement>[];
1994 functionSignature.forEachParameter((e) => list.add(e)); 2009 functionSignature.forEachParameter((e) => list.add(e));
1995 return list; 2010 return list;
1996 } 2011 }
1997 2012
1998 FunctionType computeType(Resolution resolution) { 2013 FunctionType computeType(Resolution resolution) {
1999 if (typeCache != null) return typeCache; 2014 if (typeCache != null) return typeCache;
2000 typeCache = computeSignature(resolution).type; 2015 _computeSignature(resolution);
2016 assert(invariant(this, typeCache != null,
2017 message: "Type cache expected to be set on $this."));
2001 return typeCache; 2018 return typeCache;
2002 } 2019 }
2003 2020
2004 FunctionType get type { 2021 FunctionType get type {
2005 assert(invariant(this, typeCache != null, 2022 assert(invariant(this, typeCache != null,
2006 message: "Type has not been computed for $this.")); 2023 message: "Type has not been computed for $this."));
2007 return typeCache; 2024 return typeCache;
2008 } 2025 }
2009 2026
2010 FunctionElement asFunctionElement() => this; 2027 FunctionElement asFunctionElement() => this;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 2243
2227 class DeferredLoaderGetterElementX extends GetterElementX 2244 class DeferredLoaderGetterElementX extends GetterElementX
2228 implements GetterElement { 2245 implements GetterElement {
2229 final PrefixElement prefix; 2246 final PrefixElement prefix;
2230 2247
2231 DeferredLoaderGetterElementX(PrefixElement prefix) 2248 DeferredLoaderGetterElementX(PrefixElement prefix)
2232 : this.prefix = prefix, 2249 : this.prefix = prefix,
2233 super("loadLibrary", 2250 super("loadLibrary",
2234 Modifiers.EMPTY, 2251 Modifiers.EMPTY,
2235 prefix, 2252 prefix,
2236 false); 2253 false) {
2237 2254 functionSignature = new FunctionSignatureX(type: new FunctionType(this));
2238 FunctionSignature computeSignature(Resolution resolution) {
2239 if (functionSignatureCache != null) return functionSignature;
2240 functionSignatureCache =
2241 new FunctionSignatureX(type: new FunctionType(this));
2242 return functionSignatureCache;
2243 } 2255 }
2244 2256
2245 bool get isClassMember => false; 2257 bool get isClassMember => false;
2246 2258
2247 bool get isSynthesized => true; 2259 bool get isSynthesized => true;
2248 2260
2249 bool get isDeferredLoaderGetter => true; 2261 bool get isDeferredLoaderGetter => true;
2250 2262
2251 bool get isTopLevel => true; 2263 bool get isTopLevel => true;
2252 // By having position null, the enclosing elements location is printed in 2264 // By having position null, the enclosing elements location is printed in
(...skipping 13 matching lines...) Expand all
2266 class ConstructorBodyElementX extends BaseFunctionElementX 2278 class ConstructorBodyElementX extends BaseFunctionElementX
2267 implements ConstructorBodyElement { 2279 implements ConstructorBodyElement {
2268 ConstructorElementX constructor; 2280 ConstructorElementX constructor;
2269 2281
2270 ConstructorBodyElementX(ConstructorElementX constructor) 2282 ConstructorBodyElementX(ConstructorElementX constructor)
2271 : this.constructor = constructor, 2283 : this.constructor = constructor,
2272 super(constructor.name, 2284 super(constructor.name,
2273 ElementKind.GENERATIVE_CONSTRUCTOR_BODY, 2285 ElementKind.GENERATIVE_CONSTRUCTOR_BODY,
2274 Modifiers.EMPTY, 2286 Modifiers.EMPTY,
2275 constructor.enclosingElement) { 2287 constructor.enclosingElement) {
2276 functionSignatureCache = constructor.functionSignature; 2288 functionSignature = constructor.functionSignature;
2277 } 2289 }
2278 2290
2279 bool get hasNode => constructor.hasNode; 2291 bool get hasNode => constructor.hasNode;
2280 2292
2281 FunctionExpression get node => constructor.node; 2293 FunctionExpression get node => constructor.node;
2282 2294
2283 List<MetadataAnnotation> get metadata => constructor.metadata; 2295 List<MetadataAnnotation> get metadata => constructor.metadata;
2284 2296
2285 bool get isInstanceMember => true; 2297 bool get isInstanceMember => true;
2286 2298
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2323 Modifiers.EMPTY, 2335 Modifiers.EMPTY,
2324 enclosing) ; 2336 enclosing) ;
2325 2337
2326 SynthesizedConstructorElementX.forDefault(this.definingConstructor, 2338 SynthesizedConstructorElementX.forDefault(this.definingConstructor,
2327 Element enclosing) 2339 Element enclosing)
2328 : isDefaultConstructor = true, 2340 : isDefaultConstructor = true,
2329 super('', 2341 super('',
2330 ElementKind.GENERATIVE_CONSTRUCTOR, 2342 ElementKind.GENERATIVE_CONSTRUCTOR,
2331 Modifiers.EMPTY, 2343 Modifiers.EMPTY,
2332 enclosing) { 2344 enclosing) {
2333 typeCache = new FunctionType.synthesized(enclosingClass.thisType); 2345 functionSignature = new FunctionSignatureX(
2334 functionSignatureCache = new FunctionSignatureX(type: type); 2346 type: new FunctionType.synthesized(enclosingClass.thisType));
2335 } 2347 }
2336 2348
2337 FunctionExpression parseNode(Parsing parsing) => null; 2349 FunctionExpression parseNode(Parsing parsing) => null;
2338 2350
2339 bool get hasNode => false; 2351 bool get hasNode => false;
2340 2352
2341 FunctionExpression get node => null; 2353 FunctionExpression get node => null;
2342 2354
2343 Token get position => enclosingElement.position; 2355 Token get position => enclosingElement.position;
2344 2356
2345 bool get isSynthesized => true; 2357 bool get isSynthesized => true;
2346 2358
2347 DartType get type { 2359 DartType get type {
2348 if (isDefaultConstructor) { 2360 if (isDefaultConstructor) {
2349 return super.type; 2361 return super.type;
2350 } else { 2362 } else {
2351 // TODO(johnniwinther): Ensure that the function type substitutes type 2363 // TODO(johnniwinther): Ensure that the function type substitutes type
2352 // variables correctly. 2364 // variables correctly.
2353 return definingConstructor.type; 2365 return definingConstructor.type;
2354 } 2366 }
2355 } 2367 }
2356 2368
2357 FunctionSignature computeSignature(Resolution resolution) { 2369 void _computeSignature(Resolution resolution) {
2358 if (functionSignatureCache != null) return functionSignatureCache; 2370 if (hasFunctionSignature) return;
2359 if (definingConstructor.isErroneous) { 2371 if (definingConstructor.isErroneous) {
2360 typeCache = new FunctionType.synthesized(enclosingClass.thisType); 2372 functionSignature = new FunctionSignatureX(
2361 return functionSignatureCache = new FunctionSignatureX(type: type); 2373 type: new FunctionType.synthesized(enclosingClass.thisType));
2362 } 2374 }
2363 // TODO(johnniwinther): Ensure that the function signature (and with it the 2375 // TODO(johnniwinther): Ensure that the function signature (and with it the
2364 // function type) substitutes type variables correctly. 2376 // function type) substitutes type variables correctly.
2365 definingConstructor.computeType(resolution); 2377 definingConstructor.computeType(resolution);
2366 functionSignatureCache = definingConstructor.functionSignature; 2378 functionSignature = definingConstructor.functionSignature;
2367 typeCache = definingConstructor.type;
2368 return functionSignatureCache;
2369 } 2379 }
2370 2380
2371 accept(ElementVisitor visitor, arg) { 2381 accept(ElementVisitor visitor, arg) {
2372 return visitor.visitConstructorElement(this, arg); 2382 return visitor.visitConstructorElement(this, arg);
2373 } 2383 }
2374 } 2384 }
2375 2385
2376 abstract class TypeDeclarationElementX<T extends GenericType> 2386 abstract class TypeDeclarationElementX<T extends GenericType>
2377 implements TypeDeclarationElement { 2387 implements TypeDeclarationElement {
2378 /** 2388 /**
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
3106 AstElement get definingElement; 3116 AstElement get definingElement;
3107 3117
3108 bool get hasResolvedAst => definingElement.hasTreeElements; 3118 bool get hasResolvedAst => definingElement.hasTreeElements;
3109 3119
3110 ResolvedAst get resolvedAst { 3120 ResolvedAst get resolvedAst {
3111 return new ResolvedAst(declaration, 3121 return new ResolvedAst(declaration,
3112 definingElement.node, definingElement.treeElements); 3122 definingElement.node, definingElement.treeElements);
3113 } 3123 }
3114 3124
3115 } 3125 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/closure.dart ('k') | pkg/compiler/lib/src/resolution/enum_creator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698