OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.constants.constructors; | 5 library dart2js.constants.constructors; |
6 | 6 |
7 import '../elements/entities.dart' show FieldEntity; | 7 import '../elements/entities.dart' show FieldEntity; |
8 import '../elements/types.dart'; | 8 import '../elements/types.dart'; |
9 import '../universe/call_structure.dart' show CallStructure; | 9 import '../universe/call_structure.dart' show CallStructure; |
10 import '../util/util.dart'; | 10 import '../util/util.dart'; |
(...skipping 21 matching lines...) Expand all Loading... |
32 EvaluationEnvironment environment, | 32 EvaluationEnvironment environment, |
33 List<ConstantExpression> arguments, | 33 List<ConstantExpression> arguments, |
34 CallStructure callStructure); | 34 CallStructure callStructure); |
35 | 35 |
36 accept(ConstantConstructorVisitor visitor, arg); | 36 accept(ConstantConstructorVisitor visitor, arg); |
37 } | 37 } |
38 | 38 |
39 abstract class ConstantConstructorVisitor<R, A> { | 39 abstract class ConstantConstructorVisitor<R, A> { |
40 const ConstantConstructorVisitor(); | 40 const ConstantConstructorVisitor(); |
41 | 41 |
42 R visit(ConstantConstructor constantConstructor, A context) { | 42 R visit( |
| 43 covariant ConstantConstructor constantConstructor, covariant A context) { |
43 return constantConstructor.accept(this, context); | 44 return constantConstructor.accept(this, context); |
44 } | 45 } |
45 | 46 |
46 R visitGenerative(GenerativeConstantConstructor constructor, A arg); | 47 R visitGenerative( |
| 48 covariant GenerativeConstantConstructor constructor, covariant A arg); |
47 R visitRedirectingGenerative( | 49 R visitRedirectingGenerative( |
48 RedirectingGenerativeConstantConstructor constructor, A arg); | 50 covariant RedirectingGenerativeConstantConstructor constructor, |
| 51 covariant A arg); |
49 R visitRedirectingFactory( | 52 R visitRedirectingFactory( |
50 RedirectingFactoryConstantConstructor constructor, A arg); | 53 covariant RedirectingFactoryConstantConstructor constructor, |
| 54 covariant A arg); |
51 } | 55 } |
52 | 56 |
53 /// A generative constant constructor. | 57 /// A generative constant constructor. |
54 class GenerativeConstantConstructor implements ConstantConstructor { | 58 class GenerativeConstantConstructor implements ConstantConstructor { |
55 final InterfaceType type; | 59 final InterfaceType type; |
56 final Map<dynamic /*int|String*/, ConstantExpression> defaultValues; | 60 final Map<dynamic /*int|String*/, ConstantExpression> defaultValues; |
57 final Map<FieldEntity, ConstantExpression> fieldMap; | 61 final Map<FieldEntity, ConstantExpression> fieldMap; |
58 final ConstructedConstantExpression superConstructorInvocation; | 62 final ConstructedConstantExpression superConstructorInvocation; |
59 | 63 |
60 GenerativeConstantConstructor(this.type, this.defaultValues, this.fieldMap, | 64 GenerativeConstantConstructor(this.type, this.defaultValues, this.fieldMap, |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 } | 251 } |
248 | 252 |
249 String toString() { | 253 String toString() { |
250 StringBuffer sb = new StringBuffer(); | 254 StringBuffer sb = new StringBuffer(); |
251 sb.write("{"); | 255 sb.write("{"); |
252 sb.write("'constructor': ${targetConstructorInvocation.toDartText()}"); | 256 sb.write("'constructor': ${targetConstructorInvocation.toDartText()}"); |
253 sb.write("}"); | 257 sb.write("}"); |
254 return sb.toString(); | 258 return sb.toString(); |
255 } | 259 } |
256 } | 260 } |
OLD | NEW |