OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
4 | 4 |
5 import 'package:kernel/ast.dart' as ir; | 5 import 'package:kernel/ast.dart' as ir; |
6 import 'package:kernel/frontend/accessors.dart' as ir_accessors; | 6 import 'package:kernel/frontend/accessors.dart' as ir_accessors; |
7 | 7 |
8 import 'kernel.dart' show Kernel; | 8 import 'kernel.dart' show Kernel; |
9 import 'unresolved.dart' show UnresolvedVisitor; | 9 import 'unresolved.dart' show UnresolvedVisitor; |
10 | 10 |
11 export 'package:kernel/frontend/accessors.dart' show Accessor; | 11 export 'package:kernel/frontend/accessors.dart' show Accessor; |
12 | 12 |
13 class TopLevelStaticAccessor extends ir_accessors.StaticAccessor { | 13 class TopLevelStaticAccessor extends ir_accessors.StaticAccessor { |
14 final UnresolvedVisitor builder; | 14 final UnresolvedVisitor builder; |
15 | 15 |
16 /// Name of the property attempted to be accessed, used to generate an | 16 /// Name of the property attempted to be accessed, used to generate an |
17 /// error if unresolved. | 17 /// error if unresolved. |
18 final String name; | 18 final String name; |
19 | 19 |
20 Kernel get kernel => builder.kernel; | 20 Kernel get kernel => builder.kernel; |
21 | 21 |
22 TopLevelStaticAccessor( | 22 TopLevelStaticAccessor( |
23 this.builder, this.name, ir.Member readTarget, ir.Member writeTarget) | 23 this.builder, this.name, ir.Member readTarget, ir.Member writeTarget) |
24 : super(readTarget, writeTarget); | 24 : super(readTarget, writeTarget, ir.TreeNode.noOffset); |
25 | 25 |
26 @override | 26 @override |
27 makeInvalidRead() { | 27 makeInvalidRead() { |
28 return builder.buildThrowNoSuchMethodError( | 28 return builder.buildThrowNoSuchMethodError( |
29 kernel.getUnresolvedTopLevelGetterBuilder(), | 29 kernel.getUnresolvedTopLevelGetterBuilder(), |
30 new ir.NullLiteral(), | 30 new ir.NullLiteral(), |
31 name, | 31 name, |
32 new ir.Arguments.empty()); | 32 new ir.Arguments.empty()); |
33 } | 33 } |
34 | 34 |
(...skipping 11 matching lines...) Expand all Loading... |
46 final UnresolvedVisitor builder; | 46 final UnresolvedVisitor builder; |
47 | 47 |
48 /// Name of the property attempted to be accessed, used to generate an | 48 /// Name of the property attempted to be accessed, used to generate an |
49 /// error if unresolved. | 49 /// error if unresolved. |
50 final String name; | 50 final String name; |
51 | 51 |
52 Kernel get kernel => builder.kernel; | 52 Kernel get kernel => builder.kernel; |
53 | 53 |
54 ClassStaticAccessor( | 54 ClassStaticAccessor( |
55 this.builder, this.name, ir.Member readTarget, ir.Member writeTarget) | 55 this.builder, this.name, ir.Member readTarget, ir.Member writeTarget) |
56 : super(readTarget, writeTarget); | 56 : super(readTarget, writeTarget, ir.TreeNode.noOffset); |
57 | 57 |
58 @override | 58 @override |
59 makeInvalidRead() { | 59 makeInvalidRead() { |
60 return builder.buildThrowNoSuchMethodError( | 60 return builder.buildThrowNoSuchMethodError( |
61 kernel.getUnresolvedStaticGetterBuilder(), | 61 kernel.getUnresolvedStaticGetterBuilder(), |
62 new ir.NullLiteral(), | 62 new ir.NullLiteral(), |
63 name, | 63 name, |
64 new ir.Arguments.empty()); | 64 new ir.Arguments.empty()); |
65 } | 65 } |
66 | 66 |
67 @override | 67 @override |
68 makeInvalidWrite(ir.Expression value) { | 68 makeInvalidWrite(ir.Expression value) { |
69 return builder.buildThrowNoSuchMethodError( | 69 return builder.buildThrowNoSuchMethodError( |
70 kernel.getUnresolvedStaticSetterBuilder(), | 70 kernel.getUnresolvedStaticSetterBuilder(), |
71 new ir.NullLiteral(), | 71 new ir.NullLiteral(), |
72 name, | 72 name, |
73 new ir.Arguments(<ir.Expression>[value])); | 73 new ir.Arguments(<ir.Expression>[value])); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 class SuperPropertyAccessor extends ir_accessors.SuperPropertyAccessor { | 77 class SuperPropertyAccessor extends ir_accessors.SuperPropertyAccessor { |
78 final UnresolvedVisitor builder; | 78 final UnresolvedVisitor builder; |
79 | 79 |
80 SuperPropertyAccessor( | 80 SuperPropertyAccessor( |
81 this.builder, ir.Name name, ir.Member getter, ir.Member setter) | 81 this.builder, ir.Name name, ir.Member getter, ir.Member setter) |
82 : super(name, getter, setter); | 82 : super(name, getter, setter, ir.TreeNode.noOffset); |
83 | 83 |
84 @override | 84 @override |
85 makeInvalidRead() { | 85 makeInvalidRead() { |
86 // TODO(asgerf): Technically, we should invoke 'super.noSuchMethod' for | 86 // TODO(asgerf): Technically, we should invoke 'super.noSuchMethod' for |
87 // this and the other invalid super cases. | 87 // this and the other invalid super cases. |
88 return builder.buildThrowUnresolvedSuperGetter(name.name); | 88 return builder.buildThrowUnresolvedSuperGetter(name.name); |
89 } | 89 } |
90 | 90 |
91 @override | 91 @override |
92 makeInvalidWrite(ir.Expression value) { | 92 makeInvalidWrite(ir.Expression value) { |
93 return builder.buildThrowUnresolvedSuperSetter(name.name, value); | 93 return builder.buildThrowUnresolvedSuperSetter(name.name, value); |
94 } | 94 } |
95 } | 95 } |
96 | 96 |
97 class SuperIndexAccessor extends ir_accessors.SuperIndexAccessor { | 97 class SuperIndexAccessor extends ir_accessors.SuperIndexAccessor { |
98 final UnresolvedVisitor builder; | 98 final UnresolvedVisitor builder; |
99 | 99 |
100 Kernel get kernel => builder.kernel; | 100 Kernel get kernel => builder.kernel; |
101 | 101 |
102 SuperIndexAccessor( | 102 SuperIndexAccessor( |
103 this.builder, ir.Expression index, ir.Member getter, ir.Member setter) | 103 this.builder, ir.Expression index, ir.Member getter, ir.Member setter) |
104 : super(index, getter, setter); | 104 : super(index, getter, setter, ir.TreeNode.noOffset); |
105 | 105 |
106 @override | 106 @override |
107 makeInvalidRead() { | 107 makeInvalidRead() { |
108 return builder.buildThrowNoSuchMethodError( | 108 return builder.buildThrowNoSuchMethodError( |
109 kernel.getUnresolvedSuperMethodBuilder(), | 109 kernel.getUnresolvedSuperMethodBuilder(), |
110 new ir.ThisExpression(), | 110 new ir.ThisExpression(), |
111 '[]', | 111 '[]', |
112 new ir.Arguments(<ir.Expression>[indexAccess()])); | 112 new ir.Arguments(<ir.Expression>[indexAccess()])); |
113 } | 113 } |
114 | 114 |
115 @override | 115 @override |
116 makeInvalidWrite(ir.Expression value) { | 116 makeInvalidWrite(ir.Expression value) { |
117 return builder.buildThrowNoSuchMethodError( | 117 return builder.buildThrowNoSuchMethodError( |
118 kernel.getUnresolvedSuperMethodBuilder(), | 118 kernel.getUnresolvedSuperMethodBuilder(), |
119 new ir.ThisExpression(), | 119 new ir.ThisExpression(), |
120 '[]=', | 120 '[]=', |
121 new ir.Arguments(<ir.Expression>[indexAccess(), value])); | 121 new ir.Arguments(<ir.Expression>[indexAccess(), value])); |
122 } | 122 } |
123 } | 123 } |
OLD | NEW |