Skip to content

let expression binding of argument to a function fails. #121

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sonodtt opened this issue Feb 11, 2019 · 0 comments
Open

let expression binding of argument to a function fails. #121

sonodtt opened this issue Feb 11, 2019 · 0 comments

Comments

@sonodtt
Copy link
Contributor

sonodtt commented Feb 11, 2019

NB it has been verified that let expressions do work in the simple scenario of binding a value to a variable.
https://github.com/sonodtt/gnat2goto/tree/irep_debug_framework_v0

The advantage of a let expression is that it allows to bind a parameter value to a
function in a single expression.

The alternative to this requires creating a unique function each call:
a) create a function with required value of parameter as variable in body
b) create a parameterless function call
c) pass expression to location where it is needed
(e.g the Do_Expression method of "tree_walk.adb")

As part of the cleanup work on arrays, there were a number of locations where 'let expressions' were used.
But in the scenario of using a let expression to bind a parameter to a function call - there are issues (the binding seems to fail, and it looks at a first glance like it is interpreted as a raw irep)
It is likely something minor is missing in the process.

• In the case of " Do_Aggregate_Literal_Array" in tree_walk.adb a let expression was used as so:

let_expr_irep := Make_Let_Expr (Symbol => Literal_Temp,
Value => Array_Expr,
Where => Result_Struct,
I_Type => Result_Type,
Source_Location => Sloc (N));

  return let_expr_irep;

This allows binding an array to a parameter of a function.
As this did not work, the entire callee was rewrote to avoid the let expression.

While this is a valid workaround - it seem worthwhile to investigate the original issue - let expressions, as clarified in the first paragraph, can be a useful tool to avoid trivial duplication of simple function calls.

@sonodtt sonodtt changed the title let expression binding of parameter to a function fails. let expression binding of argument to a function fails. Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant