Skip to content

Commit

Permalink
Add source level assert to basis
Browse files Browse the repository at this point in the history
  • Loading branch information
HeikoBecker committed Mar 3, 2020
1 parent e601a7b commit 89ada40
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
22 changes: 22 additions & 0 deletions basis/AssertProgScript.sml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(*
Module about CakeML assertions
*)
open preamble ml_translatorLib ml_progLib RuntimeProgTheory basisFunctionsLib;

val _ = new_theory "AssertProg";

val _ = translation_extends "RuntimeProg";

val _ = ml_prog_update (open_module "Assert");

val _ = process_topdecs `
fun assert cond msg =
if (cond)
then ()
else (Runtime.debugMsg (String.^ ("Assertion Failure:") (msg));
Runtime.abort());`
|> append_prog;

val _ = ml_prog_update (close_module NONE);

val _ = export_theory();
4 changes: 2 additions & 2 deletions basis/OptionProgScript.sml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(*
Module about the option tyoe.
*)
open preamble ml_translatorLib ml_progLib RuntimeProgTheory
open preamble ml_translatorLib ml_progLib AssertProgTheory
mloptionTheory

val _ = new_theory"OptionProg"

val _ = translation_extends "RuntimeProg"
val _ = translation_extends "AssertProg"

val _ = ml_prog_update (open_module "Option");

Expand Down
3 changes: 3 additions & 0 deletions basis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ A module about Arrays for the CakeML standard basis library.
[ArrayProofScript.sml](ArrayProofScript.sml):
Proofs about the Array module.

[AssertProgScript.sml](AssertProgScript.sml):
Module about CakeML assertions

[CharProgScript.sml](CharProgScript.sml):
A module about the char type for the CakeML standard basis library.

Expand Down

0 comments on commit 89ada40

Please sign in to comment.