additional function [message #1385616] |
Tue, 10 June 2014 00:24  |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05608 seconds