Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » helper context overlap for base data types?
helper context overlap for base data types? [message #1853941] Mon, 25 July 2022 09:12 Go to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
I have the following two helpers - both in the context of a base data type:

-- @atlcompiler atl2010

helper context Integer def: lit(): otx!IntegerLiteral =
	thisModule.createIntegerLiteral(self);

helper context String def: lit(): otx!StringLiteral =
	thisModule.createStringLiteral(self);


This yields the error message "helper 'lit' already defined" for both of them, so the compiler (ATL 4.6) does not seem to be able to separate their contexts. As overloading helpers should be possible according to the documentation (at least as far as I understand it), and works flawlessly for actual model data types, I assume that this might be a bug.
Any known workaround except for using differently named helpers?
Re: helper context overlap for base data types? [message #1853957 is a reply to message #1853941] Mon, 25 July 2022 17:29 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

Yes, that's a bug. Does it happen for any of the other compilers?

Cheers,
Dennis
Re: helper context overlap for base data types? [message #1853964 is a reply to message #1853941] Tue, 26 July 2022 07:53 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
Seems to work fine with EMFTVM.
Re: helper context overlap for base data types? [message #1853970 is a reply to message #1853964] Tue, 26 July 2022 11:56 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
...and it compiles no problem if I put the helpers of the same name into different modules (vulgo ATL files). Haven't yet tested runtime, though...
Re: helper context overlap for base data types? [message #1854226 is a reply to message #1853941] Mon, 08 August 2022 13:09 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
I've tested the compiled code now (atl2010, EMFVM), with the overloaded helper spread across different modules.
It seems to be impossible to define helper for raw data types, although it is mentioned multiple times here:
https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.m2m.atl.doc%2Fguide%2Fuser%2FOverview-of-the-Atlas-Transformation-Language.html
Calling
helper context Integer def: lit(): o!IntegerLiteral =
	thisModule.createIntegerLiteral(self); -- defined elsewhere

lazy rule DiagComPrimitive2RepeatedExecution {
	from
		source: t!DiagComPrimitive,
		interval: Integer
	to
		setRepetitionTime: o!SetRepetitionTime(
			diagService <- source.createTerm(),
			repetitionTime <- interval.lit()
		), -- ...
}

results in:
org.eclipse.m2m.atl.engine.emfvm.VMException: Operation not found: 500.lit()

Re: helper context overlap for base data types? [message #1854252 is a reply to message #1853941] Tue, 09 August 2022 08:39 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
I've created two simplified test modules where defining and calling helpers on raw types works just fine. Helpers of the same name in the context of different raw types can be defined and used, if they are in different modules.
I haven't yet found out what's the problem in my production modules, as the helpers are in the same constellation there. Probably something about more complex superimposition scenarios?
Re: helper context overlap for base data types? [message #1854258 is a reply to message #1854252] Tue, 09 August 2022 11:56 Go to previous messageGo to next message
Gunnar Arndt is currently offline Gunnar ArndtFriend
Messages: 82
Registered: June 2012
Member
Update: The problem seems to be that the '500' in the previous example is not an Integer, but an ELongObject, which is represented as OclAny in ATL. Maybe I'll have to change my input model to only contain regular Integers.
Is there an overview how Ecore data types are represented in ATL? Does only EInt become ATL-Integer? What about EIntegerObject?
Re: helper context overlap for base data types? [message #1854409 is a reply to message #1854258] Wed, 17 August 2022 15:45 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 581
Registered: September 2012
Location: Belgium
Senior Member

These are the data types that ATL supports: https://wiki.eclipse.org/ATL/User_Guide_-_The_ATL_Language#Data_types

The mapping to EMF/Java types is not part of any ATL specification, and each VM can define its own mapping. That said, the mapping choices for primitive types are all the same:


All other EMF/Ecore data types are mapped to OclAny in ATL: you can invoke methods on them, but not primitive type operations.


Cheers,
Dennis
Previous Topic:How can I tranform a feature of the Parent class accessing from the chield class?
Next Topic:OCL closure operation
Goto Forum:
  


Current Time: Sat Nov 11 08:17:02 GMT 2023

Powered by FUDForum. Page generated in 0.02271 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top