Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » additional function
additional function [message #1385616] Tue, 10 June 2014 00:24 Go to next message
thomas nobre is currently offline thomas nobre
Messages: 5
Registered: May 2014
Junior Member
hi,

i got a question toward the use of ATL. I got an ATL transformation between two language (Cometa and C) and i would like to create an additional function which is supposed to set the type of a variable.

here is the function:

rule set_varType(theVarType: String, theVariable: SynC!Variable) {

do{
if(theVarType.oclIsUndefined() or theVarType.size(0)) {
thisModule.debug('\t/!\\\tError: Variable Type empty !');
}
if(theVariable.oclIsUndefined()) {
thisModule.debug('\t/!\\\tError: Variable null, unable to set type !');

}
if (theVarType = 'bool' or theVarType = 'boolean'){
theVariable.isArray <- false;
theVariable.type <- thisModule.bool;
}
else if(theVarType = '*bool' or theVarType = '*boolean'){
theVariable.isArray <- false;
theVariable.type <- thisModule.bool;
theVariable.isPointer<-true;

}
else if(theVarType = 'bool[]' or theVarType = 'boolean[]'){
theVariable.isArray <- true;
theVariable.type <- thisModule.bool;
theVariable.isPointer<-false;

}
else if (theVarType = 'char' or theVarType = 'character'){
theVariable.isArray <- false;
theVariable.type <- thisModule.char;
}
else if(theVarType = '*char' or theVarType = '*character'){
theVariable.isArray <- false;
theVariable.type <- thisModule.char;
theVariable.isPointer<-true;

}
else if(theVarType = 'char[]' or theVarType = 'character[]'){
theVariable.isArray <- true;
theVariable.type <- thisModule.char;
theVariable.isPointer<-false;

}
else if (theVarType = 'short' or theVarType = 'short int' or theVarType = 'short integer'){
theVariable.isArray <- false;
theVariable.type <- thisModule.short;
}
else if(theVarType = '*short' or theVarType = '*short int' or theVarType = '*short integer'){
theVariable.isArray <- false;
theVariable.type <- thisModule.short;
theVariable.isPointer<-true;

}
else if(theVarType = 'int' or theVarType = 'integer'){
theVariable.isArray <- false;
theVariable.type <- thisModule.int;

}
else if(theVarType = '*int' or theVarType = '*integer'){
theVariable.isArray <- false;
theVariable.type <- thisModule.int;
theVariable.isPointer<-true;

}
else if(theVarType = 'int[]' or theVarType = 'integer[]'){
theVariable.isArray <- true;
theVariable.type <- thisModule.int;
theVariable.isPointer<-false;
}
else if(theVarType = 'float'){
theVariable.isArray <- false;
theVariable.type <- thisModule.float;

}
else if(theVarType = '*float'){
theVariable.isArray <- false;
theVariable.type <- thisModule.float;
theVariable.isPointer<-true;

}
else if(theVarType = 'long'){
theVariable.isArray <- false;
theVariable.type <- thisModule.long;

}
else if(theVarType = '*long'){
theVariable.isArray <- false;
theVariable.type <- thisModule.long;
theVariable.isPointer<-true;

}
else if(theVarType = 'unsigned int'){
theVariable.isArray <- false;
theVariable.type <- thisModule.unsigned_int;

}
else if(theVarType = 'unsigned char'){
theVariable.isArray <- false;
theVariable.type <- thisModule.unsigned_char;

}
else if(theVarType = '*unsigned char'){
theVariable.isArray <- false;
theVariable.type <- thisModule.unsigned_char;
theVariable.isPointer<-true;

}
else if (theVarType.startsWith('**')){

}
else if (theVarType = 'fifo'){
theVariable.type -> thisModule.fifo;
theVariable.isArray <- false;
}
}
}

but when i create this called rule my ATL transformation freeze and eclipse bug... I have not bug in ATL but i think maybe this function is to heavy and i would like to know if it's possible in ATL to create an additional module that i could import into my "main" module. Because i didn't succeed to write this rule as a helper in order to use a library.

Any help will be appreciated.

thomas
Re: additional function [message #1385636 is a reply to message #1385616] Tue, 10 June 2014 04:13 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARD
Messages: 522
Registered: July 2009
Senior Member
You can use superimposition in order to divide your transformation in multiple atl files.
Re: additional function [message #1385661 is a reply to message #1385636] Tue, 10 June 2014 06:07 Go to previous messageGo to next message
thomas nobre is currently offline thomas nobre
Messages: 5
Registered: May 2014
Junior Member
Have you some exemple of use of superimposition ? Cause i had never see it even in ATL user guide.

Thx, thomas
Re: additional function [message #1385692 is a reply to message #1385661] Tue, 10 June 2014 10:23 Go to previous message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARD
Messages: 522
Registered: July 2009
Senior Member
See here and there
Previous Topic:[EMFTVM] writing to console
Next Topic:[ATL API] Launch ATL transf with cross-references
Goto Forum:
  


Current Time: Fri Aug 22 15:56:10 EDT 2014

Powered by FUDForum. Page generated in 0.02341 seconds