|
12 | 12 |
|
13 | 13 | Given the arguments to `build_function_wrapper`, return a list of assignments which |
14 | 14 | reconstruct array variables if they are present scalarized in `args`. |
| 15 | +
|
| 16 | +# Keyword Arguments |
| 17 | +
|
| 18 | +- `argument_name` a function of the form `(::Int) -> Symbol` which takes the index of |
| 19 | + an argument to the generated function and returns the name of the argument in the |
| 20 | + generated function. |
15 | 21 | """ |
16 | | -function array_variable_assignments(args...) |
| 22 | +function array_variable_assignments(args...; argument_name = generated_argument_name) |
17 | 23 | # map array symbolic to an identically sized array where each element is (buffer_idx, idx_in_buffer) |
18 | 24 | var_to_arridxs = Dict{BasicSymbolic, Array{Tuple{Int, Int}}}() |
19 | 25 | for (i, arg) in enumerate(args) |
@@ -60,12 +66,12 @@ function array_variable_assignments(args...) |
60 | 66 | end |
61 | 67 | # view and reshape |
62 | 68 |
|
63 | | - expr = term(reshape, term(view, generated_argument_name(buffer_idx), idxs), |
| 69 | + expr = term(reshape, term(view, argument_name(buffer_idx), idxs), |
64 | 70 | size(arrvar)) |
65 | 71 | else |
66 | 72 | elems = map(idxs) do idx |
67 | 73 | i, j = idx |
68 | | - term(getindex, generated_argument_name(i), j) |
| 74 | + term(getindex, argument_name(i), j) |
69 | 75 | end |
70 | 76 | # use `MakeArray` syntax and generate a stack-allocated array |
71 | 77 | expr = term(SymbolicUtils.Code.create_array, SArray, nothing, |
|
0 commit comments