Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 328195

Summary: make constant evaluator detect unchanged variables
Product: z_Archived Reporter: Henrik Lindberg <henrik.lindberg>
Component: b3Assignee: Project Inbox <b3.engine-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P4    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Henrik Lindberg CLA 2010-10-19 21:43:56 EDT
consider

var a = 0;
var b = 10/a;

The constant evaluator does not treat variables as having constant value. To do this there is the need to investigate the "evaluation path" between the variable definition and the use of the variable. The constant evaluator can not currently do this.

The var scope provider performs a search "up the scope chain" in a fashion similar to what is needed in
evalConstant(BVariableExpression o) where a search is needed from "o" up it's containment chain until it finds the instance referenced by o.getNamedValue().

The search is non trivial

var a = 0;
switch someFuction() case someOtherFunction() : a = 0 case false: a = 0 endswitch;
var b = 10/a;

Here a is still 0 even if assigned (both assignments are constant and to 0).

The query would need to answer: for all possible evaluations between o and the named value, does the evaluation change the value to something different than its initial value.
Comment 1 Henrik Lindberg CLA 2010-10-19 21:44:42 EDT
Although nice to have, not the most important enhancement - changed to P4.