OLD | NEW |
---|---|
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 1955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1966 : supertypeLoadState = initialState, | 1966 : supertypeLoadState = initialState, |
1967 resolutionState = initialState, | 1967 resolutionState = initialState, |
1968 super(name, ElementKind.CLASS, enclosing); | 1968 super(name, ElementKind.CLASS, enclosing); |
1969 | 1969 |
1970 int get hashCode => id; | 1970 int get hashCode => id; |
1971 | 1971 |
1972 bool get hasBackendMembers => !backendMembers.isEmpty; | 1972 bool get hasBackendMembers => !backendMembers.isEmpty; |
1973 | 1973 |
1974 bool get isUnnamedMixinApplication => false; | 1974 bool get isUnnamedMixinApplication => false; |
1975 | 1975 |
1976 @override | |
1977 bool get isEnumClass => false; | |
1978 | |
1976 InterfaceType computeType(Compiler compiler) { | 1979 InterfaceType computeType(Compiler compiler) { |
1977 if (thisTypeCache == null) { | 1980 if (thisTypeCache == null) { |
1978 computeThisAndRawType(compiler, computeTypeParameters(compiler)); | 1981 computeThisAndRawType(compiler, computeTypeParameters(compiler)); |
1979 } | 1982 } |
1980 return thisTypeCache; | 1983 return thisTypeCache; |
1981 } | 1984 } |
1982 | 1985 |
1983 void computeThisAndRawType(Compiler compiler, List<DartType> typeVariables) { | 1986 void computeThisAndRawType(Compiler compiler, List<DartType> typeVariables) { |
1984 if (thisTypeCache == null) { | 1987 if (thisTypeCache == null) { |
1985 if (origin == null) { | 1988 if (origin == null) { |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2348 Link<Element> get localMembers { | 2351 Link<Element> get localMembers { |
2349 if (localMembersCache == null) { | 2352 if (localMembersCache == null) { |
2350 localMembersCache = localMembersReversed.reverse(); | 2353 localMembersCache = localMembersReversed.reverse(); |
2351 } | 2354 } |
2352 return localMembersCache; | 2355 return localMembersCache; |
2353 } | 2356 } |
2354 | 2357 |
2355 ClassElementX(String name, Element enclosing, int id, int initialState) | 2358 ClassElementX(String name, Element enclosing, int id, int initialState) |
2356 : super(name, enclosing, id, initialState); | 2359 : super(name, enclosing, id, initialState); |
2357 | 2360 |
2358 ClassNode parseNode(Compiler compiler); | |
2359 | |
2360 bool get isMixinApplication => false; | 2361 bool get isMixinApplication => false; |
2361 bool get hasLocalScopeMembers => !localScope.isEmpty; | 2362 bool get hasLocalScopeMembers => !localScope.isEmpty; |
2362 | 2363 |
2363 void addMember(Element element, DiagnosticListener listener) { | 2364 void addMember(Element element, DiagnosticListener listener) { |
2364 localMembersCache = null; | 2365 localMembersCache = null; |
2365 localMembersReversed = localMembersReversed.prepend(element); | 2366 localMembersReversed = localMembersReversed.prepend(element); |
2366 addToScope(element, listener); | 2367 addToScope(element, listener); |
2367 } | 2368 } |
2368 | 2369 |
2369 void addToScope(Element element, DiagnosticListener listener) { | 2370 void addToScope(Element element, DiagnosticListener listener) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2409 if (origin != null) { | 2410 if (origin != null) { |
2410 return 'patch ${super.toString()}'; | 2411 return 'patch ${super.toString()}'; |
2411 } else if (patch != null) { | 2412 } else if (patch != null) { |
2412 return 'origin ${super.toString()}'; | 2413 return 'origin ${super.toString()}'; |
2413 } else { | 2414 } else { |
2414 return super.toString(); | 2415 return super.toString(); |
2415 } | 2416 } |
2416 } | 2417 } |
2417 } | 2418 } |
2418 | 2419 |
2420 class EnumClassElementX extends ClassElementX { | |
2421 final Enum node; | |
2422 | |
2423 EnumClassElementX(String name, Element enclosing, int id, this.node) | |
2424 : super(name, enclosing, id, STATE_NOT_STARTED); | |
2425 | |
2426 @override | |
2427 bool get hasNode => true; | |
2428 | |
2429 @override | |
2430 Token get position => node.name.token; | |
2431 | |
2432 @override | |
2433 bool get isEnumClass => true; | |
2434 | |
2435 @override | |
2436 Node parseNode(Compiler compiler) => node; | |
2437 | |
2438 @override | |
2439 accept(ElementVisitor visitor) => visitor.visitClassElement(this); | |
floitsch
2014/11/10 16:08:32
Why don't we need visitor.visitEnumClass ?
Johnni Winther
2014/11/11 08:23:36
Because there is no EnumClassElement interface.
| |
2440 | |
2441 List<DartType> computeTypeParameters(Compiler compiler) => const <DartType>[]; | |
2442 } | |
2443 | |
2444 class EnumConstructorElementX extends ConstructorElementX { | |
2445 final FunctionExpression node; | |
2446 | |
2447 EnumConstructorElementX(EnumClassElementX enumClass, | |
2448 Modifiers modifiers, | |
2449 this.node) | |
2450 : super('', | |
floitsch
2014/11/10 16:08:32
'', // Name.
Johnni Winther
2014/11/11 08:23:36
Done.
| |
2451 ElementKind.GENERATIVE_CONSTRUCTOR, | |
2452 modifiers, | |
2453 enumClass); | |
2454 | |
2455 @override | |
2456 bool get hasNode => true; | |
2457 | |
2458 @override | |
2459 FunctionExpression parseNode(Compiler compiler) => node; | |
2460 } | |
2461 | |
2462 class EnumMethodElementX extends FunctionElementX { | |
2463 final FunctionExpression node; | |
2464 | |
2465 EnumMethodElementX(String name, | |
2466 EnumClassElementX enumClass, | |
2467 Modifiers modifiers, | |
2468 this.node) | |
2469 : super(name, | |
2470 ElementKind.FUNCTION, | |
2471 modifiers, | |
2472 enumClass, | |
2473 false); | |
2474 | |
2475 @override | |
2476 bool get hasNode => true; | |
2477 | |
2478 @override | |
2479 FunctionExpression parseNode(Compiler compiler) => node; | |
2480 } | |
2481 | |
2482 class EnumFormalElementX extends InitializingFormalElementX { | |
2483 EnumFormalElementX(ConstructorElement constructor, | |
2484 VariableDefinitions variables, | |
2485 Identifier identifier, | |
2486 EnumFieldElementX fieldElement) | |
2487 : super(constructor, variables, identifier, null, fieldElement) { | |
2488 typeCache = fieldElement.type; | |
2489 } | |
2490 } | |
2491 | |
2492 class EnumFieldElementX extends FieldElementX { | |
2493 | |
2494 EnumFieldElementX(Identifier name, | |
2495 EnumClassElementX enumClass, | |
2496 VariableList variableList, | |
2497 Node definition, | |
2498 [Expression initializer]) | |
2499 : super(name, enumClass, variableList) { | |
2500 definitionsCache = new VariableDefinitions(null, | |
2501 variableList.modifiers, new NodeList.singleton(definition)); | |
2502 initializerCache = initializer; | |
2503 } | |
2504 } | |
2505 | |
2419 class MixinApplicationElementX extends BaseClassElementX | 2506 class MixinApplicationElementX extends BaseClassElementX |
2420 implements MixinApplicationElement { | 2507 implements MixinApplicationElement { |
2421 final Node node; | 2508 final Node node; |
2422 final Modifiers modifiers; | 2509 final Modifiers modifiers; |
2423 | 2510 |
2424 Link<FunctionElement> constructors = new Link<FunctionElement>(); | 2511 Link<FunctionElement> constructors = new Link<FunctionElement>(); |
2425 | 2512 |
2426 InterfaceType mixinType; | 2513 InterfaceType mixinType; |
2427 | 2514 |
2428 MixinApplicationElementX(String name, Element enclosing, int id, | 2515 MixinApplicationElementX(String name, Element enclosing, int id, |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2712 AstElement get definingElement; | 2799 AstElement get definingElement; |
2713 | 2800 |
2714 bool get hasResolvedAst => definingElement.hasTreeElements; | 2801 bool get hasResolvedAst => definingElement.hasTreeElements; |
2715 | 2802 |
2716 ResolvedAst get resolvedAst { | 2803 ResolvedAst get resolvedAst { |
2717 return new ResolvedAst(declaration, | 2804 return new ResolvedAst(declaration, |
2718 definingElement.node, definingElement.treeElements); | 2805 definingElement.node, definingElement.treeElements); |
2719 } | 2806 } |
2720 | 2807 |
2721 } | 2808 } |
OLD | NEW |