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

Enhance Import printer #1487

Merged
merged 3 commits into from
Oct 19, 2021
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
11 changes: 8 additions & 3 deletions Source/Dafny/AST/Printer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,14 @@ public void PrintTopLevelDecls(List<TopLevelDecl> decls, int indent, List<Bpl.IT
wr.Write(dd.ResolvedHash);
wr.Write("*/");
}
wr.Write(" {0} ", dd.Name);
wr.Write("= {0}", dd.TargetQId.ToString());
if (dd.Exports.Count > 0) {
wr.Write(" {0}", dd.Name);
if (dd.Name != dd.TargetQId.ToString()) {
wr.Write(" = {0}", dd.TargetQId.ToString());
}
if (dd.Exports.Count == 1) {
wr.Write("`{0}", dd.Exports[0].val);
}
if (dd.Exports.Count > 1) {
wr.Write("`{{{0}}}", Util.Comma(dd.Exports, id => id.val));
}
wr.WriteLine();
Expand Down
14 changes: 14 additions & 0 deletions Test/dafny0/ModuleInsertion.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ module Outer.D {
const d := 3
}

module Outer.E {
export
provides F

module F {
export G
}
}

module Outer.H {
import E
import E.F`G
}

// ----- Oreo

module XY.X {
Expand Down
72 changes: 64 additions & 8 deletions Test/dafny0/ModuleInsertion.dfy.expect
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Outer {

module C {

import D = D
import D
const c := 2 + D.d
}
method Test()
Expand Down Expand Up @@ -40,9 +40,9 @@ method Main()

module Outer.A {

import B = B
import B

import C = C
import C
const a := B.b + C.c
}

Expand All @@ -54,11 +54,31 @@ module Outer.D {
const d := 3
}

module Outer.E {

export
provides F


module F {

export G

}
}

module Outer.H {

import E

import F = E.F`G
}

module XY.X {

module M {

import Y = Y
import Y
const n := Y.m - 5
}
const m := 20
Expand Down Expand Up @@ -208,7 +228,7 @@ module Outer {
* d
*/

import D = D
import D
const c: int := 2 + D.d
}
method Test()
Expand All @@ -226,9 +246,9 @@ module Outer {
* b
*/

import B = B
import B

import C = C
import C
const a: int := B.b + C.c
}

Expand All @@ -247,6 +267,42 @@ module Outer {
*/
const d: int := 3
}

module E {
/* CALL GRAPH for module E:
*/

export
provides F
/*----- exported view:

module F {
/* CALL GRAPH for module F:
*/

export G

}
-----*/


module F {
/* CALL GRAPH for module F:
*/

export G

}
}

module H {
/* CALL GRAPH for module H:
*/

import E

import F = E.F`G
}
}

module XY {
Expand Down Expand Up @@ -275,7 +331,7 @@ module XY {
* m
*/

import Y = Y
import Y
const n: int := Y.m - 5
}
const m: int := 20
Expand Down
6 changes: 3 additions & 3 deletions Test/git-issues/git-issue-371.dfy.expect
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ module A {

import TTT = M

import M = M
import M

import MA = MA
import MA

import MAI = MA.Inner

import Inner = MA.Inner

import MB = MB
import MB

import II = MB.I
class ZZ {
Expand Down