/**
* <copyright>
* </copyright>
*
* $Id$
*/
package net.sf.orcc.ir.impl;
import static net.sf.orcc.ir.util.IrUtil.getNameSSA;
import net.sf.orcc.ir.Def;
import net.sf.orcc.ir.Expression;
import net.sf.orcc.ir.InstAssign;
import net.sf.orcc.ir.IrPackage;
import net.sf.orcc.ir.util.ExpressionPrinter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
/**
* <!-- begin-user-doc --> An implementation of the model object '
* <em><b>Inst Assign</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link net.sf.orcc.ir.impl.InstAssignImpl#getTarget <em>Target</em>}</li>
* <li>{@link net.sf.orcc.ir.impl.InstAssignImpl#getValue <em>Value</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class InstAssignImpl extends InstructionImpl implements InstAssign {
/**
* The cached value of the '{@link #getTarget() <em>Target</em>}' containment reference.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getTarget()
* @generated
* @ordered
*/
protected Def target;
/**
* The cached value of the '{@link #getValue() <em>Value</em>}' containment reference.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getValue()
* @generated
* @ordered
*/
protected Expression value;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected InstAssignImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetTarget(Def newTarget,
NotificationChain msgs) {
Def oldTarget = target;
target = newTarget;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, IrPackage.INST_ASSIGN__TARGET, oldTarget,
newTarget);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetValue(Expression newValue,
NotificationChain msgs) {
Expression oldValue = value;
value = newValue;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, IrPackage.INST_ASSIGN__VALUE, oldValue,
newValue);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case IrPackage.INST_ASSIGN__TARGET:
return getTarget();
case IrPackage.INST_ASSIGN__VALUE:
return getValue();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case IrPackage.INST_ASSIGN__TARGET:
return basicSetTarget(null, msgs);
case IrPackage.INST_ASSIGN__VALUE:
return basicSetValue(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case IrPackage.INST_ASSIGN__TARGET:
return target != null;
case IrPackage.INST_ASSIGN__VALUE:
return value != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case IrPackage.INST_ASSIGN__TARGET:
setTarget((Def) newValue);
return;
case IrPackage.INST_ASSIGN__VALUE:
setValue((Expression) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return IrPackage.Literals.INST_ASSIGN;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case IrPackage.INST_ASSIGN__TARGET:
setTarget((Def) null);
return;
case IrPackage.INST_ASSIGN__VALUE:
setValue((Expression) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public Def getTarget() {
return target;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public Expression getValue() {
return value;
}
@Override
public boolean isInstAssign() {
return true;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setTarget(Def newTarget) {
if (newTarget != target) {
NotificationChain msgs = null;
if (target != null)
msgs = ((InternalEObject) target).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - IrPackage.INST_ASSIGN__TARGET,
null, msgs);
if (newTarget != null)
msgs = ((InternalEObject) newTarget).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - IrPackage.INST_ASSIGN__TARGET,
null, msgs);
msgs = basicSetTarget(newTarget, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
IrPackage.INST_ASSIGN__TARGET, newTarget, newTarget));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setValue(Expression newValue) {
if (newValue != value) {
NotificationChain msgs = null;
if (value != null)
msgs = ((InternalEObject) value).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - IrPackage.INST_ASSIGN__VALUE,
null, msgs);
if (newValue != null)
msgs = ((InternalEObject) newValue).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - IrPackage.INST_ASSIGN__VALUE,
null, msgs);
msgs = basicSetValue(newValue, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
IrPackage.INST_ASSIGN__VALUE, newValue, newValue));
}
@Override
public String toString() {
return super.toString() + "Assign(" + getNameSSA(target.getVariable())
+ ", " + new ExpressionPrinter().doSwitch(getValue()) + ")";
}
} // InstAssignImpl