From 17cecc36cf581dda8b909dfcaf60cd1563e2e5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=96stlund?= Date: Thu, 9 Feb 2017 12:20:55 +0100 Subject: [PATCH] Change getCommandLineOptions to return an array. --- Compiler/FrontEnd/ModelicaBuiltin.mo | 6 ++--- Compiler/Script/CevalScript.mo | 2 +- Compiler/Util/Flags.mo | 34 ++++++++++++---------------- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/Compiler/FrontEnd/ModelicaBuiltin.mo b/Compiler/FrontEnd/ModelicaBuiltin.mo index 84c48941c66..886609d8089 100644 --- a/Compiler/FrontEnd/ModelicaBuiltin.mo +++ b/Compiler/FrontEnd/ModelicaBuiltin.mo @@ -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; diff --git a/Compiler/Script/CevalScript.mo b/Compiler/Script/CevalScript.mo index 4063ab4fe0f..f11a2e168be 100644 --- a/Compiler/Script/CevalScript.mo +++ b/Compiler/Script/CevalScript.mo @@ -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); diff --git a/Compiler/Util/Flags.mo b/Compiler/Util/Flags.mo index 9eafd0833df..65991d2c8eb 100644 --- a/Compiler/Util/Flags.mo +++ b/Compiler/Util/Flags.mo @@ -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 flagStrings = {}; protected Flags flags; array debug_flags; array config_flags; - list strl = {}; String name; + list 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;