Skip to content

Commit

Permalink
Nagini Converting
Browse files Browse the repository at this point in the history
  • Loading branch information
alex28sh committed Jul 12, 2024
1 parent 0860638 commit a59b15d
Show file tree
Hide file tree
Showing 28 changed files with 518 additions and 80 deletions.
Empty file modified CODE_OF_CONDUCT.md
100644 → 100755
Empty file.
Empty file modified CONTRIBUTING.md
100644 → 100755
Empty file.
Empty file modified DAFNY.ORG.txt
100644 → 100755
Empty file.
Empty file modified INSTALL.md
100644 → 100755
Empty file.
Empty file modified LICENSE.txt
100644 → 100755
Empty file.
Empty file modified Makefile
100644 → 100755
Empty file.
Empty file modified NOTICES.txt
100644 → 100755
Empty file.
Empty file modified README.md
100644 → 100755
Empty file.
Empty file modified RELEASE_NOTES.md
100644 → 100755
Empty file.
Empty file modified SECURITY.md
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions Scripts/quicktest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ $DAFNY build -t:go c.dfy | diff - $tmp || exit 1
./c | diff - $tmpx || exit 1
(cd c-go; GO111MODULE=auto GOPATH=`pwd` go run src/c.go) | diff - $tmpx || exit 1
echo Building with Python
echo $DAFNY
$DAFNY build -t:py c.dfy | diff - $tmp || exit 1
python c-py/c.py | diff - $tmpx || exit 1
echo Building with Rust
Expand Down
38 changes: 38 additions & 0 deletions Source/Dafny.sln
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,32 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DafnyDriver.Test", "DafnyDr
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DafnyCore.Test", "DafnyCore.Test\DafnyCore.Test.csproj", "{33C29F26-A27B-474D-B436-83EA615B09FC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Boogie", "Boogie", "{60332269-9C5D-465E-8582-01F9B738BD90}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseTypes", "..\boogie\Source\BaseTypes\BaseTypes.csproj", "{68721962-0D91-4355-BC94-BE1CCBD30E47}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractInterpretation", "..\boogie\Source\AbstractInterpretation\AbstractInterpretation.csproj", "{2A6B36F4-9F15-459A-8EDB-5BAEED98FE17}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeContractsExtender", "..\boogie\Source\CodeContractsExtender\CodeContractsExtender.csproj", "{09662044-5640-4785-92E3-2F7CDBA4DDB2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Concurrency", "..\boogie\Source\Concurrency\Concurrency.csproj", "{DA8A9BA8-9BBA-4C64-9736-FD967517DCA9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "..\boogie\Source\Core\Core.csproj", "{2BF5ECCA-24B2-4A4B-86B6-D0DB17331109}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExecutionEngine", "..\boogie\Source\ExecutionEngine\ExecutionEngine.csproj", "{0145DC89-7243-41F8-AB3E-F716F04E9BFF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Graph", "..\boogie\Source\Graph\Graph.csproj", "{05DE24BB-D639-40C4-894F-701652F51559}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Houdini", "..\boogie\Source\Houdini\Houdini.csproj", "{51D6B0D1-2D15-40A3-80F4-E32A5C07B0A6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "..\boogie\Source\Model\Model.csproj", "{D97C23B6-FB4A-4450-930E-58EC83D308A0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMTLib", "..\boogie\Source\Provers\SMTLib\SMTLib.csproj", "{0EC245EE-54DD-4AE3-9C2E-34E67EE28B9F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VCExpr", "..\boogie\Source\VCExpr\VCExpr.csproj", "{E760E37E-0257-4C96-89C4-722F85BABDBB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VCGeneration", "..\boogie\Source\VCGeneration\VCGeneration.csproj", "{1EE372AA-4FF9-47FB-9C04-18CBF219F6E8}"
EndProject
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -138,5 +164,17 @@ Global
SolutionGuid = {280F572B-D27A-4613-998F-00B6FFE01187}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{68721962-0D91-4355-BC94-BE1CCBD30E47} = {60332269-9C5D-465E-8582-01F9B738BD90}
{2A6B36F4-9F15-459A-8EDB-5BAEED98FE17} = {60332269-9C5D-465E-8582-01F9B738BD90}
{09662044-5640-4785-92E3-2F7CDBA4DDB2} = {60332269-9C5D-465E-8582-01F9B738BD90}
{DA8A9BA8-9BBA-4C64-9736-FD967517DCA9} = {60332269-9C5D-465E-8582-01F9B738BD90}
{2BF5ECCA-24B2-4A4B-86B6-D0DB17331109} = {60332269-9C5D-465E-8582-01F9B738BD90}
{0145DC89-7243-41F8-AB3E-F716F04E9BFF} = {60332269-9C5D-465E-8582-01F9B738BD90}
{05DE24BB-D639-40C4-894F-701652F51559} = {60332269-9C5D-465E-8582-01F9B738BD90}
{51D6B0D1-2D15-40A3-80F4-E32A5C07B0A6} = {60332269-9C5D-465E-8582-01F9B738BD90}
{D97C23B6-FB4A-4450-930E-58EC83D308A0} = {60332269-9C5D-465E-8582-01F9B738BD90}
{0EC245EE-54DD-4AE3-9C2E-34E67EE28B9F} = {60332269-9C5D-465E-8582-01F9B738BD90}
{E760E37E-0257-4C96-89C4-722F85BABDBB} = {60332269-9C5D-465E-8582-01F9B738BD90}
{1EE372AA-4FF9-47FB-9C04-18CBF219F6E8} = {60332269-9C5D-465E-8582-01F9B738BD90}
EndGlobalSection
EndGlobal
10 changes: 8 additions & 2 deletions Source/DafnyCore/AST/Statements/Assignment/LocalVariable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,14 @@ public string AssignUniqueName(FreshIdGenerator generator) {
sanitizedName ??= $"_{IVariable.CompileNameIdGenerator.FreshNumericId()}_{SanitizedNameShadowable}";

string compileName;
public string CompileName =>
compileName ??= SanitizedName;
public string CompileName {
get {
return compileName ??= SanitizedName;
}
set {
compileName = value;
}
}

// TODO rename and update comment? Or make it nullable?
public readonly Type SyntacticType; // this is the type mentioned in the declaration, if any
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyCore/AST/Types/UserDefinedType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void ObjectInvariant() {
}

public readonly Expression NamePath; // either NameSegment or ExprDotName (with the inner expression satisfying this same constraint)
public readonly string Name;
public string Name;
[Rep]

public string FullName {
Expand Down
3 changes: 2 additions & 1 deletion Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2046,7 +2046,7 @@ protected override void EmitHalt(IToken tok, Expression/*?*/ messageExpr, Concre
}

protected override ConcreteSyntaxTree EmitForStmt(IToken tok, IVariable loopIndex, bool goingUp, string /*?*/ endVarName,
List<Statement> body, LList<Label> labels, ConcreteSyntaxTree wr) {
List<Statement> body, LList<Label> labels, out ConcreteSyntaxTree annotWriter, ConcreteSyntaxTree wr) {

wr.Write($"for ({TypeName(loopIndex.Type, wr, tok)} {loopIndex.CompileName} = ");
var startWr = wr.Fork();
Expand All @@ -2062,6 +2062,7 @@ protected override ConcreteSyntaxTree EmitForStmt(IToken tok, IVariable loopInde
bodyWr.WriteLine($"{loopIndex.CompileName}--;");
}
bodyWr = EmitContinueLabel(labels, bodyWr);
annotWriter = bodyWr.Fork();
TrStmtList(body, bodyWr);

return startWr;
Expand Down
2 changes: 1 addition & 1 deletion Source/DafnyCore/Backends/Cplusplus/CppCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ protected override void EmitHalt(IToken tok, Expression messageExpr, ConcreteSyn
}

protected override ConcreteSyntaxTree EmitForStmt(IToken tok, IVariable loopIndex, bool goingUp, string /*?*/ endVarName,
List<Statement> body, LList<Label> labels, ConcreteSyntaxTree wr) {
List<Statement> body, LList<Label> labels, out ConcreteSyntaxTree annotWriter, ConcreteSyntaxTree wr) {
throw new UnsupportedFeatureException(tok, Feature.ForLoops, "for loops have not yet been implemented");
}

Expand Down
6 changes: 4 additions & 2 deletions Source/DafnyCore/Backends/Dafny/DafnyCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1170,15 +1170,17 @@ protected override ConcreteSyntaxTree EmitBlock(ConcreteSyntaxTree wr) {
}

protected override ConcreteSyntaxTree EmitForStmt(IToken tok, IVariable loopIndex, bool goingUp, string endVarName,
List<Statement> body, LList<Label> labels, ConcreteSyntaxTree wr) {
List<Statement> body, LList<Label> labels, out ConcreteSyntaxTree annotWriter, ConcreteSyntaxTree wr) {
AddUnsupportedFeature(tok, Feature.ForLoops);
annotWriter = null;
return wr;
}

protected override ConcreteSyntaxTree CreateWhileLoop(out ConcreteSyntaxTree guardWriter, ConcreteSyntaxTree wr) {
protected override ConcreteSyntaxTree CreateWhileLoop(out ConcreteSyntaxTree guardWriter, out ConcreteSyntaxTree annotWriter, ConcreteSyntaxTree wr) {
if (wr is BuilderSyntaxTree<StatementContainer> statementContainer) {
var whileBuilder = statementContainer.Builder.While();
guardWriter = new BuilderSyntaxTree<ExprContainer>(whileBuilder, this);
annotWriter = guardWriter.Fork();
return new BuilderSyntaxTree<StatementContainer>(whileBuilder, this);
} else {
throw new InvalidOperationException();
Expand Down
6 changes: 4 additions & 2 deletions Source/DafnyCore/Backends/GoLang/GoCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2065,15 +2065,16 @@ protected override void EmitHalt(IToken tok, Expression messageExpr, ConcreteSyn
}
}

protected override ConcreteSyntaxTree CreateWhileLoop(out ConcreteSyntaxTree guardWriter, ConcreteSyntaxTree wr) {
protected override ConcreteSyntaxTree CreateWhileLoop(out ConcreteSyntaxTree guardWriter, out ConcreteSyntaxTree annotWriter, ConcreteSyntaxTree wr) {
wr.Write("for ");
guardWriter = wr.Fork();
var wBody = wr.NewBlock("");
annotWriter = wr.Fork();
return wBody;
}

protected override ConcreteSyntaxTree EmitForStmt(IToken tok, IVariable loopIndex, bool goingUp, string /*?*/ endVarName,
List<Statement> body, LList<Label> labels, ConcreteSyntaxTree wr) {
List<Statement> body, LList<Label> labels, out ConcreteSyntaxTree annotWriter, ConcreteSyntaxTree wr) {

wr.Write($"for {loopIndex.CompileName} := ");
var startWr = wr.Fork();
Expand Down Expand Up @@ -2109,6 +2110,7 @@ protected override ConcreteSyntaxTree EmitForStmt(IToken tok, IVariable loopInde
}
}
bodyWr = EmitContinueLabel(labels, bodyWr);
annotWriter = bodyWr.Fork();
TrStmtList(body, bodyWr);

return startWr;
Expand Down
3 changes: 2 additions & 1 deletion Source/DafnyCore/Backends/Java/JavaCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3823,7 +3823,7 @@ protected override ConcreteSyntaxTree CreateForLoop(string indexVar, Action<Conc
}

protected override ConcreteSyntaxTree EmitForStmt(IToken tok, IVariable loopIndex, bool goingUp, string /*?*/ endVarName,
List<Statement> body, LList<Label> labels, ConcreteSyntaxTree wr) {
List<Statement> body, LList<Label> labels, out ConcreteSyntaxTree annotWriter, ConcreteSyntaxTree wr) {

var nativeType = AsNativeType(loopIndex.Type);

Expand Down Expand Up @@ -3865,6 +3865,7 @@ protected override ConcreteSyntaxTree EmitForStmt(IToken tok, IVariable loopInde
}
}
bodyWr = EmitContinueLabel(labels, bodyWr);
annotWriter = bodyWr.Fork();
TrStmtList(body, bodyWr);

return startWr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ protected override void EmitHalt(IToken tok, Expression/*?*/ messageExpr, Concre
}

protected override ConcreteSyntaxTree EmitForStmt(IToken tok, IVariable loopIndex, bool goingUp, string /*?*/ endVarName,
List<Statement> body, LList<Label> labels, ConcreteSyntaxTree wr) {
List<Statement> body, LList<Label> labels, out ConcreteSyntaxTree annotWriter, ConcreteSyntaxTree wr) {

var nativeType = AsNativeType(loopIndex.Type);

Expand Down Expand Up @@ -1280,6 +1280,7 @@ protected override ConcreteSyntaxTree EmitForStmt(IToken tok, IVariable loopInde
}
}
bodyWr = EmitContinueLabel(labels, bodyWr);
annotWriter = bodyWr.Fork();
TrStmtList(body, bodyWr);

return startWr;
Expand Down
Loading

0 comments on commit a59b15d

Please sign in to comment.