/**
* <copyright>
* </copyright>
*
* $Id$
*/
package net.sf.orcc.ir.impl;
import java.math.BigInteger;
import net.sf.orcc.ir.ExprInt;
import net.sf.orcc.ir.IrPackage;
import net.sf.orcc.ir.Type;
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>Expr Int</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link net.sf.orcc.ir.impl.ExprIntImpl#getValue <em>Value</em>}</li>
* <li>{@link net.sf.orcc.ir.impl.ExprIntImpl#getType <em>Type</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ExprIntImpl extends ExpressionImpl implements ExprInt {
/**
* The default value of the '{@link #getValue() <em>Value</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getValue()
* @generated
* @ordered
*/
protected static final BigInteger VALUE_EDEFAULT = null;
/**
* The cached value of the '{@link #getValue() <em>Value</em>}' attribute.
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @see #getValue()
* @generated
* @ordered
*/
protected BigInteger value = VALUE_EDEFAULT;
/**
* The cached value of the '{@link #getType() <em>Type</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected Type type;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
protected ExprIntImpl() {
super();
}
public ExprIntImpl(BigInteger value) {
super();
setValue(value);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case IrPackage.EXPR_INT__VALUE:
return getValue();
case IrPackage.EXPR_INT__TYPE:
return getType();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case IrPackage.EXPR_INT__VALUE:
return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT
.equals(value);
case IrPackage.EXPR_INT__TYPE:
return type != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case IrPackage.EXPR_INT__VALUE:
setValue((BigInteger) newValue);
return;
case IrPackage.EXPR_INT__TYPE:
setType((Type) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return IrPackage.Literals.EXPR_INT;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case IrPackage.EXPR_INT__VALUE:
setValue(VALUE_EDEFAULT);
return;
case IrPackage.EXPR_INT__TYPE:
setType((Type) null);
return;
}
super.eUnset(featureID);
}
@Override
public int getIntValue() {
return value.intValue();
}
@Override
public long getLongValue() {
return value.longValue();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetType(Type newType, NotificationChain msgs) {
Type oldType = type;
type = newType;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, IrPackage.EXPR_INT__TYPE, oldType,
newType);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setType(Type newType) {
if (newType != type) {
NotificationChain msgs = null;
if (type != null)
msgs = ((InternalEObject) type).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE - IrPackage.EXPR_INT__TYPE,
null, msgs);
if (newType != null)
msgs = ((InternalEObject) newType).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE - IrPackage.EXPR_INT__TYPE,
null, msgs);
msgs = basicSetType(newType, msgs);
if (msgs != null)
msgs.dispatch();
} else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
IrPackage.EXPR_INT__TYPE, newType, newType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID) {
case IrPackage.EXPR_INT__TYPE:
return basicSetType(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public BigInteger getValue() {
return value;
}
@Override
public boolean isExprInt() {
return true;
}
@Override
public boolean isLong() {
return getIntValue() != getLongValue();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
public void setValue(BigInteger newValue) {
BigInteger oldValue = value;
value = newValue;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
IrPackage.EXPR_INT__VALUE, oldValue, value));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Type getType() {
return type;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy())
return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (value: ");
result.append(value);
result.append(')');
return result.toString();
}
public ExprInt xor(ExprInt expr) {
return new ExprIntImpl(getValue().xor(expr.getValue()));
}
} // ExprIntImpl