Rename some classes to match the design better (#1287)

* `FieldAccessExpression` -> `SimpleMemberAccessExpression`
    * Member `aggregate` -> `object`
    * Member `field` -> `member`
* `CompoundFieldAccessExpression` -> `CompoundMemberAccessExpression`
* `GetField` -> `GetMember`

As discussed in #1233.
This commit is contained in:
Richard Smith
2022-05-24 17:51:54 -07:00
committed by GitHub
parent 8b07d1ce5d
commit 4cf7ed4f12
45 changed files with 632 additions and 626 deletions
+6 -6
View File
@@ -23,18 +23,18 @@ message FunctionTypeLiteral {
optional Expression return_type = 2;
}
message FieldAccessExpression {
message SimpleMemberAccessExpression {
optional string field = 1;
optional Expression aggregate = 2;
optional Expression object = 2;
}
message CompoundFieldAccessExpression {
message CompoundMemberAccessExpression {
optional Expression object = 1;
optional Expression path = 2;
}
message IndexExpression {
optional Expression aggregate = 1;
optional Expression object = 1;
optional Expression offset = 2;
}
@@ -124,7 +124,7 @@ message Expression {
oneof kind {
CallExpression call = 1;
FunctionTypeLiteral function_type = 2;
FieldAccessExpression field_access = 3;
SimpleMemberAccessExpression simple_member_access = 3;
IndexExpression index = 4;
PrimitiveOperatorExpression primitive_operator = 5;
TupleLiteralExpression tuple_literal = 6;
@@ -143,7 +143,7 @@ message Expression {
TypeTypeLiteral type_type_literal = 19;
UnimplementedExpression unimplemented_expression = 20;
ArrayTypeLiteral array_type_literal = 21;
CompoundFieldAccessExpression compound_field_access = 22;
CompoundMemberAccessExpression compound_member_access = 22;
}
}
+9 -9
View File
@@ -206,26 +206,26 @@ static auto ExpressionToCarbon(const Fuzzing::Expression& expression,
break;
}
case Fuzzing::Expression::kFieldAccess: {
const auto& field_access = expression.field_access();
ExpressionToCarbon(field_access.aggregate(), out);
case Fuzzing::Expression::kSimpleMemberAccess: {
const auto& simple_member_access = expression.simple_member_access();
ExpressionToCarbon(simple_member_access.object(), out);
out << ".";
IdentifierToCarbon(field_access.field(), out);
IdentifierToCarbon(simple_member_access.field(), out);
break;
}
case Fuzzing::Expression::kCompoundFieldAccess: {
const auto& field_access = expression.compound_field_access();
ExpressionToCarbon(field_access.object(), out);
case Fuzzing::Expression::kCompoundMemberAccess: {
const auto& simple_member_access = expression.compound_member_access();
ExpressionToCarbon(simple_member_access.object(), out);
out << ".(";
ExpressionToCarbon(field_access.path(), out);
ExpressionToCarbon(simple_member_access.path(), out);
out << ")";
break;
}
case Fuzzing::Expression::kIndex: {
const auto& index = expression.index();
ExpressionToCarbon(index.aggregate(), out);
ExpressionToCarbon(index.object(), out);
out << "[";
ExpressionToCarbon(index.offset(), out);
out << "]";
+2 -2
View File
@@ -41,8 +41,8 @@ abstract class Expression : AstNode;
class BoolLiteral : Expression;
class CallExpression : Expression;
class FunctionTypeLiteral : Expression;
class FieldAccessExpression : Expression;
class CompoundFieldAccessExpression : Expression;
class SimpleMemberAccessExpression : Expression;
class CompoundMemberAccessExpression : Expression;
class IndexExpression : Expression;
class IntTypeLiteral : Expression;
class ContinuationTypeLiteral : Expression;
+8 -8
View File
@@ -87,16 +87,16 @@ void Expression::Print(llvm::raw_ostream& out) const {
switch (kind()) {
case ExpressionKind::IndexExpression: {
const auto& index = cast<IndexExpression>(*this);
out << index.aggregate() << "[" << index.offset() << "]";
out << index.object() << "[" << index.offset() << "]";
break;
}
case ExpressionKind::FieldAccessExpression: {
const auto& access = cast<FieldAccessExpression>(*this);
out << access.aggregate() << "." << access.field();
case ExpressionKind::SimpleMemberAccessExpression: {
const auto& access = cast<SimpleMemberAccessExpression>(*this);
out << access.object() << "." << access.member();
break;
}
case ExpressionKind::CompoundFieldAccessExpression: {
const auto& access = cast<CompoundFieldAccessExpression>(*this);
case ExpressionKind::CompoundMemberAccessExpression: {
const auto& access = cast<CompoundMemberAccessExpression>(*this);
out << access.object() << ".(" << access.path() << ")";
break;
}
@@ -242,8 +242,8 @@ void Expression::PrintID(llvm::raw_ostream& out) const {
out << "ValueLiteral";
break;
case ExpressionKind::IndexExpression:
case ExpressionKind::FieldAccessExpression:
case ExpressionKind::CompoundFieldAccessExpression:
case ExpressionKind::SimpleMemberAccessExpression:
case ExpressionKind::CompoundMemberAccessExpression:
case ExpressionKind::IfExpression:
case ExpressionKind::TupleLiteral:
case ExpressionKind::StructLiteral:
+25 -25
View File
@@ -152,24 +152,24 @@ class IdentifierExpression : public Expression {
std::optional<ValueNodeView> value_node_;
};
class FieldAccessExpression : public Expression {
class SimpleMemberAccessExpression : public Expression {
public:
explicit FieldAccessExpression(SourceLocation source_loc,
Nonnull<Expression*> aggregate,
std::string field)
: Expression(AstNodeKind::FieldAccessExpression, source_loc),
aggregate_(aggregate),
field_(std::move(field)) {}
explicit SimpleMemberAccessExpression(SourceLocation source_loc,
Nonnull<Expression*> object,
std::string member)
: Expression(AstNodeKind::SimpleMemberAccessExpression, source_loc),
object_(object),
member_(std::move(member)) {}
static auto classof(const AstNode* node) -> bool {
return InheritsFromFieldAccessExpression(node->kind());
return InheritsFromSimpleMemberAccessExpression(node->kind());
}
auto aggregate() const -> const Expression& { return *aggregate_; }
auto aggregate() -> Expression& { return *aggregate_; }
auto field() const -> const std::string& { return field_; }
auto object() const -> const Expression& { return *object_; }
auto object() -> Expression& { return *object_; }
auto member() const -> const std::string& { return member_; }
// If `aggregate` has a generic type, returns the `ImplBinding` that
// If `object` has a generic type, returns the `ImplBinding` that
// identifies its witness table. Otherwise, returns `std::nullopt`. Should not
// be called before typechecking.
auto impl() const -> std::optional<Nonnull<const ImplBinding*>> {
@@ -183,8 +183,8 @@ class FieldAccessExpression : public Expression {
}
private:
Nonnull<Expression*> aggregate_;
std::string field_;
Nonnull<Expression*> object_;
std::string member_;
std::optional<Nonnull<const ImplBinding*>> impl_;
};
@@ -201,17 +201,17 @@ class FieldAccessExpression : public Expression {
//
// Note that the `path` is evaluated during type-checking, not at runtime, so
// the corresponding `member` is determined statically.
class CompoundFieldAccessExpression : public Expression {
class CompoundMemberAccessExpression : public Expression {
public:
explicit CompoundFieldAccessExpression(SourceLocation source_loc,
Nonnull<Expression*> object,
Nonnull<Expression*> path)
: Expression(AstNodeKind::CompoundFieldAccessExpression, source_loc),
explicit CompoundMemberAccessExpression(SourceLocation source_loc,
Nonnull<Expression*> object,
Nonnull<Expression*> path)
: Expression(AstNodeKind::CompoundMemberAccessExpression, source_loc),
object_(object),
path_(path) {}
static auto classof(const AstNode* node) -> bool {
return InheritsFromCompoundFieldAccessExpression(node->kind());
return InheritsFromCompoundMemberAccessExpression(node->kind());
}
auto object() const -> const Expression& { return *object_; }
@@ -257,23 +257,23 @@ class CompoundFieldAccessExpression : public Expression {
class IndexExpression : public Expression {
public:
explicit IndexExpression(SourceLocation source_loc,
Nonnull<Expression*> aggregate,
Nonnull<Expression*> object,
Nonnull<Expression*> offset)
: Expression(AstNodeKind::IndexExpression, source_loc),
aggregate_(aggregate),
object_(object),
offset_(offset) {}
static auto classof(const AstNode* node) -> bool {
return InheritsFromIndexExpression(node->kind());
}
auto aggregate() const -> const Expression& { return *aggregate_; }
auto aggregate() -> Expression& { return *aggregate_; }
auto object() const -> const Expression& { return *object_; }
auto object() -> Expression& { return *object_; }
auto offset() const -> const Expression& { return *offset_; }
auto offset() -> Expression& { return *offset_; }
private:
Nonnull<Expression*> aggregate_;
Nonnull<Expression*> object_;
Nonnull<Expression*> offset_;
};
+5 -4
View File
@@ -141,13 +141,14 @@ auto TuplePatternFromParenContents(Nonnull<Arena*> arena,
// Used by AlternativePattern for constructor initialization. Produces a helpful
// error for incorrect expressions, rather than letting a default cast error
// apply.
auto AlternativePattern::RequireFieldAccess(Nonnull<Expression*> alternative)
-> ErrorOr<Nonnull<FieldAccessExpression*>> {
if (alternative->kind() != ExpressionKind::FieldAccessExpression) {
auto AlternativePattern::RequireSimpleMemberAccess(
Nonnull<Expression*> alternative)
-> ErrorOr<Nonnull<SimpleMemberAccessExpression*>> {
if (alternative->kind() != ExpressionKind::SimpleMemberAccessExpression) {
return ProgramError(alternative->source_loc())
<< "Alternative pattern must have the form of a field access.";
}
return &cast<FieldAccessExpression>(*alternative);
return &cast<SimpleMemberAccessExpression>(*alternative);
}
auto ParenExpressionToParenPattern(Nonnull<Arena*> arena,
+7 -7
View File
@@ -285,11 +285,11 @@ class AlternativePattern : public Pattern {
Nonnull<Expression*> alternative,
Nonnull<TuplePattern*> arguments)
-> ErrorOr<Nonnull<AlternativePattern*>> {
CARBON_ASSIGN_OR_RETURN(Nonnull<FieldAccessExpression*> field_access,
RequireFieldAccess(alternative));
return arena->New<AlternativePattern>(source_loc,
&field_access->aggregate(),
field_access->field(), arguments);
CARBON_ASSIGN_OR_RETURN(
Nonnull<SimpleMemberAccessExpression*> member_access,
RequireSimpleMemberAccess(alternative));
return arena->New<AlternativePattern>(source_loc, &member_access->object(),
member_access->member(), arguments);
}
// Constructs an AlternativePattern that matches a value of the type
@@ -317,8 +317,8 @@ class AlternativePattern : public Pattern {
auto arguments() -> TuplePattern& { return *arguments_; }
private:
static auto RequireFieldAccess(Nonnull<Expression*> alternative)
-> ErrorOr<Nonnull<FieldAccessExpression*>>;
static auto RequireSimpleMemberAccess(Nonnull<Expression*> alternative)
-> ErrorOr<Nonnull<SimpleMemberAccessExpression*>>;
Nonnull<Expression*> choice_type_;
std::string alternative_name_;
+18 -16
View File
@@ -103,31 +103,33 @@ static auto ExpressionToProto(const Expression& expression)
break;
}
case ExpressionKind::FieldAccessExpression: {
const auto& field_access = cast<FieldAccessExpression>(expression);
auto* field_access_proto = expression_proto.mutable_field_access();
field_access_proto->set_field(field_access.field());
*field_access_proto->mutable_aggregate() =
ExpressionToProto(field_access.aggregate());
case ExpressionKind::SimpleMemberAccessExpression: {
const auto& simple_member_access =
cast<SimpleMemberAccessExpression>(expression);
auto* simple_member_access_proto =
expression_proto.mutable_simple_member_access();
simple_member_access_proto->set_field(simple_member_access.member());
*simple_member_access_proto->mutable_object() =
ExpressionToProto(simple_member_access.object());
break;
}
case ExpressionKind::CompoundFieldAccessExpression: {
const auto& field_access =
cast<CompoundFieldAccessExpression>(expression);
auto* field_access_proto =
expression_proto.mutable_compound_field_access();
*field_access_proto->mutable_object() =
ExpressionToProto(field_access.object());
*field_access_proto->mutable_path() =
ExpressionToProto(field_access.path());
case ExpressionKind::CompoundMemberAccessExpression: {
const auto& simple_member_access =
cast<CompoundMemberAccessExpression>(expression);
auto* simple_member_access_proto =
expression_proto.mutable_compound_member_access();
*simple_member_access_proto->mutable_object() =
ExpressionToProto(simple_member_access.object());
*simple_member_access_proto->mutable_path() =
ExpressionToProto(simple_member_access.path());
break;
}
case ExpressionKind::IndexExpression: {
const auto& index = cast<IndexExpression>(expression);
auto* index_proto = expression_proto.mutable_index();
*index_proto->mutable_aggregate() = ExpressionToProto(index.aggregate());
*index_proto->mutable_object() = ExpressionToProto(index.object());
*index_proto->mutable_offset() = ExpressionToProto(index.offset());
break;
}
@@ -68,9 +68,9 @@ compilation_unit {
init {
call {
function {
field_access {
simple_member_access {
field: "None"
aggregate {
object {
identifier {
name: "Ints"
}
@@ -99,9 +99,9 @@ compilation_unit {
init {
call {
function {
field_access {
simple_member_access {
field: "One"
aggregate {
object {
identifier {
name: "Ints"
}
@@ -150,9 +150,9 @@ compilation_unit {
pattern {
expression_pattern {
expression {
field_access {
simple_member_access {
field: "None"
aggregate {
object {
identifier {
name: "Ints"
}
@@ -351,9 +351,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "None"
aggregate {
object {
identifier {
name: "Ints"
}
@@ -267,9 +267,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "U"
}
@@ -288,9 +288,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "U"
}
@@ -360,12 +360,12 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
field_access {
object {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -377,9 +377,9 @@ compilation_unit {
argument {
tuple_literal {
fields {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "other"
}
@@ -396,12 +396,12 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
field_access {
object {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -413,9 +413,9 @@ compilation_unit {
argument {
tuple_literal {
fields {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "other"
}
@@ -505,9 +505,9 @@ compilation_unit {
init {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "E"
}
@@ -532,9 +532,9 @@ compilation_unit {
rhs {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "total"
}
@@ -564,9 +564,9 @@ compilation_unit {
rhs {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "total"
}
@@ -770,9 +770,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "r"
}
@@ -780,9 +780,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "r"
}
@@ -110,9 +110,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "T"
}
@@ -131,9 +131,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "T"
}
@@ -352,17 +352,17 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
field_access {
object {
simple_member_access {
field: "x"
aggregate {
object {
call {
function {
field_access {
simple_member_access {
field: "Origin"
aggregate {
object {
identifier {
name: "p"
}
@@ -382,9 +382,9 @@ compilation_unit {
argument {
tuple_literal {
fields {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "p"
}
@@ -261,9 +261,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -271,9 +271,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -289,9 +289,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -299,9 +299,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -367,9 +367,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -390,9 +390,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -493,14 +493,14 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -512,9 +512,9 @@ compilation_unit {
fields {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "U"
}
@@ -647,9 +647,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -192,9 +192,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -202,9 +202,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -220,9 +220,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -230,9 +230,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -298,9 +298,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -321,9 +321,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -419,11 +419,11 @@ compilation_unit {
}
}
init {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
index {
aggregate {
object {
identifier {
name: "t"
}
@@ -451,9 +451,9 @@ compilation_unit {
}
}
init {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
call {
function {
identifier {
@@ -464,7 +464,7 @@ compilation_unit {
tuple_literal {
fields {
index {
aggregate {
object {
identifier {
name: "t"
}
@@ -654,9 +654,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -96,7 +96,7 @@ compilation_unit {
tuple_literal {
fields {
index {
aggregate {
object {
identifier {
name: "tuple"
}
@@ -123,7 +123,7 @@ compilation_unit {
tuple_literal {
fields {
index {
aggregate {
object {
identifier {
name: "tuple"
}
@@ -211,7 +211,7 @@ compilation_unit {
return_statement {
expression {
index {
aggregate {
object {
call {
function {
identifier {
@@ -132,7 +132,7 @@ compilation_unit {
}
arguments {
index {
aggregate {
object {
identifier {
name: "c"
}
@@ -148,7 +148,7 @@ compilation_unit {
}
arguments {
index {
aggregate {
object {
identifier {
name: "c"
}
@@ -280,9 +280,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "U"
}
@@ -301,9 +301,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "U"
}
@@ -412,12 +412,12 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
field_access {
object {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -429,9 +429,9 @@ compilation_unit {
argument {
tuple_literal {
fields {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "other"
}
@@ -448,12 +448,12 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
field_access {
object {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -465,9 +465,9 @@ compilation_unit {
argument {
tuple_literal {
fields {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "other"
}
@@ -557,9 +557,9 @@ compilation_unit {
init {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "E"
}
@@ -584,9 +584,9 @@ compilation_unit {
rhs {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "total"
}
@@ -616,9 +616,9 @@ compilation_unit {
rhs {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "total"
}
@@ -941,9 +941,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "r"
}
@@ -951,9 +951,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "r"
}
@@ -159,9 +159,9 @@ compilation_unit {
fields {
call {
function {
field_access {
simple_member_access {
field: "Two"
aggregate {
object {
identifier {
name: "Ints"
}
@@ -194,9 +194,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -204,9 +204,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -222,9 +222,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -232,9 +232,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -300,9 +300,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -323,9 +323,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -424,9 +424,9 @@ compilation_unit {
}
}
init {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -447,9 +447,9 @@ compilation_unit {
}
}
init {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
call {
function {
identifier {
@@ -637,9 +637,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -280,9 +280,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "U"
}
@@ -301,9 +301,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "U"
}
@@ -412,12 +412,12 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
field_access {
object {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -429,9 +429,9 @@ compilation_unit {
argument {
tuple_literal {
fields {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "other"
}
@@ -448,12 +448,12 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
field_access {
object {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -465,9 +465,9 @@ compilation_unit {
argument {
tuple_literal {
fields {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "other"
}
@@ -557,9 +557,9 @@ compilation_unit {
init {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "E"
}
@@ -584,9 +584,9 @@ compilation_unit {
rhs {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "total"
}
@@ -616,9 +616,9 @@ compilation_unit {
rhs {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "total"
}
@@ -822,9 +822,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "r"
}
@@ -832,9 +832,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "r"
}
@@ -574,9 +574,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -584,9 +584,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -602,9 +602,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -612,9 +612,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -680,9 +680,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -703,9 +703,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -877,14 +877,14 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -896,9 +896,9 @@ compilation_unit {
fields {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "U"
}
@@ -920,14 +920,14 @@ compilation_unit {
argument {
tuple_literal {
fields {
field_access {
simple_member_access {
field: "v"
aggregate {
object {
call {
function {
field_access {
simple_member_access {
field: "Hold"
aggregate {
object {
identifier {
name: "a"
}
@@ -1054,9 +1054,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -323,9 +323,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -333,9 +333,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -351,9 +351,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -361,9 +361,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -453,9 +453,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -476,9 +476,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -556,14 +556,14 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -575,9 +575,9 @@ compilation_unit {
fields {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "T"
}
@@ -734,9 +734,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -167,9 +167,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -177,9 +177,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -195,9 +195,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -205,9 +205,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -301,9 +301,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Op"
aggregate {
object {
identifier {
name: "a"
}
@@ -465,9 +465,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -475,9 +475,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "p"
}
@@ -110,9 +110,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "T"
}
@@ -131,9 +131,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "T"
}
@@ -200,12 +200,12 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
field_access {
object {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -217,9 +217,9 @@ compilation_unit {
argument {
tuple_literal {
fields {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "p"
}
@@ -276,9 +276,9 @@ compilation_unit {
statements {
return_statement {
expression {
field_access {
simple_member_access {
field: "SumXY"
aggregate {
object {
call {
function {
identifier {
@@ -491,9 +491,9 @@ compilation_unit {
init {
call {
function {
field_access {
simple_member_access {
field: "Origin"
aggregate {
object {
call {
function {
identifier {
@@ -527,9 +527,9 @@ compilation_unit {
function {
call {
function {
field_access {
simple_member_access {
field: "SumFn"
aggregate {
object {
identifier {
name: "p"
}
@@ -110,9 +110,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "T"
}
@@ -131,9 +131,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "T"
}
@@ -213,9 +213,9 @@ compilation_unit {
fields {
name: "x"
expression {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -226,9 +226,9 @@ compilation_unit {
fields {
name: "y"
expression {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -287,12 +287,12 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
field_access {
object {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -304,9 +304,9 @@ compilation_unit {
argument {
tuple_literal {
fields {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -510,9 +510,9 @@ compilation_unit {
init {
call {
function {
field_access {
simple_member_access {
field: "Origin"
aggregate {
object {
call {
function {
identifier {
@@ -544,14 +544,14 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "SumXY"
aggregate {
object {
call {
function {
field_access {
simple_member_access {
field: "Clone"
aggregate {
object {
identifier {
name: "p"
}
@@ -192,9 +192,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -202,9 +202,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -220,9 +220,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -230,9 +230,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -298,9 +298,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -321,9 +321,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -440,9 +440,9 @@ compilation_unit {
}
}
init {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -478,9 +478,9 @@ compilation_unit {
}
}
init {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
call {
function {
identifier {
@@ -668,9 +668,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -248,9 +248,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -258,9 +258,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -276,9 +276,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -286,9 +286,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -354,9 +354,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -377,9 +377,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -459,14 +459,14 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -478,9 +478,9 @@ compilation_unit {
fields {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "T"
}
@@ -613,9 +613,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -194,9 +194,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -204,9 +204,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -222,9 +222,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -232,9 +232,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -300,9 +300,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -323,9 +323,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -424,9 +424,9 @@ compilation_unit {
}
}
init {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -447,9 +447,9 @@ compilation_unit {
}
}
init {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
call {
function {
identifier {
@@ -637,9 +637,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -178,9 +178,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "U"
}
@@ -199,9 +199,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "U"
}
@@ -291,9 +291,9 @@ compilation_unit {
fields {
name: "x"
expression {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "other"
}
@@ -304,9 +304,9 @@ compilation_unit {
fields {
name: "y"
expression {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "other"
}
@@ -375,12 +375,12 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
field_access {
object {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "other"
}
@@ -392,9 +392,9 @@ compilation_unit {
argument {
tuple_literal {
fields {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "other"
}
@@ -192,9 +192,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -202,9 +202,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -220,9 +220,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -230,9 +230,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -298,9 +298,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -321,9 +321,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -403,9 +403,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
identifier {
name: "c"
}
@@ -505,9 +505,9 @@ compilation_unit {
fields {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -680,9 +680,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -75,9 +75,9 @@ compilation_unit {
statements {
return_statement {
expression {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -153,9 +153,9 @@ compilation_unit {
init {
call {
function {
field_access {
simple_member_access {
field: "Origin"
aggregate {
object {
identifier {
name: "Point"
}
@@ -175,9 +175,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "GetX"
aggregate {
object {
identifier {
name: "p"
}
@@ -275,9 +275,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -285,9 +285,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -303,9 +303,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -313,9 +313,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -381,9 +381,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -404,9 +404,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -484,14 +484,14 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -503,9 +503,9 @@ compilation_unit {
fields {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "T"
}
@@ -662,9 +662,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -90,9 +90,9 @@ compilation_unit {
statements {
return_statement {
expression {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -193,9 +193,9 @@ compilation_unit {
init {
call {
function {
field_access {
simple_member_access {
field: "Origin"
aggregate {
object {
call {
function {
identifier {
@@ -232,9 +232,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "GetX"
aggregate {
object {
identifier {
name: "p"
}
@@ -116,9 +116,9 @@ compilation_unit {
statements {
return_statement {
expression {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -219,9 +219,9 @@ compilation_unit {
init {
call {
function {
field_access {
simple_member_access {
field: "Origin"
aggregate {
object {
call {
function {
identifier {
@@ -258,9 +258,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "GetX"
aggregate {
object {
identifier {
name: "p"
}
@@ -248,9 +248,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -258,9 +258,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -276,9 +276,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -286,9 +286,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -354,9 +354,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -377,9 +377,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -459,14 +459,14 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -478,9 +478,9 @@ compilation_unit {
fields {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "T"
}
@@ -613,9 +613,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -192,9 +192,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -202,9 +202,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -220,9 +220,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -230,9 +230,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -298,9 +298,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -321,9 +321,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -448,9 +448,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -458,9 +458,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -486,9 +486,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -496,9 +496,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -574,9 +574,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -607,9 +607,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -696,9 +696,9 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
identifier {
name: "c"
}
@@ -817,9 +817,9 @@ compilation_unit {
fields {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -858,9 +858,9 @@ compilation_unit {
fields {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "b"
}
@@ -1056,9 +1056,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "q"
}
@@ -1066,9 +1066,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
@@ -248,9 +248,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -258,9 +258,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "b"
}
@@ -276,9 +276,9 @@ compilation_unit {
primitive_operator {
op: Add
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -286,9 +286,9 @@ compilation_unit {
}
}
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "b"
}
@@ -354,9 +354,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "me"
}
@@ -377,9 +377,9 @@ compilation_unit {
primitive_operator {
op: Mul
arguments {
field_access {
simple_member_access {
field: "y"
aggregate {
object {
identifier {
name: "me"
}
@@ -459,14 +459,14 @@ compilation_unit {
expression {
call {
function {
field_access {
simple_member_access {
field: "Scale"
aggregate {
object {
call {
function {
field_access {
simple_member_access {
field: "Add"
aggregate {
object {
identifier {
name: "a"
}
@@ -478,9 +478,9 @@ compilation_unit {
fields {
call {
function {
field_access {
simple_member_access {
field: "Zero"
aggregate {
object {
identifier {
name: "T"
}
@@ -613,9 +613,9 @@ compilation_unit {
primitive_operator {
op: Sub
arguments {
field_access {
simple_member_access {
field: "x"
aggregate {
object {
identifier {
name: "p"
}
+2 -2
View File
@@ -24,8 +24,8 @@ auto Heap::AllocateValue(Nonnull<const Value*> v) -> AllocationId {
auto Heap::Read(const Address& a, SourceLocation source_loc) const
-> ErrorOr<Nonnull<const Value*>> {
CARBON_RETURN_IF_ERROR(this->CheckAlive(a.allocation_, source_loc));
return values_[a.allocation_.index_]->GetField(arena_, a.field_path_,
source_loc);
return values_[a.allocation_.index_]->GetMember(arena_, a.field_path_,
source_loc);
}
auto Heap::Write(const Address& a, Nonnull<const Value*> v,
+24 -24
View File
@@ -322,23 +322,23 @@ auto Interpreter::StepLvalue() -> ErrorOr<Success> {
CARBON_CHECK(isa<LValue>(value)) << *value;
return todo_.FinishAction(value);
}
case ExpressionKind::FieldAccessExpression: {
case ExpressionKind::SimpleMemberAccessExpression: {
if (act.pos() == 0) {
// { {e.f :: C, E, F} :: S, H}
// -> { e :: [].f :: C, E, F} :: S, H}
return todo_.Spawn(std::make_unique<LValAction>(
&cast<FieldAccessExpression>(exp).aggregate()));
&cast<SimpleMemberAccessExpression>(exp).object()));
} else {
// { v :: [].f :: C, E, F} :: S, H}
// -> { { &v.f :: C, E, F} :: S, H }
Address aggregate = cast<LValue>(*act.results()[0]).address();
Address field = aggregate.SubobjectAddress(
cast<FieldAccessExpression>(exp).field());
return todo_.FinishAction(arena_->New<LValue>(field));
Address object = cast<LValue>(*act.results()[0]).address();
Address member = object.SubobjectAddress(
cast<SimpleMemberAccessExpression>(exp).member());
return todo_.FinishAction(arena_->New<LValue>(member));
}
}
case ExpressionKind::CompoundFieldAccessExpression: {
const auto& access = cast<CompoundFieldAccessExpression>(exp);
case ExpressionKind::CompoundMemberAccessExpression: {
const auto& access = cast<CompoundMemberAccessExpression>(exp);
if (act.pos() == 0) {
return todo_.Spawn(std::make_unique<LValAction>(&access.object()));
} else {
@@ -357,8 +357,8 @@ auto Interpreter::StepLvalue() -> ErrorOr<Success> {
if (act.pos() == 0) {
// { {e[i] :: C, E, F} :: S, H}
// -> { e :: [][i] :: C, E, F} :: S, H}
return todo_.Spawn(std::make_unique<LValAction>(
&cast<IndexExpression>(exp).aggregate()));
return todo_.Spawn(
std::make_unique<LValAction>(&cast<IndexExpression>(exp).object()));
} else if (act.pos() == 1) {
return todo_.Spawn(std::make_unique<ExpressionAction>(
@@ -366,10 +366,10 @@ auto Interpreter::StepLvalue() -> ErrorOr<Success> {
} else {
// { v :: [][i] :: C, E, F} :: S, H}
// -> { { &v[i] :: C, E, F} :: S, H }
Address aggregate = cast<LValue>(*act.results()[0]).address();
Address object = cast<LValue>(*act.results()[0]).address();
std::string f =
std::to_string(cast<IntValue>(*act.results()[1]).value());
Address field = aggregate.SubobjectAddress(f);
Address field = object.SubobjectAddress(f);
return todo_.FinishAction(arena_->New<LValue>(field));
}
}
@@ -749,7 +749,7 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
// { { e[i] :: C, E, F} :: S, H}
// -> { { e :: [][i] :: C, E, F} :: S, H}
return todo_.Spawn(std::make_unique<ExpressionAction>(
&cast<IndexExpression>(exp).aggregate()));
&cast<IndexExpression>(exp).object()));
} else if (act.pos() == 1) {
return todo_.Spawn(std::make_unique<ExpressionAction>(
&cast<IndexExpression>(exp).offset()));
@@ -801,11 +801,11 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
return todo_.FinishAction(arena_->New<StructType>(std::move(fields)));
}
}
case ExpressionKind::FieldAccessExpression: {
const auto& access = cast<FieldAccessExpression>(exp);
case ExpressionKind::SimpleMemberAccessExpression: {
const auto& access = cast<SimpleMemberAccessExpression>(exp);
if (act.pos() == 0) {
return todo_.Spawn(
std::make_unique<ExpressionAction>(&access.aggregate()));
std::make_unique<ExpressionAction>(&access.object()));
} else {
if (const auto* member_name_type =
dyn_cast<TypeOfMemberName>(&access.static_type())) {
@@ -841,17 +841,17 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
access.source_loc()));
witness = cast<Witness>(witness_value);
}
FieldPath::Component field(access.field(), witness);
FieldPath::Component member(access.member(), witness);
CARBON_ASSIGN_OR_RETURN(
Nonnull<const Value*> member,
act.results()[0]->GetField(arena_, FieldPath(field),
exp.source_loc()));
return todo_.FinishAction(member);
Nonnull<const Value*> member_value,
act.results()[0]->GetMember(arena_, FieldPath(member),
exp.source_loc()));
return todo_.FinishAction(member_value);
}
}
}
case ExpressionKind::CompoundFieldAccessExpression: {
const auto& access = cast<CompoundFieldAccessExpression>(exp);
case ExpressionKind::CompoundMemberAccessExpression: {
const auto& access = cast<CompoundMemberAccessExpression>(exp);
bool forming_member_name = isa<TypeOfMemberName>(&access.static_type());
if (act.pos() == 0) {
// First, evaluate the first operand.
@@ -894,7 +894,7 @@ auto Interpreter::StepExp() -> ErrorOr<Success> {
FieldPath::Component field(access.member().name(), witness);
CARBON_ASSIGN_OR_RETURN(
Nonnull<const Value*> member,
object->GetField(arena_, FieldPath(field), exp.source_loc()));
object->GetMember(arena_, FieldPath(field), exp.source_loc()));
return todo_.FinishAction(member);
}
}
+5 -5
View File
@@ -111,20 +111,20 @@ static auto ResolveNames(Expression& expression,
ResolveNames(fun_type.return_type(), enclosing_scope));
break;
}
case ExpressionKind::FieldAccessExpression:
case ExpressionKind::SimpleMemberAccessExpression:
CARBON_RETURN_IF_ERROR(
ResolveNames(cast<FieldAccessExpression>(expression).aggregate(),
ResolveNames(cast<SimpleMemberAccessExpression>(expression).object(),
enclosing_scope));
break;
case ExpressionKind::CompoundFieldAccessExpression: {
auto& access = cast<CompoundFieldAccessExpression>(expression);
case ExpressionKind::CompoundMemberAccessExpression: {
auto& access = cast<CompoundMemberAccessExpression>(expression);
CARBON_RETURN_IF_ERROR(ResolveNames(access.object(), enclosing_scope));
CARBON_RETURN_IF_ERROR(ResolveNames(access.path(), enclosing_scope));
break;
}
case ExpressionKind::IndexExpression: {
auto& index = cast<IndexExpression>(expression);
CARBON_RETURN_IF_ERROR(ResolveNames(index.aggregate(), enclosing_scope));
CARBON_RETURN_IF_ERROR(ResolveNames(index.object(), enclosing_scope));
CARBON_RETURN_IF_ERROR(ResolveNames(index.offset(), enclosing_scope));
break;
}
+48 -49
View File
@@ -503,11 +503,11 @@ auto TypeChecker::BuildBuiltinMethodCall(const ImplScope& impl_scope,
Nonnull<Expression*> iface_expr = arena_->New<ValueLiteral>(
source_loc, iface_type, arena_->New<TypeOfInterfaceType>(iface_type),
ValueCategory::Let);
Nonnull<Expression*> iface_member =
arena_->New<FieldAccessExpression>(source_loc, iface_expr, method.name);
Nonnull<Expression*> iface_member = arena_->New<SimpleMemberAccessExpression>(
source_loc, iface_expr, method.name);
Nonnull<Expression*> method_access =
arena_->New<CompoundFieldAccessExpression>(source_loc, source,
iface_member);
arena_->New<CompoundMemberAccessExpression>(source_loc, source,
iface_member);
Nonnull<Expression*> call_args =
arena_->New<TupleLiteral>(source_loc, method.arguments);
Nonnull<Expression*> call =
@@ -1051,12 +1051,12 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
<< " generated during type checking";
case ExpressionKind::IndexExpression: {
auto& index = cast<IndexExpression>(*e);
CARBON_RETURN_IF_ERROR(TypeCheckExp(&index.aggregate(), impl_scope));
CARBON_RETURN_IF_ERROR(TypeCheckExp(&index.object(), impl_scope));
CARBON_RETURN_IF_ERROR(TypeCheckExp(&index.offset(), impl_scope));
const Value& aggregate_type = index.aggregate().static_type();
switch (aggregate_type.kind()) {
const Value& object_type = index.object().static_type();
switch (object_type.kind()) {
case Value::Kind::TupleValue: {
const auto& tuple_type = cast<TupleValue>(aggregate_type);
const auto& tuple_type = cast<TupleValue>(object_type);
CARBON_RETURN_IF_ERROR(ExpectExactType(
index.offset().source_loc(), "tuple index",
arena_->New<IntType>(), &index.offset().static_type()));
@@ -1070,7 +1070,7 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
<< tuple_type;
}
index.set_static_type(tuple_type.elements()[i]);
index.set_value_category(index.aggregate().value_category());
index.set_value_category(index.object().value_category());
return Success();
}
case Value::Kind::StaticArrayType: {
@@ -1078,8 +1078,8 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
index.offset().source_loc(), "array index",
arena_->New<IntType>(), &index.offset().static_type()));
index.set_static_type(
&cast<StaticArrayType>(aggregate_type).element_type());
index.set_value_category(index.aggregate().value_category());
&cast<StaticArrayType>(object_type).element_type());
index.set_value_category(index.object().value_category());
return Success();
}
default:
@@ -1127,31 +1127,31 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
e->set_value_category(ValueCategory::Let);
return Success();
}
case ExpressionKind::FieldAccessExpression: {
auto& access = cast<FieldAccessExpression>(*e);
CARBON_RETURN_IF_ERROR(TypeCheckExp(&access.aggregate(), impl_scope));
const Value& aggregate_type = access.aggregate().static_type();
switch (aggregate_type.kind()) {
case ExpressionKind::SimpleMemberAccessExpression: {
auto& access = cast<SimpleMemberAccessExpression>(*e);
CARBON_RETURN_IF_ERROR(TypeCheckExp(&access.object(), impl_scope));
const Value& object_type = access.object().static_type();
switch (object_type.kind()) {
case Value::Kind::StructType: {
const auto& struct_type = cast<StructType>(aggregate_type);
const auto& struct_type = cast<StructType>(object_type);
for (const auto& [field_name, field_type] : struct_type.fields()) {
if (access.field() == field_name) {
if (access.member() == field_name) {
access.set_static_type(field_type);
access.set_value_category(access.aggregate().value_category());
access.set_value_category(access.object().value_category());
return Success();
}
}
return CompilationError(access.source_loc())
<< "struct " << struct_type << " does not have a field named "
<< access.field();
<< access.member();
}
case Value::Kind::TypeType: {
CARBON_ASSIGN_OR_RETURN(
Nonnull<const Value*> type,
InterpExp(&access.aggregate(), arena_, trace_stream_));
InterpExp(&access.object(), arena_, trace_stream_));
if (const auto* struct_type = dyn_cast<StructType>(type)) {
for (const auto& field : struct_type->fields()) {
if (access.field() == field.name) {
if (access.member() == field.name) {
access.set_static_type(
arena_->New<TypeOfMemberName>(Member(&field)));
access.set_value_category(ValueCategory::Let);
@@ -1160,7 +1160,7 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
}
return CompilationError(access.source_loc())
<< "struct " << *struct_type
<< " does not have a field named " << access.field();
<< " does not have a field named " << access.member();
}
// TODO: We should handle all types here, not only structs. For
// example:
@@ -1175,22 +1175,22 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
<< "unsupported member access into type " << *type;
}
case Value::Kind::NominalClassType: {
const auto& t_class = cast<NominalClassType>(aggregate_type);
const auto& t_class = cast<NominalClassType>(object_type);
if (std::optional<Nonnull<const Declaration*>> member =
FindMember(access.field(), t_class.declaration().members());
FindMember(access.member(), t_class.declaration().members());
member.has_value()) {
Nonnull<const Value*> field_type =
Substitute(t_class.type_args(), &(*member)->static_type());
access.set_static_type(field_type);
switch ((*member)->kind()) {
case DeclarationKind::VariableDeclaration:
access.set_value_category(access.aggregate().value_category());
access.set_value_category(access.object().value_category());
break;
case DeclarationKind::FunctionDeclaration:
access.set_value_category(ValueCategory::Let);
break;
default:
CARBON_FATAL() << "member " << access.field()
CARBON_FATAL() << "member " << access.member()
<< " is not a field or method";
break;
}
@@ -1198,18 +1198,18 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
} else {
return CompilationError(e->source_loc())
<< "class " << t_class.declaration().name()
<< " does not have a field named " << access.field();
<< " does not have a field named " << access.member();
}
}
case Value::Kind::TypeOfChoiceType: {
const ChoiceType& choice =
cast<TypeOfChoiceType>(aggregate_type).choice_type();
cast<TypeOfChoiceType>(object_type).choice_type();
std::optional<Nonnull<const Value*>> parameter_types =
choice.FindAlternative(access.field());
choice.FindAlternative(access.member());
if (!parameter_types.has_value()) {
return CompilationError(e->source_loc())
<< "choice " << choice.name()
<< " does not have a field named " << access.field();
<< " does not have an alternative named " << access.member();
}
access.set_static_type(arena_->New<FunctionType>(
*parameter_types, llvm::None, &choice, llvm::None, llvm::None));
@@ -1218,9 +1218,9 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
}
case Value::Kind::TypeOfClassType: {
const NominalClassType& class_type =
cast<TypeOfClassType>(aggregate_type).class_type();
cast<TypeOfClassType>(object_type).class_type();
if (std::optional<Nonnull<const Declaration*>> member = FindMember(
access.field(), class_type.declaration().members());
access.member(), class_type.declaration().members());
member.has_value()) {
switch ((*member)->kind()) {
case DeclarationKind::FunctionDeclaration: {
@@ -1244,14 +1244,14 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
} else {
return CompilationError(access.source_loc())
<< class_type << " does not have a member named "
<< access.field();
<< access.member();
}
}
case Value::Kind::TypeOfInterfaceType: {
const InterfaceType& iface_type =
cast<TypeOfInterfaceType>(aggregate_type).interface_type();
cast<TypeOfInterfaceType>(object_type).interface_type();
if (std::optional<Nonnull<const Declaration*>> member = FindMember(
access.field(), iface_type.declaration().members());
access.member(), iface_type.declaration().members());
member.has_value()) {
access.set_static_type(
arena_->New<TypeOfMemberName>(Member(*member)));
@@ -1260,7 +1260,7 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
} else {
return CompilationError(access.source_loc())
<< iface_type << " does not have a member named "
<< access.field();
<< access.member();
}
}
case Value::Kind::VariableType: {
@@ -1268,14 +1268,14 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
// is a type variable. For example, `x.foo` where the type of
// `x` is `T` and `foo` and `T` implements an interface that
// includes `foo`.
const VariableType& var_type = cast<VariableType>(aggregate_type);
const VariableType& var_type = cast<VariableType>(object_type);
const Value& typeof_var = var_type.binding().static_type();
switch (typeof_var.kind()) {
case Value::Kind::InterfaceType: {
const auto& iface_type = cast<InterfaceType>(typeof_var);
const InterfaceDeclaration& iface_decl = iface_type.declaration();
if (std::optional<Nonnull<const Declaration*>> member =
FindMember(access.field(), iface_decl.members());
FindMember(access.member(), iface_decl.members());
member.has_value()) {
const Value& member_type = (*member)->static_type();
BindingMap binding_map = iface_type.args();
@@ -1288,14 +1288,14 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
return Success();
} else {
return CompilationError(e->source_loc())
<< "field access, " << access.field() << " not in "
<< "member access, " << access.member() << " not in "
<< iface_decl.name();
}
break;
}
default:
return CompilationError(e->source_loc())
<< "field access, unexpected " << aggregate_type
<< "member access, unexpected " << object_type
<< " of non-interface type " << typeof_var << " in " << *e;
}
break;
@@ -1307,12 +1307,12 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
// function of `T`.
CARBON_ASSIGN_OR_RETURN(
Nonnull<const Value*> var_addr,
InterpExp(&access.aggregate(), arena_, trace_stream_));
InterpExp(&access.object(), arena_, trace_stream_));
const VariableType& var_type = cast<VariableType>(*var_addr);
const InterfaceType& iface_type = cast<InterfaceType>(aggregate_type);
const InterfaceType& iface_type = cast<InterfaceType>(object_type);
const InterfaceDeclaration& iface_decl = iface_type.declaration();
if (std::optional<Nonnull<const Declaration*>> member =
FindMember(access.field(), iface_decl.members());
FindMember(access.member(), iface_decl.members());
member.has_value()) {
CARBON_CHECK(var_type.binding().impl_binding().has_value());
access.set_impl(*var_type.binding().impl_binding());
@@ -1344,19 +1344,18 @@ auto TypeChecker::TypeCheckExp(Nonnull<Expression*> e,
return Success();
} else {
return CompilationError(e->source_loc())
<< "field access, " << access.field() << " not in "
<< "member access, " << access.member() << " not in "
<< iface_decl.name();
}
break;
}
default:
return CompilationError(e->source_loc())
<< "field access, unexpected " << aggregate_type << " in "
<< *e;
<< "member access, unexpected " << object_type << " in " << *e;
}
}
case ExpressionKind::CompoundFieldAccessExpression: {
auto& access = cast<CompoundFieldAccessExpression>(*e);
case ExpressionKind::CompoundMemberAccessExpression: {
auto& access = cast<CompoundMemberAccessExpression>(*e);
CARBON_RETURN_IF_ERROR(TypeCheckExp(&access.object(), impl_scope));
CARBON_RETURN_IF_ERROR(TypeCheckExp(&access.path(), impl_scope));
if (!isa<TypeOfMemberName>(access.path().static_type())) {
+4 -3
View File
@@ -130,12 +130,13 @@ static auto GetMember(Nonnull<Arena*> arena, Nonnull<const Value*> v,
}
}
auto Value::GetField(Nonnull<Arena*> arena, const FieldPath& path,
SourceLocation source_loc) const
auto Value::GetMember(Nonnull<Arena*> arena, const FieldPath& path,
SourceLocation source_loc) const
-> ErrorOr<Nonnull<const Value*>> {
Nonnull<const Value*> value(this);
for (const FieldPath::Component& field : path.components_) {
CARBON_ASSIGN_OR_RETURN(value, GetMember(arena, value, field, source_loc));
CARBON_ASSIGN_OR_RETURN(value,
Carbon::GetMember(arena, value, field, source_loc));
}
return value;
}
+2 -2
View File
@@ -81,8 +81,8 @@ class Value {
// Returns the sub-Value specified by `path`, which must be a valid field
// path for *this.
auto GetField(Nonnull<Arena*> arena, const FieldPath& path,
SourceLocation source_loc) const
auto GetMember(Nonnull<Arena*> arena, const FieldPath& path,
SourceLocation source_loc) const
-> ErrorOr<Nonnull<const Value*>>;
// Returns a copy of *this, but with the sub-Value specified by `path`
+6 -3
View File
@@ -327,11 +327,14 @@ primary_expression:
postfix_expression:
primary_expression
| postfix_expression designator
{ $$ = arena->New<FieldAccessExpression>(context.source_loc(), $1, $2); }
{
$$ = arena->New<SimpleMemberAccessExpression>(context.source_loc(), $1,
$2);
}
| postfix_expression PERIOD LEFT_PARENTHESIS expression RIGHT_PARENTHESIS
{
$$ = arena->New<CompoundFieldAccessExpression>(context.source_loc(), $1,
$4);
$$ = arena->New<CompoundMemberAccessExpression>(context.source_loc(), $1,
$4);
}
| postfix_expression LEFT_SQUARE_BRACKET expression RIGHT_SQUARE_BRACKET
{ $$ = arena->New<IndexExpression>(context.source_loc(), $1, $3); }
@@ -10,11 +10,11 @@
package ExplorerTest api;
fn BadFieldAccess[T:! Type](a: T) -> T {
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_field_access_on_generic.carbon:[[@LINE+1]]: field access, unexpected T:! Type of non-interface type Type in a.x
fn BadSimpleMemberAccess[T:! Type](a: T) -> T {
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_field_access_on_generic.carbon:[[@LINE+1]]: member access, unexpected T:! Type of non-interface type Type in a.x
return a.x;
}
fn Main() -> i32 {
return BadFieldAccess(0);
return BadSimpleMemberAccess(0);
}
@@ -15,7 +15,7 @@ interface Vector {
}
fn ScaleGeneric[T:! Vector](a: T, s: i32) -> T {
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/interface/fail_interface_missing_member.carbon:[[@LINE+1]]: field access, Scale not in Vector
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/interface/fail_interface_missing_member.carbon:[[@LINE+1]]: member access, Scale not in Vector
return a.Scale(s);
}