Revert "[kernel] offsets on direct property get/set"

This commit wanted stuff from anther CL that haven't landed yet.

This reverts commit 7577f6aaa0.

BUG=

Review-Url: https://codereview.chromium.org/2751083002 .
This commit is contained in:
Jens Johansen 2017-03-15 13:54:03 +01:00
parent 4b9297caad
commit 9fa510ea38
9 changed files with 16 additions and 183 deletions

View file

@ -216,10 +216,10 @@ class ThisAccessor extends BuilderAccessor {
Member getter = helper.lookupSuperMember(send.name);
Member setter = helper.lookupSuperMember(send.name, isSetter: true);
return new SuperPropertyAccessor(
helper, send.charOffset, send.name, getter, setter);
helper, charOffset, send.name, getter, setter);
} else {
return new ThisPropertyAccessor(
helper, send.charOffset, send.name, null, null);
helper, charOffset, send.name, null, null);
}
}
}
@ -592,9 +592,11 @@ class SuperPropertyAccessor extends kernel.SuperPropertyAccessor
with BuilderAccessor {
final BuilderHelper helper;
final int charOffset;
SuperPropertyAccessor(
this.helper, int charOffset, Name name, Member getter, Member setter)
: super(name, getter, setter, charOffset);
this.helper, this.charOffset, Name name, Member getter, Member setter)
: super(name, getter, setter);
String get plainNameForRead => name.name;

View file

@ -222,25 +222,23 @@ class NullAwarePropertyAccessor extends Accessor {
class SuperPropertyAccessor extends Accessor {
Name name;
Member getter, setter;
final int charOffset;
SuperPropertyAccessor(this.name, this.getter, this.setter, this.charOffset);
SuperPropertyAccessor(this.name, this.getter, this.setter);
_makeRead() {
if (getter == null) return makeInvalidRead();
// TODO(ahe): Use [DirectPropertyGet] when possible.
Expression result = new DirectPropertyGet(new ThisExpression(), getter)
..fileOffset = charOffset;
result = new SuperPropertyGet(name, getter)..fileOffset = charOffset;
Expression result = new DirectPropertyGet(new ThisExpression(), getter);
result = new SuperPropertyGet(name, getter);
return result;
}
_makeWrite(Expression value, bool voidContext) {
if (setter == null) return makeInvalidWrite(value);
// TODO(ahe): Use [DirectPropertySet] when possible.
Expression result = new DirectPropertySet(
new ThisExpression(), setter, value)..fileOffset = charOffset;
result = new SuperPropertySet(name, value, setter)..fileOffset = charOffset;
Expression result =
new DirectPropertySet(new ThisExpression(), setter, value);
result = new SuperPropertySet(name, value, setter);
return result;
}
}

View file

@ -395,14 +395,12 @@ type SuperPropertySet extends Expression {
type DirectPropertyGet extends Expression {
Byte tag = 15; // Note: tag is out of order
FileOffset fileOffset;
Expression receiver;
MemberReference target;
}
type DirectPropertySet extends Expression {
Byte tag = 16; // Note: tag is out of order
FileOffset fileOffset;
Expression receiver;
MemberReference target;
Expression value;

View file

@ -687,14 +687,11 @@ class BinaryBuilder {
return new SuperPropertySet.byReference(
readName(), readExpression(), readMemberReference(allowNull: true));
case Tag.DirectPropertyGet:
int offset = readOffset();
return new DirectPropertyGet.byReference(
readExpression(), readMemberReference())..fileOffset = offset;
readExpression(), readMemberReference());
case Tag.DirectPropertySet:
int offset = readOffset();
return new DirectPropertySet.byReference(
readExpression(), readMemberReference(), readExpression())
..fileOffset = offset;
readExpression(), readMemberReference(), readExpression());
case Tag.StaticGet:
int offset = readOffset();
return new StaticGet.byReference(readMemberReference())

View file

@ -501,14 +501,12 @@ class BinaryPrinter extends Visitor {
visitDirectPropertyGet(DirectPropertyGet node) {
writeByte(Tag.DirectPropertyGet);
writeOffset(node, node.fileOffset);
writeNode(node.receiver);
writeReference(node.targetReference);
}
visitDirectPropertySet(DirectPropertySet node) {
writeByte(Tag.DirectPropertySet);
writeOffset(node, node.fileOffset);
writeNode(node.receiver);
writeReference(node.targetReference);
writeNode(node.value);

View file

@ -187,8 +187,7 @@ class SuperCallResolutionTransformer extends Transformer {
visitSuperPropertyGet(SuperPropertyGet node) {
Member target = hierarchy.getDispatchTarget(lookupClass, node.name);
if (target != null) {
return new DirectPropertyGet(new ThisExpression(), target)
..fileOffset = node.fileOffset;
return new DirectPropertyGet(new ThisExpression(), target);
} else {
return _callNoSuchMethod(node.name.name, new Arguments.empty(), node,
isGetter: true, isSuper: true);
@ -200,8 +199,7 @@ class SuperCallResolutionTransformer extends Transformer {
hierarchy.getDispatchTarget(lookupClass, node.name, setter: true);
if (target != null) {
return new DirectPropertySet(
new ThisExpression(), target, visit(node.value))
..fileOffset = node.fileOffset;
new ThisExpression(), target, visit(node.value));
} else {
// Call has to return right-hand-side.
VariableDeclaration rightHandSide =

View file

@ -1,78 +0,0 @@
// Copyright (c) 2017, 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 file.
import 'test_helper.dart';
import 'service_test_common.dart';
const int LINE = 33;
const String file = "step_through_property_get_test.dart";
code() {
Bar bar = new Bar();
bar.doStuff();
}
class Foo {
final List<String> data1;
Foo() : data1 = ["a", "b", "c"];
void doStuff() {
print(data1);
print(data1[1]);
}
}
class Bar extends Foo {
final List<String> data2;
Bar() : data2 = ["d", "e", "f"];
void doStuff() {
print(data2);
print(data2[1]);
print(data1);
print(data1[1]);
print(super.data1);
print(super.data1[1]);
}
}
List<String> stops = [];
List<String> expected = [
"$file:${LINE+0}:11", // on 'data2'
"$file:${LINE+0}:5", // on 'print'
"$file:${LINE+1}:11", // on 'data2'
"$file:${LINE+1}:16", // on '['
"$file:${LINE+1}:5", // on 'print'
"$file:${LINE+3}:11", // on 'data1'
"$file:${LINE+3}:5", // on 'print'
"$file:${LINE+4}:11", // on 'data1'
"$file:${LINE+4}:16", // on '['
"$file:${LINE+4}:5", // on 'print'
"$file:${LINE+6}:17", // on 'data1'
"$file:${LINE+6}:5", // on 'print'
"$file:${LINE+7}:17", // on 'data1'
"$file:${LINE+7}:22", // on '['
"$file:${LINE+7}:5", // on 'print'
"$file:${LINE+8}:3" // on ending '}'
];
var tests = [
hasPausedAtStart,
setBreakpointAtLine(LINE),
runStepIntoThroughProgramRecordingStops(stops),
checkRecordedStops(stops, expected,
debugPrint: true, debugPrintFile: file, debugPrintLine: LINE)
];
main(args) {
runIsolateTestsSynchronous(args, tests,
testeeConcurrent: code, pause_on_start: true, pause_on_exit: true);
}

View file

@ -1,78 +0,0 @@
// Copyright (c) 2017, 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 file.
import 'test_helper.dart';
import 'service_test_common.dart';
const int LINE = 33;
const String file = "step_through_property_set_test.dart";
code() {
Bar bar = new Bar();
bar.doStuff();
}
class Foo {
final List<String> data1;
Foo() : data1 = ["a", "b", "c"];
void doStuff() {
data1[1] = 'x';
print(data1[1]);
}
}
class Bar extends Foo {
final List<String> data2;
Bar() : data2 = ["d", "e", "f"];
void doStuff() {
data2[1] = '1';
print(data2[1]);
data1[1] = '2';
print(data1[1]);
super.data1[1] = '42';
print(super.data1[1]);
}
}
List<String> stops = [];
List<String> expected = [
"$file:${LINE+0}:5", // on 'data2'
"$file:${LINE+0}:10", // on '['
"$file:${LINE+1}:11", // on 'data2'
"$file:${LINE+1}:16", // on '['
"$file:${LINE+1}:5", // on 'print'
"$file:${LINE+3}:5", // on 'data1'
"$file:${LINE+3}:10", // on '['
"$file:${LINE+4}:11", // on 'data1'
"$file:${LINE+4}:16", // on '['
"$file:${LINE+4}:5", // on 'print'
"$file:${LINE+6}:11", // on 'data1'
"$file:${LINE+6}:16", // on '['
"$file:${LINE+7}:17", // on 'data1'
"$file:${LINE+7}:22", // on '['
"$file:${LINE+7}:5", // on 'print'
"$file:${LINE+8}:3" // on ending '}'
];
var tests = [
hasPausedAtStart,
setBreakpointAtLine(LINE),
runStepIntoThroughProgramRecordingStops(stops),
checkRecordedStops(stops, expected,
debugPrint: true, debugPrintFile: file, debugPrintLine: LINE)
];
main(args) {
runIsolateTestsSynchronous(args, tests,
testeeConcurrent: code, pause_on_start: true, pause_on_exit: true);
}

View file

@ -1096,7 +1096,6 @@ PropertySet* PropertySet::ReadFrom(Reader* reader) {
DirectPropertyGet* DirectPropertyGet::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
DirectPropertyGet* get = new DirectPropertyGet();
get->position_ = reader->ReadPosition();
get->receiver_ = Expression::ReadFrom(reader);
get->target_reference_ = Reference::ReadMemberFrom(reader);
return get;
@ -1106,7 +1105,6 @@ DirectPropertyGet* DirectPropertyGet::ReadFrom(Reader* reader) {
DirectPropertySet* DirectPropertySet::ReadFrom(Reader* reader) {
TRACE_READ_OFFSET();
DirectPropertySet* set = new DirectPropertySet();
set->position_ = reader->ReadPosition();
set->receiver_ = Expression::ReadFrom(reader);
set->target_reference_ = Reference::ReadMemberFrom(reader);
set->value_ = Expression::ReadFrom(reader);