From 41c5ae82e46fe06ab3a16d0759872a5a221f2da2 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Thu, 22 Jun 2017 18:11:32 +0100 Subject: Can now typecheck register declarations and assignments Can now properly typecheck register declarations and assignments. Also better support for assignments to mutable variables. Assignment to immutable let bound variables is disallowed as it should be, and casts when assiging to existing bound variables should be handled properly. Added additional tests for these new features, and a new option -just_check that allows the new checker to be run without the old. --- test/typecheck/fail/modify_assignment1.sail | 8 ++++++++ test/typecheck/fail/modify_assignment2.sail | 8 ++++++++ test/typecheck/fail/modify_let_bound.sail | 16 ++++++++++++++++ test/typecheck/fail/modify_type_chain1.sail | 8 ++++++++ test/typecheck/fail/modify_type_chain2.sail | 8 ++++++++ test/typecheck/fail/modify_type_chain3.sail | 8 ++++++++ test/typecheck/fail/modify_type_chain4.sail | 8 ++++++++ test/typecheck/fail/modify_type_chain5.sail | 8 ++++++++ test/typecheck/fail/reg_mod.sail | 11 +++++++++++ test/typecheck/pass/modify_assignment1.sail | 8 ++++++++ test/typecheck/pass/modify_type_chain.sail | 8 ++++++++ test/typecheck/pass/reg_mod.sail | 11 +++++++++++ 12 files changed, 110 insertions(+) create mode 100644 test/typecheck/fail/modify_assignment1.sail create mode 100644 test/typecheck/fail/modify_assignment2.sail create mode 100644 test/typecheck/fail/modify_let_bound.sail create mode 100644 test/typecheck/fail/modify_type_chain1.sail create mode 100644 test/typecheck/fail/modify_type_chain2.sail create mode 100644 test/typecheck/fail/modify_type_chain3.sail create mode 100644 test/typecheck/fail/modify_type_chain4.sail create mode 100644 test/typecheck/fail/modify_type_chain5.sail create mode 100644 test/typecheck/fail/reg_mod.sail create mode 100644 test/typecheck/pass/modify_assignment1.sail create mode 100644 test/typecheck/pass/modify_type_chain.sail create mode 100644 test/typecheck/pass/reg_mod.sail (limited to 'test') diff --git a/test/typecheck/fail/modify_assignment1.sail b/test/typecheck/fail/modify_assignment1.sail new file mode 100644 index 00000000..99adc95c --- /dev/null +++ b/test/typecheck/fail/modify_assignment1.sail @@ -0,0 +1,8 @@ + +val unit -> unit effect pure test + +function unit test () = +{ + z := 9; + z := 10 +} \ No newline at end of file diff --git a/test/typecheck/fail/modify_assignment2.sail b/test/typecheck/fail/modify_assignment2.sail new file mode 100644 index 00000000..6551afff --- /dev/null +++ b/test/typecheck/fail/modify_assignment2.sail @@ -0,0 +1,8 @@ + +val unit -> unit effect pure test + +function unit test () = +{ + ([|0:9|]) z := 9; + z := ([|0:10|]) 10 +} \ No newline at end of file diff --git a/test/typecheck/fail/modify_let_bound.sail b/test/typecheck/fail/modify_let_bound.sail new file mode 100644 index 00000000..a2ad1b98 --- /dev/null +++ b/test/typecheck/fail/modify_let_bound.sail @@ -0,0 +1,16 @@ + +default Order dec + +register bit[3] test + +val unit -> unit effect pure test + +function unit test () = +{ + let i = 10 in { + i := 20 + }; + z := 9; + z := 10; + test := 3 +} \ No newline at end of file diff --git a/test/typecheck/fail/modify_type_chain1.sail b/test/typecheck/fail/modify_type_chain1.sail new file mode 100644 index 00000000..3fff3b59 --- /dev/null +++ b/test/typecheck/fail/modify_type_chain1.sail @@ -0,0 +1,8 @@ + +val unit -> unit effect pure test + +function unit test () = +{ + ([|0:10|]) z := 9; + ([|0:9|]) z := ([|0:10|]) 8 +} \ No newline at end of file diff --git a/test/typecheck/fail/modify_type_chain2.sail b/test/typecheck/fail/modify_type_chain2.sail new file mode 100644 index 00000000..085e7db5 --- /dev/null +++ b/test/typecheck/fail/modify_type_chain2.sail @@ -0,0 +1,8 @@ + +val unit -> unit effect pure test + +function unit test () = +{ + ([|0:10|]) z := 9; + ([|0:7|]) z := ([|0:8|]) 8 +} \ No newline at end of file diff --git a/test/typecheck/fail/modify_type_chain3.sail b/test/typecheck/fail/modify_type_chain3.sail new file mode 100644 index 00000000..cfe532aa --- /dev/null +++ b/test/typecheck/fail/modify_type_chain3.sail @@ -0,0 +1,8 @@ + +val unit -> unit effect pure test + +function unit test () = +{ + ([|0:6|]) z := 9; + ([|0:7|]) z := ([|0:8|]) 8 +} \ No newline at end of file diff --git a/test/typecheck/fail/modify_type_chain4.sail b/test/typecheck/fail/modify_type_chain4.sail new file mode 100644 index 00000000..c36a9086 --- /dev/null +++ b/test/typecheck/fail/modify_type_chain4.sail @@ -0,0 +1,8 @@ + +val unit -> unit effect pure test + +function unit test () = +{ + ([|0:10|]) z := 9; + ([|0:11|]) z := ([|0:13|]) 8 +} \ No newline at end of file diff --git a/test/typecheck/fail/modify_type_chain5.sail b/test/typecheck/fail/modify_type_chain5.sail new file mode 100644 index 00000000..3c3076a4 --- /dev/null +++ b/test/typecheck/fail/modify_type_chain5.sail @@ -0,0 +1,8 @@ + +val unit -> unit effect pure test + +function unit test () = +{ + ([|0:10|]) z := 9; + ([|0:9|]) z := ([|0:13|]) 8 +} \ No newline at end of file diff --git a/test/typecheck/fail/reg_mod.sail b/test/typecheck/fail/reg_mod.sail new file mode 100644 index 00000000..24b318b4 --- /dev/null +++ b/test/typecheck/fail/reg_mod.sail @@ -0,0 +1,11 @@ + +register [|0:10|] reg + +val unit -> unit effect pure test + +function unit test () = +{ + reg := 9; + reg := 10; + reg := 8 +} \ No newline at end of file diff --git a/test/typecheck/pass/modify_assignment1.sail b/test/typecheck/pass/modify_assignment1.sail new file mode 100644 index 00000000..1c7ab614 --- /dev/null +++ b/test/typecheck/pass/modify_assignment1.sail @@ -0,0 +1,8 @@ + +val unit -> unit effect pure test + +function unit test () = +{ + ([|0:10|]) z := 9; + z := ([|0:9|]) 8 +} \ No newline at end of file diff --git a/test/typecheck/pass/modify_type_chain.sail b/test/typecheck/pass/modify_type_chain.sail new file mode 100644 index 00000000..14651787 --- /dev/null +++ b/test/typecheck/pass/modify_type_chain.sail @@ -0,0 +1,8 @@ + +val unit -> unit effect pure test + +function unit test () = +{ + ([|0:10|]) z := 9; + ([|0:9|]) z := ([|0:8|]) 8 +} \ No newline at end of file diff --git a/test/typecheck/pass/reg_mod.sail b/test/typecheck/pass/reg_mod.sail new file mode 100644 index 00000000..37c8d890 --- /dev/null +++ b/test/typecheck/pass/reg_mod.sail @@ -0,0 +1,11 @@ + +register [|0:10|] reg + +val unit -> unit effect {wreg} test + +function unit test () = +{ + reg := 9; + reg := 10; + reg := 8 +} \ No newline at end of file -- cgit v1.2.3