Skip to content

Commit

Permalink
Python progress - getting the file picked up at least
Browse files Browse the repository at this point in the history
  • Loading branch information
robin-aws committed Nov 15, 2023
1 parent ac6fe4e commit 29206be
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 6 deletions.
8 changes: 8 additions & 0 deletions Source/DafnyCore/AST/ShouldCompileOrVerify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ public static bool ShouldCompile(this ModuleDefinition module, CompilationData p
// https://github.com/dafny-lang/dafny/issues/4009
return true;
}

if (program.Options.Backend?.TargetId != "lib") {
bool compileIt = true;
if (Attributes.ContainsBool(module.Attributes, "compile", ref compileIt) && !compileIt) {
return false;
}
}

return program.UrisToCompile.Contains(module.Tok.Uri);
}

Expand Down
3 changes: 3 additions & 0 deletions Source/DafnyCore/Compilers/Python/Compiler-python.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ protected override void EmitHeader(Program program, ConcreteSyntaxTree wr) {
if (Options.IncludeRuntime) {
EmitRuntimeSource("DafnyRuntimePython", wr);
}
if (Options.Get(CommonOptionBag.UseStandardLibraries)) {
EmitRuntimeSource("DafnyStandardLibraries_py", wr);
}

Imports.Add(DafnyRuntimeModule);
EmitImports(null, wr);
Expand Down
4 changes: 4 additions & 0 deletions Source/DafnyPipeline/DafnyPipeline.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
<LinkBase>DafnyStandardLibraries_go</LinkBase>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="..\DafnyStandardLibraries\src\**\*.py">
<LinkBase>DafnyStandardLibraries_py</LinkBase>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>

<EmbeddedResource Include="..\DafnyStandardLibraries\binaries\DafnyStandardLibraries.doo">
<LogicalName>DafnyStandardLibraries.doo</LogicalName>
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*******************************************************************************
* Copyright by the contributors to the Dafny Project
* SPDX-License-Identifier: MIT
*******************************************************************************/

/*
* Private API - these are intentionally not exported from the module and should not be used elsewhere
*/
module {:compile false} DafnyStdLibs.FileIOInternalExterns {
method
{:extern}
INTERNAL_ReadBytesFromFile(path: string)
returns (isError: bool, bytesRead: seq<bv8>, errorMsg: string)

method
{:extern}
INTERNAL_WriteBytesToFile(path: string, bytes: seq<bv8>)
returns (isError: bool, errorMsg: string)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Module: DafnyStdLibs_FileIOInternalExterns

@staticmethod
def INTERNAL_ReadBytesFromFile(i):
return i * i

0 comments on commit 29206be

Please sign in to comment.