How to get expression as string in Java? [message #1760592] |
Fri, 28 April 2017 17:14 |
Sina Madani Messages: 160 Registered: November 2015 Location: York, UK |
Senior Member |
|
|
Hello,
I am trying to get the name of all of the dependencies in EVL through "satisfies" calls. However, I found that the type "Expression" does not provide any way to retrieve the expression as text. I have attached the relevant code.
Apologies if this is not a suitable place for asking this or there is insufficient detail.
|
|
|
|
|
|
|
|
Re: How to get expression as string in Java? [message #1760623 is a reply to message #1760621] |
Fri, 28 April 2017 23:32 |
Sina Madani Messages: 160 Registered: November 2015 Location: York, UK |
Senior Member |
|
|
Apologies for the misunderstanding.
Having read section 4.4.1 of the Epsilon Book ("Capturing Dependencies Between Invariants"), the specification of "satisfies" operations take a string as parameter(s), however admittedly this may not be a StringLiteral. Therefore, I may have to resort to manually resolving all potential expressions to get the eventual string, or make an assumption that all parameters to "satisfies" operations will be StringLiterals. For example:
//Stream<Expression> satisfiesParams
.map(expr -> {
if (expr instanceof StringLiteral)
return ((StringLiteral) expr).getValue();
if (expr instanceof NameExpression)
return ((NameExpression) expr).getName();
return expr.execute(context);
})
Thanks,
Sina
[Updated on: Fri, 28 April 2017 23:34] Report message to a moderator
|
|
|
Re: How to get expression as string in Java? [message #1760632 is a reply to message #1760623] |
Sat, 29 April 2017 08:17 |
|
Hi Sina,
This is correct. Bear in mind that the name of a constraint is not unique so in order to compute a precise dependency graph, in the general case you'd need to do full static analysis (including type inference etc.). To avoid going down that road at this stage you may want to limit your analysis to calls to satisfies() on the self built-in variable.
Cheers,
Dimitris
|
|
|
|
Powered by
FUDForum. Page generated in 0.04013 seconds