|Re: EClassifier for primitive variables [message #52159 is a reply to message #52106]
||Tue, 04 March 2008 14:28
Originally posted by: cdamus.ca.ibm.com|
The EcoreEnvironment maps EInt, EIntegerObject, and friends to the Integer
primitive type from the OCL Standard Library when used as the types of
ETypedElements in the model. That is automatic. Because OCL knows how to
define operations for its own data types, but EDataTypes generally cannot
express operations, this is important for '+' etc. to work.
The same type mapping is not done for Variables because OCL Variables cannot
occur in a model (in particular, they have no relation to the UML construct
of the same name). If you are creating your own Variables and adding them
to an Environment, then you need to use the OCL-defined standard types
It sounds from your last remark that you are trying to do this
(OCLStandardLibrary::getInteger() is the right way). Why is it not
working? I don't know what you mean by the result being an EObject. The
OCL Integer type is not a class; its instances are not EObjects.
Stefan Schulze wrote:
> how can I define a context-variable of a primitive type like an integer?
> As the most simple example, I want to evaluate "a+a" after setting "a" as
> an integer-variable with value "1" in the (Evaluation)Environment.
> If I set EcorePackage.Literals.EINT as variable-type, I get a
> SemanticException about "Cannot find operation (+(EInt)) for the type
> If I set TypesPackage.eINSTANCE.getPrimitiveType() as variable-type, I get
> a SemanticException about "Cannot find operation (+(PrimitiveType)) for
> the type (PrimitiveType).
> I thought about using Environment#getOCLStandardLibrary().getInteger(),
> but that didn't work, because the result is an EObject but I need an
> EClassifier for Variable#setType(...).
Powered by FUDForum
. Page generated in 0.16241 seconds