Home » Modeling » Epsilon » Global variables in EGL(Definition of EGL global variables )
| | | |
Re: Global variables in EGL [message #1750624 is a reply to message #1750622] |
Fri, 23 December 2016 12:36 |
Víctor López Messages: 22 Registered: June 2014 |
Junior Member |
|
|
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/
|
|
| | |
Goto Forum:
Current Time: Tue Sep 24 10:20:14 GMT 2024
Powered by FUDForum. Page generated in 0.05068 seconds
|