summaryrefslogtreecommitdiff
path: root/test/typecheck
diff options
context:
space:
mode:
authorThomas Bauereiss2017-08-24 16:49:45 +0100
committerThomas Bauereiss2017-08-24 16:58:29 +0100
commitea35b8540a67c80f5b0e777a8cac5367e87f2c1e (patch)
treee3ed8b06b4a2b9c56d030363fd3c2b641238900e /test/typecheck
parent893df6c2ca7e1d51eb2e2d7c19ea0b2fca38eacb (diff)
Begin refactoring Sail library
- Add back support for bit list representation of bit vectors, for backwards compatibility in order to ease integration with the interpreter. For this purpose, split out a file sail_operators.lem from sail_values.lem, and add a variant sail_operators_mwords.lem for the machine word representation of bitvectors. Currently, Sail is hardcoded to use machine words for the sequential state monad, and bit lists for the free monad, but this could be turned into a command line flag. - Add a prelude_wrappers.sail file for glueing the Sail prelude to the Lem library. The wrappers make use of sizeof expressions to extract type information from bitvectors (length, start index) in order to pass it to the Lem functions. - Add early return support to the free monad, using a new constructor "Return of 'r". As with the sequential monad, functions with early return are wrapped into "catch_early_return", which extracts the return value at the end of the function execution.
Diffstat (limited to 'test/typecheck')
-rw-r--r--test/typecheck/pass/foreach_var_updates.sail15
-rwxr-xr-xtest/typecheck/run_tests.sh10
2 files changed, 20 insertions, 5 deletions
diff --git a/test/typecheck/pass/foreach_var_updates.sail b/test/typecheck/pass/foreach_var_updates.sail
new file mode 100644
index 00000000..e3e30ce6
--- /dev/null
+++ b/test/typecheck/pass/foreach_var_updates.sail
@@ -0,0 +1,15 @@
+val extern (int, int) -> int effect pure add_int = "add"
+overload (deinfix +) [ add_int ]
+
+val extern (int, int) -> int effect pure sub_int = "sub"
+overload (deinfix -) [ sub_int ]
+
+function (int) foo ((int) w) = {
+ (int) x := w;
+ (int) y := w;
+ foreach (z from 0 to 10) {
+ x := x + z;
+ y := y - z;
+ };
+ x + y;
+}
diff --git a/test/typecheck/run_tests.sh b/test/typecheck/run_tests.sh
index 12e6acc0..24f20d1f 100755
--- a/test/typecheck/run_tests.sh
+++ b/test/typecheck/run_tests.sh
@@ -18,11 +18,11 @@ rm -f $DIR/tests.xml
MIPS="$SAILDIR/mips_new_tc"
-cat $SAILDIR/lib/prelude.sail $MIPS/mips_prelude.sail > $DIR/pass/mips_prelude.sail
-cat $SAILDIR/lib/prelude.sail $MIPS/mips_prelude.sail $MIPS/mips_tlb.sail > $DIR/pass/mips_tlb.sail
-cat $SAILDIR/lib/prelude.sail $MIPS/mips_prelude.sail $MIPS/mips_tlb.sail $MIPS/mips_wrappers.sail > $DIR/pass/mips_wrappers.sail
-cat $SAILDIR/lib/prelude.sail $MIPS/mips_prelude.sail $MIPS/mips_tlb.sail $MIPS/mips_wrappers.sail $MIPS/mips_insts.sail $MIPS/mips_epilogue.sail > $DIR/pass/mips_insts.sail
-cat $SAILDIR/lib/prelude.sail $MIPS/mips_prelude.sail $MIPS/mips_tlb_stub.sail $MIPS/mips_wrappers.sail $MIPS/mips_insts.sail $MIPS/mips_epilogue.sail > $DIR/pass/mips_notlb.sail
+cat $SAILDIR/lib/prelude.sail $SAILDIR/lib/prelude_wrappers.sail $MIPS/mips_prelude.sail > $DIR/pass/mips_prelude.sail
+cat $SAILDIR/lib/prelude.sail $SAILDIR/lib/prelude_wrappers.sail $MIPS/mips_prelude.sail $MIPS/mips_tlb.sail > $DIR/pass/mips_tlb.sail
+cat $SAILDIR/lib/prelude.sail $SAILDIR/lib/prelude_wrappers.sail $MIPS/mips_prelude.sail $MIPS/mips_tlb.sail $MIPS/mips_wrappers.sail > $DIR/pass/mips_wrappers.sail
+cat $SAILDIR/lib/prelude.sail $SAILDIR/lib/prelude_wrappers.sail $MIPS/mips_prelude.sail $MIPS/mips_tlb.sail $MIPS/mips_wrappers.sail $MIPS/mips_insts.sail $MIPS/mips_epilogue.sail > $DIR/pass/mips_insts.sail
+cat $SAILDIR/lib/prelude.sail $SAILDIR/lib/prelude_wrappers.sail $MIPS/mips_prelude.sail $MIPS/mips_tlb_stub.sail $MIPS/mips_wrappers.sail $MIPS/mips_insts.sail $MIPS/mips_epilogue.sail > $DIR/pass/mips_notlb.sail
pass=0
fail=0