Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Civl] Make atomic keyword on actions optional #866

Merged
merged 1 commit into from
Apr 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Source/Core/AST/Absy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2974,9 +2974,13 @@ public override void Resolve(ResolutionContext rc)
if (RefinedAction != null)
{
RefinedAction.Resolve(rc);
if (!HasMoverType)
{
MoverType = MoverType.Atomic;
}
if (RefinedAction.ActionDecl is { HasMoverType: false })
{
rc.Error(this, $"refined action {RefinedAction.ActionDecl.Name} must have a mover type");
RefinedAction.ActionDecl.MoverType = MoverType.Atomic;
}
}
if (InvariantAction != null)
Expand Down Expand Up @@ -3298,7 +3302,7 @@ public override void Resolve(ResolutionContext rc)
RefinedAction.Resolve(rc);
if (RefinedAction.ActionDecl is { HasMoverType: false })
{
rc.Error(this, $"refined action {RefinedAction.ActionDecl.Name} must have a mover type");
RefinedAction.ActionDecl.MoverType = MoverType.Atomic;
}
}

Expand Down
10 changes: 5 additions & 5 deletions Source/Core/BoogiePL.atg
Original file line number Diff line number Diff line change
Expand Up @@ -705,16 +705,16 @@ ActionDecl<bool isPure, out ActionDecl actionDecl, out Implementation impl, out
}
}
if (isAsync) {
if (moverType == MoverType.None)
{
this.SemErr("async action must have a mover type");
}
else if (outs.Count > 0)
if (outs.Count > 0)
{
this.SemErr("async action must not have output parameters");
}
else
{
if (moverType == MoverType.None)
{
moverType = MoverType.Atomic;
}
datatypeTypeCtorDecl = new DatatypeTypeCtorDecl(name, name.val, new List<TypeVariable>(), null);
var fields = ins.Select(v => new Formal(v.tok, new TypedIdent(v.TypedIdent.tok, v.Name, v.TypedIdent.Type), true, v.Attributes)).ToList<Variable>();
datatypeTypeCtorDecl.AddConstructor(name, name.val, fields);
Expand Down
10 changes: 5 additions & 5 deletions Source/Core/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -725,16 +725,16 @@ void ActionDecl(bool isPure, out ActionDecl actionDecl, out Implementation impl,
}
}
if (isAsync) {
if (moverType == MoverType.None)
{
this.SemErr("async action must have a mover type");
}
else if (outs.Count > 0)
if (outs.Count > 0)
{
this.SemErr("async action must not have output parameters");
}
else
{
if (moverType == MoverType.None)
{
moverType = MoverType.Atomic;
}
datatypeTypeCtorDecl = new DatatypeTypeCtorDecl(name, name.val, new List<TypeVariable>(), null);
var fields = ins.Select(v => new Formal(v.tok, new TypedIdent(v.TypedIdent.tok, v.Name, v.TypedIdent.Type), true, v.Attributes)).ToList<Variable>();
datatypeTypeCtorDecl.AddConstructor(name, name.val, fields);
Expand Down
Loading