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

Unified Diff: pkg/compiler/lib/src/kernel/accessors.dart

Issue 2265383002: Copy Rasta visitor to dart2js. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: missed some renames Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/compiler/lib/src/kernel/error.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/kernel/accessors.dart
diff --git a/pkg/compiler/lib/src/kernel/accessors.dart b/pkg/compiler/lib/src/kernel/accessors.dart
new file mode 100644
index 0000000000000000000000000000000000000000..026ba63001c1eec6eb06fe0bb48912884340df61
--- /dev/null
+++ b/pkg/compiler/lib/src/kernel/accessors.dart
@@ -0,0 +1,136 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE.md file.
+
+import 'package:kernel/ast.dart' as ir;
+import 'package:kernel/frontend/accessors.dart' as ir_accessors;
+
+import 'kernel.dart' show Kernel;
+import 'unresolved.dart' show UnresolvedVisitor;
+
+export 'package:kernel/frontend/accessors.dart' show Accessor;
+
+class TopLevelStaticAccessor extends ir_accessors.StaticAccessor {
+ final UnresolvedVisitor builder;
+
+ /// Name of the property attempted to be accessed, used to generate an
+ /// error if unresolved.
+ final String name;
+
+ Kernel get kernel => builder.kernel;
+
+ TopLevelStaticAccessor(
+ this.builder,
+ this.name,
+ ir.Member readTarget,
+ ir.Member writeTarget)
+ : super(readTarget, writeTarget);
+
+ @override
+ makeInvalidRead() {
+ return builder.buildThrowNoSuchMethodError(
+ kernel.getUnresolvedTopLevelGetterBuilder(),
+ new ir.NullLiteral(),
+ name,
+ new ir.Arguments.empty());
+ }
+
+ @override
+ makeInvalidWrite(ir.Expression value) {
+ return builder.buildThrowNoSuchMethodError(
+ kernel.getUnresolvedTopLevelSetterBuilder(),
+ new ir.NullLiteral(),
+ name,
+ new ir.Arguments(<ir.Expression>[value]));
+ }
+}
+
+class ClassStaticAccessor extends ir_accessors.StaticAccessor {
+ final UnresolvedVisitor builder;
+
+ /// Name of the property attempted to be accessed, used to generate an
+ /// error if unresolved.
+ final String name;
+
+ Kernel get kernel => builder.kernel;
+
+ ClassStaticAccessor(this.builder, this.name,
+ ir.Member readTarget, ir.Member writeTarget)
+ : super(readTarget, writeTarget);
+
+ @override
+ makeInvalidRead() {
+ return builder.buildThrowNoSuchMethodError(
+ kernel.getUnresolvedStaticGetterBuilder(),
+ new ir.NullLiteral(),
+ name,
+ new ir.Arguments.empty());
+ }
+
+ @override
+ makeInvalidWrite(ir.Expression value) {
+ return builder.buildThrowNoSuchMethodError(
+ kernel.getUnresolvedStaticSetterBuilder(),
+ new ir.NullLiteral(),
+ name,
+ new ir.Arguments(<ir.Expression>[value]));
+ }
+}
+
+class SuperPropertyAccessor extends ir_accessors.SuperPropertyAccessor {
+ final UnresolvedVisitor builder;
+
+ /// Name of the property attempted to be accessed, used to generate an
+ /// error if unresolved.
+ final String name;
+
+ SuperPropertyAccessor(
+ this.builder,
+ this.name,
+ ir.Member readTarget,
+ ir.Member writeTarget)
+ : super(readTarget, writeTarget);
+
+ @override
+ makeInvalidRead() {
+ // TODO(asgerf): Technically, we should invoke 'super.noSuchMethod' for
+ // this and the other invalid super cases.
+ return builder.buildThrowUnresolvedSuperGetter(name);
+ }
+
+ @override
+ makeInvalidWrite(ir.Expression value) {
+ return builder.buildThrowUnresolvedSuperSetter(name, value);
+ }
+}
+
+class SuperIndexAccessor extends ir_accessors.SuperIndexAccessor {
+ final UnresolvedVisitor builder;
+
+ Kernel get kernel => builder.kernel;
+
+ SuperIndexAccessor(
+ this.builder,
+ ir.Expression index,
+ ir.Member readTarget,
+ ir.Member writeTarget)
+ : super(index, readTarget, writeTarget);
+
+ @override
+ makeInvalidRead() {
+ return builder.buildThrowNoSuchMethodError(
+ kernel.getUnresolvedSuperMethodBuilder(),
+ new ir.ThisExpression(),
+ '[]',
+ new ir.Arguments(<ir.Expression>[indexAccess()]));
+ }
+
+ @override
+ makeInvalidWrite(ir.Expression value) {
+ return builder.buildThrowNoSuchMethodError(
+ kernel.getUnresolvedSuperMethodBuilder(),
+ new ir.ThisExpression(),
+ '[]=',
+ new ir.Arguments(<ir.Expression>[indexAccess(), value]));
+ }
+}
« no previous file with comments | « no previous file | pkg/compiler/lib/src/kernel/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698