Originally, I have two MATLAB files: main.m and myIfElse.m.
function z = main(x)
n = x + 1;
z = zeros(1,n);
for i = 1:n
z(i) = myIfElse(i,1);
end
end
function z = myIfElse(a, b)
z = a - 1;
if(a > b)
z = b + 1;
end
end
After I get the TameIR of the two files and save it for each file as follows (mainIR.m and myIfElseIR.m).
function [z] = mainIR(x)
mc_t9 = 1;
[n] = plus(x, mc_t9);
mc_t10 = 1;
[z] = zeros(mc_t10, n);
mc_t12 = 1;
for i = (mc_t12 : n);
mc_t11 = 1;
mc_t8 = myIfElse(i, mc_t11);
z(i) = mc_t8;
end
end
function [z] = myIfElseIR(a, b)
mc_t13 = 1;
[z] = minus(a, mc_t13);
[mc_t15] = gt(a, b);
if mc_t15
mc_t14 = 1;
[z] = plus(b, mc_t14);
else
end
end
I feed the TamerPlus with mainIR.m and myIfElseIR.m that it is expected to produce the 'same' code as the original code. But the user defined function myIfElseIR disappears in the main function mainIR. Maybe I should not use the program which contains temporary variables (e.g. mc_10).
% After Tamer plus
function [z] = mainIR(x)
[n] = plus(x, mc_t9);
[z] = zeros(mc_t10, n);
for i = (mc_t12 : n);
z(i) = mc_t8; %one line is missing
end
end
function [z] = myIfElse(a, b)
[z] = minus(a, 1);
if gt(a, b)
[z] = plus(b, 1);
else
end
end
The Java code I used to invoke TamerPlus is listed below.
for(StaticFunction f : localAnalysis.getFunctionCollection().getAllFunctions()){
PrintMessage.See(TransformationEngine.forAST(f.getAst())
.getTIRToMcSAFIRWithoutTemp()
.getTransformedTree()
.getPrettyPrinted());
}
Originally, I have two MATLAB files:
main.m
andmyIfElse.m
.After I get the TameIR of the two files and save it for each file as follows (
mainIR.m
andmyIfElseIR.m
).I feed the TamerPlus with
mainIR.m
andmyIfElseIR.m
that it is expected to produce the 'same' code as the original code. But the user defined functionmyIfElseIR
disappears in the main functionmainIR
. Maybe I should not use the program which contains temporary variables (e.g.mc_10
).The Java code I used to invoke TamerPlus is listed below.