blob: c3d031b6aff2ac58a1a7b4a816de42393f46d03f [file] [log] [blame]
/**
* * Copyright (c) 2006-2010 Istvan Rath and Daniel Varro
* * All rights reserved. This program and the accompanying materials
* * are made available under the terms of the Eclipse Public License v1.0
* * which accompanies this distribution, and is available at
* * http://www.eclipse.org/legal/epl-v10.html
* *
* * Contributors:
* * Istvan Rath, Daniel Varro - initial API and implementation
*
*/
package org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl;
import java.util.Collection;
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.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.ASMFunction;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.DefinitionsPackage;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.InitialValue;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.Machine;
import org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.TypeConstant;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>ASM Function</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.ASMFunctionImpl#getInitialValues <em>Initial Values</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.ASMFunctionImpl#getArity <em>Arity</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.ASMFunctionImpl#getNamespace <em>Namespace</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.ASMFunctionImpl#getReturnType <em>Return Type</em>}</li>
* <li>{@link org.eclipse.viatra2.gtasmmodel.gtasm.metamodel.asm.definitions.impl.ASMFunctionImpl#getArgumentTypes <em>Argument Types</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class ASMFunctionImpl extends FunctionDefinitionImpl implements ASMFunction
{
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final String copyright = " * Copyright (c) 2006-2010 Istvan Rath and Daniel Varro\r\n * All rights reserved. This program and the accompanying materials\r\n * are made available under the terms of the Eclipse Public License v1.0\r\n * which accompanies this distribution, and is available at\r\n * http://www.eclipse.org/legal/epl-v10.html\r\n *\r\n * Contributors:\r\n * Istvan Rath, Daniel Varro - initial API and implementation\r\n";
/**
* The cached value of the '{@link #getInitialValues() <em>Initial Values</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getInitialValues()
* @generated
* @ordered
*/
protected EList<InitialValue> initialValues;
/**
* The default value of the '{@link #getArity() <em>Arity</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getArity()
* @generated
* @ordered
*/
protected static final int ARITY_EDEFAULT = 0;
/**
* The cached value of the '{@link #getArity() <em>Arity</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getArity()
* @generated
* @ordered
*/
protected int arity = ARITY_EDEFAULT;
/**
* The cached value of the '{@link #getReturnType() <em>Return Type</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getReturnType()
* @generated
* @ordered
*/
protected TypeConstant returnType;
/**
* The cached value of the '{@link #getArgumentTypes() <em>Argument Types</em>}' containment reference list.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getArgumentTypes()
* @generated
* @ordered
*/
protected EList<TypeConstant> argumentTypes;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected ASMFunctionImpl()
{
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass()
{
return DefinitionsPackage.Literals.ASM_FUNCTION;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<InitialValue> getInitialValues()
{
if (initialValues == null)
{
initialValues = new EObjectContainmentEList<InitialValue>(InitialValue.class, this, DefinitionsPackage.ASM_FUNCTION__INITIAL_VALUES);
}
return initialValues;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int getArity()
{
return arity;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setArity(int newArity)
{
int oldArity = arity;
arity = newArity;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.ASM_FUNCTION__ARITY, oldArity, arity));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Machine getNamespace()
{
if (eContainerFeatureID() != DefinitionsPackage.ASM_FUNCTION__NAMESPACE) return null;
return (Machine)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetNamespace(Machine newNamespace, NotificationChain msgs)
{
msgs = eBasicSetContainer((InternalEObject)newNamespace, DefinitionsPackage.ASM_FUNCTION__NAMESPACE, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setNamespace(Machine newNamespace)
{
if (newNamespace != eInternalContainer() || (eContainerFeatureID() != DefinitionsPackage.ASM_FUNCTION__NAMESPACE && newNamespace != null))
{
if (EcoreUtil.isAncestor(this, newNamespace))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newNamespace != null)
msgs = ((InternalEObject)newNamespace).eInverseAdd(this, DefinitionsPackage.MACHINE__ASM_FUNCTION_DEFINITIONS, Machine.class, msgs);
msgs = basicSetNamespace(newNamespace, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.ASM_FUNCTION__NAMESPACE, newNamespace, newNamespace));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public TypeConstant getReturnType()
{
return returnType;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetReturnType(TypeConstant newReturnType, NotificationChain msgs)
{
TypeConstant oldReturnType = returnType;
returnType = newReturnType;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DefinitionsPackage.ASM_FUNCTION__RETURN_TYPE, oldReturnType, newReturnType);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setReturnType(TypeConstant newReturnType)
{
if (newReturnType != returnType)
{
NotificationChain msgs = null;
if (returnType != null)
msgs = ((InternalEObject)returnType).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DefinitionsPackage.ASM_FUNCTION__RETURN_TYPE, null, msgs);
if (newReturnType != null)
msgs = ((InternalEObject)newReturnType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DefinitionsPackage.ASM_FUNCTION__RETURN_TYPE, null, msgs);
msgs = basicSetReturnType(newReturnType, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, DefinitionsPackage.ASM_FUNCTION__RETURN_TYPE, newReturnType, newReturnType));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EList<TypeConstant> getArgumentTypes()
{
if (argumentTypes == null)
{
argumentTypes = new EObjectContainmentEList<TypeConstant>(TypeConstant.class, this, DefinitionsPackage.ASM_FUNCTION__ARGUMENT_TYPES);
}
return argumentTypes;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs)
{
switch (featureID)
{
case DefinitionsPackage.ASM_FUNCTION__NAMESPACE:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetNamespace((Machine)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 DefinitionsPackage.ASM_FUNCTION__INITIAL_VALUES:
return ((InternalEList<?>)getInitialValues()).basicRemove(otherEnd, msgs);
case DefinitionsPackage.ASM_FUNCTION__NAMESPACE:
return basicSetNamespace(null, msgs);
case DefinitionsPackage.ASM_FUNCTION__RETURN_TYPE:
return basicSetReturnType(null, msgs);
case DefinitionsPackage.ASM_FUNCTION__ARGUMENT_TYPES:
return ((InternalEList<?>)getArgumentTypes()).basicRemove(otherEnd, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs)
{
switch (eContainerFeatureID())
{
case DefinitionsPackage.ASM_FUNCTION__NAMESPACE:
return eInternalContainer().eInverseRemove(this, DefinitionsPackage.MACHINE__ASM_FUNCTION_DEFINITIONS, Machine.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType)
{
switch (featureID)
{
case DefinitionsPackage.ASM_FUNCTION__INITIAL_VALUES:
return getInitialValues();
case DefinitionsPackage.ASM_FUNCTION__ARITY:
return getArity();
case DefinitionsPackage.ASM_FUNCTION__NAMESPACE:
return getNamespace();
case DefinitionsPackage.ASM_FUNCTION__RETURN_TYPE:
return getReturnType();
case DefinitionsPackage.ASM_FUNCTION__ARGUMENT_TYPES:
return getArgumentTypes();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue)
{
switch (featureID)
{
case DefinitionsPackage.ASM_FUNCTION__INITIAL_VALUES:
getInitialValues().clear();
getInitialValues().addAll((Collection<? extends InitialValue>)newValue);
return;
case DefinitionsPackage.ASM_FUNCTION__ARITY:
setArity((Integer)newValue);
return;
case DefinitionsPackage.ASM_FUNCTION__NAMESPACE:
setNamespace((Machine)newValue);
return;
case DefinitionsPackage.ASM_FUNCTION__RETURN_TYPE:
setReturnType((TypeConstant)newValue);
return;
case DefinitionsPackage.ASM_FUNCTION__ARGUMENT_TYPES:
getArgumentTypes().clear();
getArgumentTypes().addAll((Collection<? extends TypeConstant>)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID)
{
switch (featureID)
{
case DefinitionsPackage.ASM_FUNCTION__INITIAL_VALUES:
getInitialValues().clear();
return;
case DefinitionsPackage.ASM_FUNCTION__ARITY:
setArity(ARITY_EDEFAULT);
return;
case DefinitionsPackage.ASM_FUNCTION__NAMESPACE:
setNamespace((Machine)null);
return;
case DefinitionsPackage.ASM_FUNCTION__RETURN_TYPE:
setReturnType((TypeConstant)null);
return;
case DefinitionsPackage.ASM_FUNCTION__ARGUMENT_TYPES:
getArgumentTypes().clear();
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID)
{
switch (featureID)
{
case DefinitionsPackage.ASM_FUNCTION__INITIAL_VALUES:
return initialValues != null && !initialValues.isEmpty();
case DefinitionsPackage.ASM_FUNCTION__ARITY:
return arity != ARITY_EDEFAULT;
case DefinitionsPackage.ASM_FUNCTION__NAMESPACE:
return getNamespace() != null;
case DefinitionsPackage.ASM_FUNCTION__RETURN_TYPE:
return returnType != null;
case DefinitionsPackage.ASM_FUNCTION__ARGUMENT_TYPES:
return argumentTypes != null && !argumentTypes.isEmpty();
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString()
{
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (arity: ");
result.append(arity);
result.append(')');
return result.toString();
}
} //ASMFunctionImpl