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

Bug 358049

Summary: Member comparison in GridLayout is not correctly generated
Product: z_Archived Reporter: Huang Ji Yong <hjiyong>
Component: EDTAssignee: Scott Greer <greer>
Status: CLOSED FIXED QA Contact:
Severity: blocker    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Huang Ji Yong CLA 2011-09-19 02:13:34 EDT
The egl content in GridLayout
function initTable()
	if ( columns == 0 || rows == 0 )
is generated to

if (({eze$$value : this.getColumns(), eze$$signature : "I;"}.compareTo({eze$$value : 0, eze$$signature : "i;"}) == 0) || ({eze$$value : this.getRows(), eze$$signature : "I;"}.compareTo({eze$$value : 0, eze$$signature : "i;"}) == 0))) 

The {eze$$value : this.getColumns(), eze$$signature : "I;"}.compareTo throws an exception. 
Should be ({eze$$value : this.getColumns(), eze$$signature : "I;"}).compareTo

Reproducible: always
Comment 1 Huang Ji Yong CLA 2011-09-19 04:31:51 EDT
Hi Scott,
The problem happens in BinaryExpressionTemplate, genExpression
When it runs ctx.invoke(genBinaryExpression, (Type) binExpr.getOperation().getContainer(), ctx, out, binExpr), the BooleanTypeTemplate is invoked first, and then NumTypeTemplate is invokded
I test the previous correctly build, the IntTypeTemplate should be invoked instead of NumTypeTemplate.

I think the problem is in the following codes in genExpression function of BinaryExpressionTemplate
if (CommonUtilities.needsConversion(expr.getRHS().getType(), expr.getLHS().getType())) {
			IRUtils.makeCompatible(binExpr, expr.getLHS().getType(), expr.getRHS().getType());
		}
IRUtils.makeCompatible converts the int/smallint type to num type. In previous version, the int/smallint type are converted to int type.
Thus this may be an IR problem.

The correctly generated js for that line of code is simply as:
this.getColumns() == 0
Comment 2 Huang Ji Yong CLA 2011-09-19 21:38:58 EDT
Verified in 201109192102