Skip to content

Commit

Permalink
Change getCommandLineOptions to return an array.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Feb 9, 2017
1 parent 674967b commit 17cecc3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -1536,9 +1536,9 @@ annotation(preferredView="text");
end setCommandLineOptions;

function getCommandLineOptions
"Returns all command line options who have non-default values as a string.
The format of the string is '--flag=value --flag2=value2'."
output String flags;
"Returns all command line options who have non-default values as a list of
strings. The format of the strings is '--flag=value --flag2=value2'."
output String[:] flags;
external "builtin";
annotation(preferredView="text");
end getCommandLineOptions;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Script/CevalScript.mo
Expand Up @@ -944,7 +944,7 @@ algorithm
then (cache,Values.BOOL(false),st);

case (cache, _, "getCommandLineOptions", {}, st, _)
then (cache, Values.STRING(Flags.unparseFlags()), st);
then (cache, ValuesUtil.makeStringArray(Flags.unparseFlags()), st);

case (cache, _, "getCommandLineOptions", _, st, _)
then (cache, Values.BOOL(false), st);
Expand Down
34 changes: 14 additions & 20 deletions Compiler/Util/Flags.mo
Expand Up @@ -2968,47 +2968,41 @@ algorithm
end flagDataString;

function unparseFlags
"Goes through all the existing flags, and each flag whose value differs from
the default is added to the output string as flag=value."
output String str = "";
"Goes through all the existing flags, and returns a list of all flags with
values that differ from the default. The format of each string is flag=value."
output list<String> flagStrings = {};
protected
Flags flags;
array<Boolean> debug_flags;
array<FlagData> config_flags;
list<String> strl = {};
String name;
list<String> strl = {};
algorithm
try
FLAGS(debugFlags = debug_flags, configFlags = config_flags) := loadFlags(false);
else
str := "";
return;
end try;

for f in allDebugFlags loop
if f.default <> debug_flags[f.index] then
strl := f.name :: strl;
end if;
end for;

if not listEmpty(strl) then
str := "-d=" + stringDelimitList(strl, ",");
end if;

strl := {};
for f in allConfigFlags loop
if not flagDataEq(f.defaultValue, config_flags[f.index]) then
name := match f.shortname
case SOME(name) then " -" + name;
else " --" + f.name;
case SOME(name) then "-" + name;
else "--" + f.name;
end match;

strl := (name + "=" + flagDataString(config_flags[f.index])) :: strl;
flagStrings := (name + "=" + flagDataString(config_flags[f.index])) :: flagStrings;
end if;
end for;

for f in allDebugFlags loop
if f.default <> debug_flags[f.index] then
strl := f.name :: strl;
end if;
end for;

if not listEmpty(strl) then
str := str + stringAppendList(strl);
flagStrings := "-d=" + stringDelimitList(strl, ",") :: flagStrings;
end if;
end unparseFlags;

Expand Down

0 comments on commit 17cecc3

Please sign in to comment.