Skip to content
Snippets Groups Projects
Commit f88ddb49 authored by Basile Desloges's avatar Basile Desloges Committed by Julien Signoles
Browse files

[eacsl:codegen] Fix translation of ranges

The ranges are inclusives, so the number of elements in `[n1 .. n2]` is
`n2 - n1 + 1`.
parent 0ad5c75a
No related branches found
No related tags found
No related merge requests found
...@@ -204,13 +204,17 @@ let call_memory_block ~loc kf name ctx env ptr r p = ...@@ -204,13 +204,17 @@ let call_memory_block ~loc kf name ctx env ptr r p =
we need to clone them in order to force retyping *) we need to clone them in order to force retyping *)
let s = { s with term_node = s.term_node } in let s = { s with term_node = s.term_node } in
let n1 = { n1 with term_node = n1.term_node } in let n1 = { n1 with term_node = n1.term_node } in
Logic_const.term (* The range are inclusives, so the total number of elements is
~loc [n2 - n1 + 1] *)
(TBinOp( let count = Logic_const.term
Mult, ~loc
s, (TBinOp (
Logic_const.term ~loc (TBinOp(MinusA, n2, n1)) Linteger)) PlusA,
Linteger Logic_const.term ~loc (TBinOp (MinusA, n2, n1)) Linteger,
Logic_const.tinteger ~loc 1))
Linteger
in
Logic_const.term ~loc (TBinOp (Mult, s, count)) Linteger
in in
Typing.type_term ~use_gmp_opt:false size_term; Typing.type_term ~use_gmp_opt:false size_term;
let size, env = match Typing.get_number_ty size_term with let size, env = match Typing.get_number_ty size_term with
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment