/** * <copyright> * </copyright> * * $Id$ */ package net.sf.orcc.ir.impl; import net.sf.orcc.ir.Def; import net.sf.orcc.ir.IrPackage; import net.sf.orcc.ir.Var; 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; import org.eclipse.emf.ecore.impl.EObjectImpl; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>Def</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link net.sf.orcc.ir.impl.DefImpl#getVariable <em>Variable</em>}</li> * </ul> * </p> * * @generated */ public class DefImpl extends EObjectImpl implements Def { /** * The cached value of the '{@link #getVariable() <em>Variable</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getVariable() * @generated * @ordered */ protected Var variable; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected DefImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Var basicGetVariable() { return variable; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetVariable(Var newVariable, NotificationChain msgs) { Var oldVariable = variable; variable = newVariable; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IrPackage.DEF__VARIABLE, oldVariable, newVariable); 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.DEF__VARIABLE: if (resolve) return getVariable(); return basicGetVariable(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case IrPackage.DEF__VARIABLE: if (variable != null) msgs = ((InternalEObject) variable).eInverseRemove(this, IrPackage.VAR__DEFS, Var.class, msgs); return basicSetVariable((Var) otherEnd, msgs); } return super.eInverseAdd(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case IrPackage.DEF__VARIABLE: return basicSetVariable(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.DEF__VARIABLE: return variable != null; } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case IrPackage.DEF__VARIABLE: setVariable((Var) newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return IrPackage.Literals.DEF; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case IrPackage.DEF__VARIABLE: setVariable((Var) null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Var getVariable() { if (variable != null && variable.eIsProxy()) { InternalEObject oldVariable = (InternalEObject) variable; variable = (Var) eResolveProxy(oldVariable); if (variable != oldVariable) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, IrPackage.DEF__VARIABLE, oldVariable, variable)); } } return variable; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setVariable(Var newVariable) { if (newVariable != variable) { NotificationChain msgs = null; if (variable != null) msgs = ((InternalEObject) variable).eInverseRemove(this, IrPackage.VAR__DEFS, Var.class, msgs); if (newVariable != null) msgs = ((InternalEObject) newVariable).eInverseAdd(this, IrPackage.VAR__DEFS, Var.class, msgs); msgs = basicSetVariable(newVariable, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, IrPackage.DEF__VARIABLE, newVariable, newVariable)); } @Override public String toString() { return "def of: " + variable; } } //DefImpl