X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CompoundAssignment.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CompoundAssignment.java index 4dd83aa..5912979 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CompoundAssignment.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CompoundAssignment.java @@ -1,19 +1,20 @@ /******************************************************************************* - * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others. + * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v0.5 + * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v05.html + * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation - ******************************************************************************/ + *******************************************************************************/ package net.sourceforge.phpdt.internal.compiler.ast; -import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor; -import net.sourceforge.phpdt.internal.compiler.codegen.*; -import net.sourceforge.phpdt.internal.compiler.flow.*; -import net.sourceforge.phpdt.internal.compiler.lookup.*; +import net.sourceforge.phpdt.internal.compiler.ASTVisitor; +import net.sourceforge.phpdt.internal.compiler.flow.FlowContext; +import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo; +import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope; +import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding; public class CompoundAssignment extends Assignment implements OperatorIds { public int operator; @@ -27,6 +28,7 @@ public CompoundAssignment(Expression lhs, Expression expression,int operator, in //but is build as an expression ==> the checkcast cannot fail super(lhs, expression, sourceEnd); + lhs.bits &= ~IsStrictlyAssignedMASK; // tag lhs as NON assigned - it is also a read access this.operator = operator ; } public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { @@ -34,21 +36,21 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl // a field reference, a blank final field reference, a field of an enclosing instance or // just a local variable. - return lhs.analyseAssignment(currentScope, flowContext, flowInfo, this, true).unconditionalInits(); -} -public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { - - // various scenarii are possible, setting an array reference, - // a field reference, a blank final field reference, a field of an enclosing instance or - // just a local variable. - - int pc = codeStream.position; - lhs.generateCompoundAssignment(currentScope, codeStream, expression, operator, assignmentImplicitConversion, valueRequired); - if (valueRequired) { - codeStream.generateImplicitConversion(implicitConversion); - } - codeStream.recordPositionsFrom(pc, this.sourceStart); + return ((Reference) lhs).analyseAssignment(currentScope, flowContext, flowInfo, this, true).unconditionalInits(); } +//public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { +// +// // various scenarii are possible, setting an array reference, +// // a field reference, a blank final field reference, a field of an enclosing instance or +// // just a local variable. +// +// int pc = codeStream.position; +// ((Reference) lhs).generateCompoundAssignment(currentScope, codeStream, expression, operator, assignmentImplicitConversion, valueRequired); +// if (valueRequired) { +// codeStream.generateImplicitConversion(implicitConversion); +// } +// codeStream.recordPositionsFrom(pc, this.sourceStart); +//} public String operatorToString() { switch (operator) { case PLUS : @@ -78,6 +80,9 @@ public String operatorToString() { } public TypeBinding resolveType(BlockScope scope) { constant = NotAConstant; + if (!(this.lhs instanceof Reference)) { + scope.problemReporter().expressionShouldBeAVariable(this.lhs); + } TypeBinding lhsType = lhs.resolveType(scope); TypeBinding expressionType = expression.resolveType(scope); if (lhsType == null || expressionType == null) @@ -122,7 +127,7 @@ public TypeBinding resolveType(BlockScope scope) { lhs.implicitConversion = result >>> 12; expression.implicitConversion = (result >>> 4) & 0x000FF; assignmentImplicitConversion = (lhsId << 4) + (result & 0x0000F); - return lhsType; + return this.resolvedType = lhsType; } public boolean restrainUsageToNumericTypes(){ return false ;} @@ -131,7 +136,7 @@ public String toStringExpressionNoParenthesis() { return lhs.toStringExpression() + " " + //$NON-NLS-1$ operatorToString() + " " + //$NON-NLS-1$ expression.toStringExpression() ; } -public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) { +public void traverse(ASTVisitor visitor, BlockScope scope) { if (visitor.visit(this, scope)) { lhs.traverse(visitor, scope); expression.traverse(visitor, scope);