diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-06-25 18:21:34 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-06-25 18:21:34 +0200 |
commit | 850a99e8d49d910d1afb86d954f7145a31c657ca (patch) | |
tree | b773176fe9a196451830e2d919bf02a601100d0f /src | |
parent | c689d10d872647492ce117b3134d0dd2d998d26f (diff) | |
download | ghdl-850a99e8d49d910d1afb86d954f7145a31c657ca.tar.gz ghdl-850a99e8d49d910d1afb86d954f7145a31c657ca.tar.bz2 ghdl-850a99e8d49d910d1afb86d954f7145a31c657ca.zip |
src/ortho/oread: add more tests.
Diffstat (limited to 'src')
-rw-r--r-- | src/ortho/oread/tests/const2.on | 20 | ||||
-rw-r--r-- | src/ortho/oread/tests/const5.on | 17 | ||||
-rw-r--r-- | src/ortho/oread/tests/const6.on | 23 | ||||
-rw-r--r-- | src/ortho/oread/tests/structref2.on | 30 | ||||
-rw-r--r-- | src/ortho/oread/tests/structref3.on | 24 | ||||
-rw-r--r-- | src/ortho/oread/tests/structref4.on | 24 |
6 files changed, 123 insertions, 15 deletions
diff --git a/src/ortho/oread/tests/const2.on b/src/ortho/oread/tests/const2.on new file mode 100644 index 000000000..89269bf47 --- /dev/null +++ b/src/ortho/oread/tests/const2.on @@ -0,0 +1,20 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +PUBLIC FUNCTION inc (a : __ghdl_index_type) RETURN __ghdl_index_type; + +PUBLIC FUNCTION inc (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + RETURN a +# 1; +END; + +PUBLIC FUNCTION main (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + DECLARE + PRIVATE CONSTANT cst : __ghdl_index_type; + CONSTANT cst := __ghdl_index_type'[1]; + BEGIN + RETURN inc (a +# cst); + END; +END; diff --git a/src/ortho/oread/tests/const5.on b/src/ortho/oread/tests/const5.on new file mode 100644 index 000000000..0d98781f2 --- /dev/null +++ b/src/ortho/oread/tests/const5.on @@ -0,0 +1,17 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE index_array_type IS ARRAY[__ghdl_index_type] OF __ghdl_index_type; + +PUBLIC FUNCTION main (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + DECLARE + TYPE my_array IS SUBARRAY index_array_type[2]; + PRIVATE CONSTANT cst : my_array; + CONSTANT cst := [2]{__ghdl_index_type'[1], __ghdl_index_type'[2]}; + LOCAL VAR v : __ghdl_index_type; + BEGIN + v := a; + RETURN a +# cst[0]; + END; +END; diff --git a/src/ortho/oread/tests/const6.on b/src/ortho/oread/tests/const6.on new file mode 100644 index 000000000..f2bf7dee4 --- /dev/null +++ b/src/ortho/oread/tests/const6.on @@ -0,0 +1,23 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE index_array_type IS ARRAY[__ghdl_index_type] OF __ghdl_index_type; + +PUBLIC FUNCTION main (a : __ghdl_index_type) RETURN __ghdl_index_type +DECLARE +BEGIN + DECLARE + TYPE my_array IS SUBARRAY index_array_type[2]; + + TYPE _UI00000030 IS ARRAY [__ghdl_index_type] OF SUBARRAY + index_array_type[2]; + PRIVATE CONSTANT _UI00000031 : _UI00000030; + CONSTANT _UI00000031 := [3]{ + [2]{1, 2}, + [2]{2, 3}, + [2]{3, 4}}; + LOCAL VAR v : __ghdl_index_type; + BEGIN + v := a; + RETURN a; + END; +END; diff --git a/src/ortho/oread/tests/structref2.on b/src/ortho/oread/tests/structref2.on index 1090fe799..393fe4419 100644 --- a/src/ortho/oread/tests/structref2.on +++ b/src/ortho/oread/tests/structref2.on @@ -1,22 +1,22 @@ -type __ghdl_index_type is unsigned (32); +TYPE __ghdl_index_type IS UNSIGNED (32); -type __ghdl_char is unsigned (8); +TYPE __ghdl_char IS UNSIGNED (8); -type __ghdl_chararray is array [__ghdl_index_type] of __ghdl_char; +TYPE __ghdl_chararray IS ARRAY [__ghdl_index_type] OF __ghdl_char; -type __ghdl_char_ptr is access __ghdl_chararray; +TYPE __ghdl_char_ptr IS ACCESS __ghdl_chararray; -type __ghdl_char_ptr_array is array [__ghdl_index_type] of __ghdl_char_ptr; +TYPE __ghdl_char_ptr_array IS ARRAY [__ghdl_index_type] OF __ghdl_char_ptr; -type __ghdl_str_len is record - str: __ghdl_char_ptr; - len: __ghdl_index_type; -end record; +TYPE __ghdl_str_len IS RECORD + str: __ghdl_char_ptr; + len: __ghdl_index_type; +END RECORD; -public var var1 : __ghdl_str_len; +PUBLIC VAR var1 : __ghdl_str_len; -public function get_len () return __ghdl_index_type -declare -begin - return var1.len; -end; +PUBLIC FUNCTION get_len () RETURN __ghdl_index_type +DECLARE +BEGIN + RETURN var1.len; +END; diff --git a/src/ortho/oread/tests/structref3.on b/src/ortho/oread/tests/structref3.on new file mode 100644 index 000000000..0832a5e30 --- /dev/null +++ b/src/ortho/oread/tests/structref3.on @@ -0,0 +1,24 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_char IS UNSIGNED (8); + +TYPE __ghdl_chararray IS ARRAY [__ghdl_index_type] OF __ghdl_char; + +TYPE __ghdl_char_ptr IS ACCESS __ghdl_chararray; + +TYPE __ghdl_char_ptr_array IS ARRAY [__ghdl_index_type] OF __ghdl_char_ptr; + +TYPE __ghdl_str_len IS RECORD + str: __ghdl_char_ptr; + len: __ghdl_index_type; +END RECORD; + +TYPE ghdl_str_len_acc IS ACCESS __ghdl_str_len; + +PUBLIC VAR var1 : __ghdl_str_len; + +PUBLIC FUNCTION get_len (arg : ghdl_str_len_acc) RETURN __ghdl_index_type +DECLARE +BEGIN + RETURN arg.ALL.len; +END; diff --git a/src/ortho/oread/tests/structref4.on b/src/ortho/oread/tests/structref4.on new file mode 100644 index 000000000..32b40b17c --- /dev/null +++ b/src/ortho/oread/tests/structref4.on @@ -0,0 +1,24 @@ +TYPE __ghdl_index_type IS UNSIGNED (32); + +TYPE __ghdl_char IS UNSIGNED (8); + +TYPE __ghdl_chararray IS ARRAY [__ghdl_index_type] OF __ghdl_char; + +TYPE __ghdl_char_ptr IS ACCESS __ghdl_chararray; + +TYPE __ghdl_char_ptr_array IS ARRAY [__ghdl_index_type] OF __ghdl_char_ptr; + +TYPE __ghdl_str_len IS RECORD + str: __ghdl_char_ptr; + len: __ghdl_index_type; +END RECORD; + +TYPE ghdl_str_len_acc IS ACCESS __ghdl_str_len; + +PUBLIC VAR var1 : ghdl_str_len_acc; + +PUBLIC FUNCTION get_len () RETURN __ghdl_index_type +DECLARE +BEGIN + RETURN var1.ALL.len; +END; |