Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] A util for expression evaluation in CDT?

> Evaluating expressions is required for dealing correctly with 
> generalized constant expressions. In 
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=332829 (still open) 
> Sergey states that the evaluation of constexpr functions has been 
> added (Comment 5). I currently can't access the repository, but 
> if that functionality has not been revoked, there needs to be 
> some kind of facility to do such evaluation. At least for simple 
> expressions like requested below. Yet, I don't know if it is 
> accessible from other plug-ins or whether it is internal.

If you have a variable whose initial value is the expression
you want to evaluate, you can call IVariable.getValue(), and
call numericalValue() on the returned IValue. This is public
API.

For expressions in general there is 
ICPPASTExpression.getEvaluation() and ICPPEvaluation.getValue()
but these are internal. There would probably be value (ha ha)
in exposing these in the public API as well.

Regards,
Nate
 		 	   		  

Back to the top