Home » Modeling » Epsilon » Global variables in EGL(Definition of EGL global variables )
Global variables in EGL [message #1750608] |
Fri, 23 December 2016 04:30  |
Eclipse User |
|
|
|
Hi all!,
I wonder if it is possible to specify a global variable in an EGL file so that variable is available in both the templates and the rest of the EGL file. For instance, imagine defining an enumeration to be used in both templates and the rest of the EGL.
I don't know how to do it (if it is possible) so the global variable is available also in the templates.
Best,
Víctor
|
|
| | | |
Re: Global variables in EGL [message #1750624 is a reply to message #1750622] |
Fri, 23 December 2016 07:36   |
Eclipse User |
|
|
|
Thanks a lot Dimitris.
I found another scenario closely related where global variables are not working as I expected.
Imagine this egx file to transform an UML Class:
rule testCase
transform aClass: Class {
template: "test.egl"
target: "gen/src/" + aClass.name.firstToUpperCase() + ".java"
parameters {
// These parameters will be made available
// to the invoked template as variables
var params : new Map;
params.put("allIntegerTypes", Set{'int', 'integer', 'tinyint', 'smallint', 'mediumint', 'bigint', 'long', 'unsigned int', 'unsigned long', 'short', 'byte'});
return params;
}
}
An this egl file:
/********************************************************/
/* Class: [%=aClass.name.concat('.java').pad(45,' ',true)%]*/
/* Testing global variables */
/********************************************************/
{
The size of the set is: [%=allIntegerTypes.size() %] [this is working]
[%= aClass.test()%] [this is not working, allIntegerTypes is undefined in the template ]
}
[% @template
operation Class test() { %]
The size of the set in this templates is: [%=allIntegerTypes.size() %]
[% } %]
I was expecting allIntegerTypes to be available within the template, but it isn't. Is it the expected behaviour?
Best,
Víctor López
Dimitris Kolovos wrote on Fri, 23 December 2016 13:09Hi Victor,
I see what you mean. I've fixed this in [1] so top-level variables should now be accessible from sub-templates invoked using [%include("foo.egl");%]. Once Hudson has finished building the new interim version [2] you can pick up a copy from [3]. Many thanks for reporting this!
Cheers,
Dimitris
[1] https://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/commit/?id=d04d07b8d7da9febfd96729ca9ec14be6886c299
[2] https://hudson.eclipse.org/epsilon/job/epsilon-interim-update-site/189/
[3] http://download.eclipse.org/epsilon/interim/
|
|
| |
Re: Global variables in EGL [message #1750628 is a reply to message #1750626] |
Fri, 23 December 2016 07:55  |
Eclipse User |
|
|
|
Hi Dimitris,
Thanks for your quick reply.
Yes it is working on Interim version, but it isn't on 1.4 version.
I'll use the interim version in the meantime.
Best,
Víctor López
Dimitris Kolovos wrote on Fri, 23 December 2016 13:45Hi Victor,
With a quick test, this seems to be working fine on my side with the latest interim version (i.e. global variables are visible within @template operations). Could you please put together a minimal example [1] I can use to reproduce this?
Cheers,
Dimitris
[1] https://www.eclipse.org/epsilon/doc/articles/minimal-examples/
|
|
|
Goto Forum:
Current Time: Tue Jul 08 07:30:43 EDT 2025
Powered by FUDForum. Page generated in 0.07336 seconds
|