Skip to content

Commit

Permalink
- Added clearCommandLineOptions API command.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16504 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Jun 27, 2013
1 parent 445c5d1 commit b62572e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
6 changes: 6 additions & 0 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1294,6 +1294,12 @@ external "builtin";
annotation(preferredView="text");
end setCommandLineOptions;

function clearCommandLineOptions
"Resets all commdand-line flags to their default values."
external "builtin";
annotation(preferredView="text");
end clearCommandLineOptions;

function getVersion "Returns the version of the Modelica compiler."
input TypeName cl := $TypeName(OpenModelica);
output String version;
Expand Down
10 changes: 10 additions & 0 deletions Compiler/Script/CevalScript.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,16 @@ algorithm
case (cache,env,"setCommandLineOptions",_,st,_)
then (cache,Values.BOOL(false),st);

case (cache,env,"clearCommandLineOptions",{},st,_)
equation
Flags.resetDebugFlags();
Flags.resetConfigFlags();
then
(cache,Values.BOOL(true),st);

case (cache,env,"clearCommandLineOptions",_,st,_)
then (cache,Values.BOOL(false),st);

case (cache,env,"cd",{Values.STRING("")},st,_)
equation
str_1 = System.pwd();
Expand Down
49 changes: 36 additions & 13 deletions Compiler/Util/Flags.mo
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ encapsulated package Flags

Debug flags are boolean flags specified with +d, which can be used together
with the Debug package. They are typically used to enable printing of extra
information that helps debugging, such as the failtrace flag. All debug flags
are initialized to disabled, unlike configuration flags which have a specified
default value.
information that helps debugging, such as the failtrace flag. Unlike
configuration flags they are only on or off, i.e. true or false.

To add a new flag, simply add a new constant of either DebugFlag or ConfigFlag
type below, and then add it to either the allDebugFlags or allConfigFlags list
Expand Down Expand Up @@ -797,6 +796,22 @@ algorithm
setGlobalRoot(Global.flagsIndex, inFlags);
end saveFlags;

protected function createConfigFlags
output array<FlagData> outConfigFlags;
protected
Integer count;
algorithm
count := listLength(allConfigFlags);
outConfigFlags := arrayCreate(count, EMPTY_FLAG());
_ := List.fold1(allConfigFlags, setDefaultConfig, outConfigFlags, 1);
end createConfigFlags;

protected function createDebugFlags
output array<Boolean> outDebugFlags;
algorithm
outDebugFlags := listArray(List.map(allDebugFlags, defaultDebugFlag));
end createDebugFlags;

protected function loadFlags
"Loads the flags with getGlobalRoot. Creates a new flags structure if it
hasn't been created yet."
Expand All @@ -818,29 +833,37 @@ algorithm
else
equation
_ = List.fold(allDebugFlags, checkDebugFlag, 1);
config_count = listLength(allConfigFlags);
debug_flags = listArray(List.map(allDebugFlags,defaultDebugFlag));
config_flags = arrayCreate(config_count, EMPTY_FLAG());
_ = List.fold1(allConfigFlags, setDefaultConfig, config_flags, 1);
debug_flags = createDebugFlags();
config_flags = createConfigFlags();
flags = FLAGS(debug_flags, config_flags);
saveFlags(flags);
then
flags;

end matchcontinue;
end loadFlags;

public function resetDebugFlags
"Resets all debug flags to their default values."
protected
array<Boolean> debug_flags;
array<FlagData> config_flags;
algorithm
FLAGS(_, config_flags) := loadFlags();
debug_flags := createDebugFlags();
saveFlags(FLAGS(debug_flags, config_flags));
end resetDebugFlags;

public function clearDebugFlags
"Sets all the debug flags to false."
public function resetConfigFlags
"Resets all configuration flags to their default values."
protected
array<Boolean> debug_flags;
array<FlagData> config_flags;
Flags flags;
algorithm
debug_flags := listArray(List.map(allDebugFlags,defaultDebugFlag));
FLAGS(configFlags = config_flags) := loadFlags();
FLAGS(debug_flags, _) := loadFlags();
config_flags := createConfigFlags();
saveFlags(FLAGS(debug_flags, config_flags));
end clearDebugFlags;
end resetConfigFlags;

protected function checkDebugFlag
"Used when creating a new flags structure (in loadFlags) to check that a debug
Expand Down

0 comments on commit b62572e

Please sign in to comment.