Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions libISA/isa_visitor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ class type isaVisitor =
method leave_scope : Ident.t list -> unit
end

(****************************************************************)
(** {2 Nested scope handler} *)
(****************************************************************)

(** Handle nested scope by adding a nested scope level with
* list of variables `ls` that are introduced by `f`.
*)
let with_locals (vis : isaVisitor) (ls : Ident.t list) (f : 'a -> 'b) (x: 'a) : 'b =
vis#enter_scope ls;
let result = f x in
vis#leave_scope ls;
result

(****************************************************************)
(** {2 ISA visitor functions} *)
(****************************************************************)
Expand Down Expand Up @@ -185,9 +198,11 @@ and visit_expr (vis : isaVisitor) (x : expr) : expr =
let v' = visit_var vis Definition v in
let t' = visit_type vis t in
let e' = visit_expr vis e in
let b' = visit_expr vis b in
if v == v' && t == t' && e == e' && b == b' then x
else Expr_Let (v', t', e', b')
with_locals vis [v] (fun _ ->
let b' = visit_expr vis b in
if v == v' && t == t' && e == e' && b == b' then x
else Expr_Let (v', t', e', b')
) ()
| Expr_Assert (e1, e2, loc) ->
let e1' = visit_expr vis e1 in
let e2' = visit_expr vis e2 in
Expand Down Expand Up @@ -382,12 +397,6 @@ and visit_lexpr (vis : isaVisitor) (x : lexpr) : lexpr =
in
doVisit vis (vis#vlexpr x) aux x

let with_locals (vis : isaVisitor) (ls : Ident.t list) (f : 'a -> 'b) (x: 'a) : 'b =
vis#enter_scope ls;
let result = f x in
vis#leave_scope ls;
result

let rec locals_of_declitem (x : decl_item) : Ident.t list =
match x with
| DeclItem_Var (v, _) -> [ v ]
Expand Down
9 changes: 9 additions & 0 deletions tests/lit/dependencies/nocheck_00.isa
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: %iii --batchmode --exec=":dependencies %t.json" %s
// RUN: not grep temporary_variable %t.json

// Copyright (C) 2026-2026 Intel Corporation

function FUT1(i : {0..15}) -> {1..256}
begin
return __let temporary_variable : {1..16} := i+1 __in temporary_variable * temporary_variable;
end