forked from dfinity/motoko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug fixes: * pretty-printing of MethodCallS * arguments in private functions * calls with n=1 arguments New features: * method calls in let/var declarations * method calls in assignments * method calls in return statements New test cases: * test/viper/method-call.mo
- Loading branch information
Showing
7 changed files
with
117 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
actor MethodCall { | ||
func ignoreBool(_b : Bool) : () { | ||
}; | ||
|
||
// take an Int argument and return it unmodified | ||
func idInt(n : Int) : Int { | ||
return n; | ||
}; | ||
|
||
// take a Bool argument and return it unmodified | ||
func idBool(b : Bool) : Bool { | ||
return b; | ||
}; | ||
|
||
public func ifThenElse(b : Bool, tru : Int, fls : Int) : async Int { | ||
ignoreBool(b); // standalone method call | ||
let c1 = idBool(b); // method call in let-declaration | ||
var c2 = idBool(b); // method call in var-declaration | ||
c2 := idBool(c2); // method call in assignment | ||
if (c1 and c2) { | ||
return idInt(tru); // method call in return statement | ||
}; | ||
return idInt(fls); // method call in return statement | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Parse warning: In macro $Perm, the following parameters were defined but not used: $Self (method-call.vpr@1.1) | ||
Parse warning: In macro $Inv, the following parameters were defined but not used: $Self (method-call.vpr@2.1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
define $Perm($Self) (true) | ||
define $Inv($Self) (true) | ||
method __init__($Self: Ref) | ||
|
||
requires $Perm($Self) | ||
ensures $Perm($Self) | ||
ensures $Inv($Self) | ||
{ | ||
|
||
} | ||
method ignoreBool($Self: Ref, _b: Bool) | ||
|
||
requires $Perm($Self) | ||
ensures $Perm($Self) | ||
{ | ||
label $Ret | ||
} | ||
method idInt($Self: Ref, n: Int) | ||
returns ($Res: Int) | ||
requires $Perm($Self) | ||
ensures $Perm($Self) | ||
{ | ||
$Res := n | ||
goto $Ret | ||
label $Ret | ||
} | ||
method idBool($Self: Ref, b: Bool) | ||
returns ($Res: Bool) | ||
requires $Perm($Self) | ||
ensures $Perm($Self) | ||
{ | ||
$Res := b | ||
goto $Ret | ||
label $Ret | ||
} | ||
method ifThenElse($Self: Ref, b: Bool, tru: Int, fls: Int) | ||
returns ($Res: Int) | ||
requires $Perm($Self) | ||
requires $Inv($Self) | ||
ensures $Perm($Self) | ||
ensures $Inv($Self) | ||
{ var c1: Bool | ||
var c2: Bool | ||
ignoreBool($Self, b) | ||
c1 := idBool($Self, b) | ||
c2 := idBool($Self, b) | ||
c2 := idBool($Self, c2) | ||
if ((c1 && c2)) | ||
{ | ||
$Res := idInt($Self, tru) | ||
goto $Ret | ||
} | ||
$Res := idInt($Self, fls) | ||
goto $Ret | ||
label $Ret | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters