/**
* <copyright>
* </copyright>
*
* $Id$
*/
package net.sf.orcc.ir.impl;
import java.util.Collection;
import net.sf.orcc.ir.Block;
import net.sf.orcc.ir.BlockBasic;
import net.sf.orcc.ir.BlockWhile;
import net.sf.orcc.ir.Expression;
import net.sf.orcc.ir.IrPackage;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
/**
* <!-- begin-user-doc --> An implementation of the model object '
* <em><b>BlockWhile</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link net.sf.orcc.ir.impl.BlockWhileImpl#getCondition <em>Condition</em>}</li>
* <li>{@link net.sf.orcc.ir.impl.BlockWhileImpl#getJoinBlock <em>Join Block</em>}</li>
* <li>{@link net.sf.orcc.ir.impl.BlockWhileImpl#getLineNumber <em>Line Number</em>}</li>
* <li>{@link net.sf.orcc.ir.impl.BlockWhileImpl#getBlocks <em>Blocks</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class BlockWhileImpl extends BlockImpl implements BlockWhile {
/**
* The cached value of the '{@link #getCondition() <em>Condition</em>}' containment reference.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getCondition()
* @generated
* @ordered
*/
protected Expression condition;
/**
* The cached value of the '{@link #getJoinBlock() <em>Join Block</em>}' containment reference.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getJoinBlock()
* @generated
* @ordered
*/
protected BlockBasic joinBlock;
/**
* The default value of the '{@link #getLineNumber() <em>Line Number</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getLineNumber()
* @generated
* @ordered
*/
protected static final int LINE_NUMBER_EDEFAULT = 0;
/**
* The cached value of the '{@link #getLineNumber() <em>Line Number</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getLineNumber()
* @generated
* @ordered
*/
protected int lineNumber = LINE_NUMBER_EDEFAULT;
/**
* The cached value of the '{@link #getBlocks() <em>Blocks</em>}' containment reference list.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getBlocks()
* @generated
* @ordered
*/
protected EList<Block> blocks;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected BlockWhileImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetCondition(Expression newCondition,
NotificationChain msgs) {
Expression oldCondition = condition;
condition = newCondition;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, IrPackage.BLOCK_WHILE__CONDITION,
oldCondition, newCondition);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetJoinBlock(BlockBasic newJoinBlock,
NotificationChain msgs) {
BlockBasic oldJoinBlock = joinBlock;
joinBlock = newJoinBlock;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, IrPackage.BLOCK_WHILE__JOIN_BLOCK,
oldJoinBlock, newJoinBlock);
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.BLOCK_WHILE__CONDITION:
return getCondition();
case IrPackage.BLOCK_WHILE__JOIN_BLOCK:
return getJoinBlock();
case IrPackage.BLOCK_WHILE__LINE_NUMBER:
return getLineNumber();
case IrPackage.BLOCK_WHILE__BLOCKS:
return getBlocks();
}
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.BLOCK_WHILE__CONDITION:
return basicSetCondition(null, msgs);
case IrPackage.BLOCK_WHILE__JOIN_BLOCK:
return basicSetJoinBlock(null, msgs);
case IrPackage.BLOCK_WHILE__BLOCKS:
return ((InternalEList<?>) getBlocks()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case IrPackage.BLOCK_WHILE__CONDITION:
return condition != null;
case IrPackage.BLOCK_WHILE__JOIN_BLOCK:
return joinBlock != null;
case IrPackage.BLOCK_WHILE__LINE_NUMBER:
return lineNumber != LINE_NUMBER_EDEFAULT;
case IrPackage.BLOCK_WHILE__BLOCKS:
return blocks != null && !blocks.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case IrPackage.BLOCK_WHILE__CONDITION:
setCondition((Expression) newValue);
return;
case IrPackage.BLOCK_WHILE__JOIN_BLOCK:
setJoinBlock((BlockBasic) newValue);
return;
case IrPackage.BLOCK_WHILE__LINE_NUMBER:
setLineNumber((Integer) newValue);
return;
case IrPackage.BLOCK_WHILE__BLOCKS:
getBlocks().clear();
getBlocks().addAll((Collection<? extends Block>) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return IrPackage.Literals.BLOCK_WHILE;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case IrPackage.BLOCK_WHILE__CONDITION:
setCondition((Expression) null);
return;
case IrPackage.BLOCK_WHILE__JOIN_BLOCK:
setJoinBlock((BlockBasic) null);
return;
case IrPackage.BLOCK_WHILE__LINE_NUMBER:
setLineNumber(LINE_NUMBER_EDEFAULT);
return;
case IrPackage.BLOCK_WHILE__BLOCKS:
getBlocks().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public EList<Block> getBlocks() {
if (blocks == null) {
blocks = new EObjectContainmentEList<Block>(Block.class, this,
IrPackage.BLOCK_WHILE__BLOCKS);
}
return blocks;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public Expression getCondition() {
return condition;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public BlockBasic getJoinBlock() {
return joinBlock;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public int getLineNumber() {
return lineNumber;
}
@Override
public boolean isBlockBasic() {
return false;
}
@Override
public boolean isBlockIf() {
return false;
}
@Override
public boolean isBlockWhile() {
return true;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setCondition(Expression newCondition) {
if (newCondition != condition) {
NotificationChain msgs = null;
if (condition != null)
msgs = ((InternalEObject) condition).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE
- IrPackage.BLOCK_WHILE__CONDITION, null, msgs);
if (newCondition != null)
msgs = ((InternalEObject) newCondition).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE
- IrPackage.BLOCK_WHILE__CONDITION, null, msgs);
msgs = basicSetCondition(newCondition, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
IrPackage.BLOCK_WHILE__CONDITION, newCondition,
newCondition));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setJoinBlock(BlockBasic newJoinBlock) {
if (newJoinBlock != joinBlock) {
NotificationChain msgs = null;
if (joinBlock != null)
msgs = ((InternalEObject) joinBlock)
.eInverseRemove(this, EOPPOSITE_FEATURE_BASE
- IrPackage.BLOCK_WHILE__JOIN_BLOCK, null, msgs);
if (newJoinBlock != null)
msgs = ((InternalEObject) newJoinBlock)
.eInverseAdd(this, EOPPOSITE_FEATURE_BASE
- IrPackage.BLOCK_WHILE__JOIN_BLOCK, null, msgs);
msgs = basicSetJoinBlock(newJoinBlock, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
IrPackage.BLOCK_WHILE__JOIN_BLOCK, newJoinBlock,
newJoinBlock));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setLineNumber(int newLineNumber) {
int oldLineNumber = lineNumber;
lineNumber = newLineNumber;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
IrPackage.BLOCK_WHILE__LINE_NUMBER, oldLineNumber,
lineNumber));
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy())
return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (lineNumber: ");
result.append(lineNumber);
result.append(')');
return result.toString();
}
} // BlockWhileImpl