@@ -18,6 +18,7 @@ use jani::{
1818 types:: { BasicType , BoundedType , BoundedTypeBase , Type } ,
1919 Identifier ,
2020} ;
21+ use lsp_types:: NumberOrString ;
2122
2223use crate :: {
2324 ast:: {
@@ -45,10 +46,12 @@ pub enum JaniConversionError {
4546 UnsupportedPre ( Expr ) ,
4647 UnsupportedAssume ( Expr ) ,
4748 UnsupportedAssert ( Expr ) ,
49+ UnsupportedHavoc { stmt : Stmt , can_eliminate : bool } ,
4850 UnsupportedInftyPost ( Expr ) ,
4951 NondetSelection ( Span ) ,
5052 MismatchedDirection ( Span ) ,
5153 UnsupportedCall ( Span , Ident ) ,
54+ UnsupportedCalculus { proc : Ident , calculus : Ident } ,
5255}
5356
5457impl JaniConversionError {
@@ -85,6 +88,16 @@ impl JaniConversionError {
8588 . with_message ( "JANI: Assertion must be a Boolean expression" )
8689 . with_label ( Label :: new ( expr. span ) . with_message ( "expected ?(b) here" ) )
8790 }
91+ JaniConversionError :: UnsupportedHavoc { stmt, can_eliminate} => {
92+ let diagnostic = Diagnostic :: new ( ReportKind :: Error , stmt. span )
93+ . with_message ( "JANI: Havoc is not supported" )
94+ . with_label ( Label :: new ( stmt. span ) . with_message ( "here" ) ) ;
95+ if * can_eliminate {
96+ diagnostic. with_note ( "You can replace the havoc with a re-declaration of its variables." )
97+ } else {
98+ diagnostic
99+ }
100+ }
88101 JaniConversionError :: UnsupportedInftyPost ( expr) => {
89102 Diagnostic :: new ( ReportKind :: Error , expr. span )
90103 . with_message ( "JANI: Post that evaluates to ∞ is not supported" )
@@ -103,7 +116,11 @@ impl JaniConversionError {
103116 . with_message ( format ! ( "JANI: Cannot call '{}'" , ident. name) )
104117 . with_label ( Label :: new ( * span) . with_message ( "must be a func with a body" ) )
105118 }
119+ JaniConversionError :: UnsupportedCalculus { proc, calculus } => Diagnostic :: new ( ReportKind :: Error , proc. span )
120+ . with_message ( format ! ( "JANI: Calculus '{}' is not supported" , calculus) )
121+ . with_label ( Label :: new ( proc. span ) . with_message ( "here" ) ) ,
106122 }
123+ . with_code ( NumberOrString :: String ( "model checking" . to_owned ( ) ) )
107124 }
108125}
109126
@@ -112,6 +129,8 @@ pub fn proc_to_model(
112129 tcx : & TyCtx ,
113130 proc : & ProcDecl ,
114131) -> Result < Model , JaniConversionError > {
132+ check_calculus_annotation ( proc) ?;
133+
115134 let expr_translator = ExprTranslator :: new ( tcx) ;
116135
117136 // initialize the spec automaton
@@ -197,6 +216,20 @@ pub fn proc_to_model(
197216 Ok ( model)
198217}
199218
219+ fn check_calculus_annotation ( proc : & ProcDecl ) -> Result < ( ) , JaniConversionError > {
220+ if let Some ( calculus) = proc. calculus {
221+ if & calculus. name != "wp" || & calculus. name != "ert"
222+ // yeah that's ugly
223+ {
224+ return Err ( JaniConversionError :: UnsupportedCalculus {
225+ proc : proc. name ,
226+ calculus,
227+ } ) ;
228+ }
229+ }
230+ Ok ( ( ) )
231+ }
232+
200233/// Translate variable declarations, including local variable declarations, as
201234/// well as input and output parameters.
202235fn translate_var_decls (
0 commit comments