I need help with understanding with a piece code
信息
此问题已关闭。 请重新打开它进行编辑或回答。
显示 更早的评论
Hello, my name is Michael and I am currently working on a matlab heavy project. The project is a matlab compiler for compiling Simulink programs, created with project intern library, into assembler. My predecessor wrote the compiler, but sadly he didn't comment very well the source code and I can't contact him. So, he worte a function in his compiler, which creates the assembler source code file. In this function he builds an optimisation method, with which, he reduces the number of used variables. I need help with understanding this piece of code, so I came here, looking for help. Here is the code snippet:
if ~strcmp(graph(name).type, 'Outport')
% reduce number of used variable
% default variable name
signal_name = node.arguments{3};
% replace variable when flag is set and not needed for Mov & Mov_*
if optimizing && OPTIMISATIONS('reduce_variables') && ...
~strcmp('Mov', node.type(1:3)) && ~strcmp(node.arguments{3}, '?')
% check if a free name is available
for key = refs.keys
var_name = key{1};
% check if variable is free for reusage
% only constants can have negative ref counts
if refs(var_name) < 1 && var_name(1) ~= '_'
signal_name = var_name;
break;
end
end
end
% special case for i.e. wbnone
if ~strcmp(signal_name, '?')
% determine number of references to signal_names
% to avoid code duplicate often overwritten input arguments
ref_add = update_references(graph, node.arguments{3}, node.next, ...
signal_name);
refs(signal_name) = ref_add;
node.arguments{3} = signal_name;
end
end
end
Thanks for help and greetings from Germany.
0 个评论
回答(0 个)
此问题已关闭。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!