Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 328195 - make constant evaluator detect unchanged variables
Summary: make constant evaluator detect unchanged variables
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: b3 (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P4 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-19 21:43 EDT by Henrik Lindberg CLA
Modified: 2017-09-13 11:51 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.