Skip to content

Commit

Permalink
Add flag +d=printStructuralParameters to print the names of structu…
Browse files Browse the repository at this point in the history
…ral parameters evaluated by the front-end

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@20733 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed May 21, 2014
1 parent 9afe9f3 commit bb4ad8d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
25 changes: 24 additions & 1 deletion Compiler/FrontEnd/DAEUtil.mo
Expand Up @@ -5929,14 +5929,37 @@ public function transformationsBeforeBackend
output DAE.DAElist outDAElist;
protected
list<DAE.Element> elts;
HashTable.HashTable ht;
algorithm
DAE.DAE(elts) := inDAElist;
elts := List.map1(elts, makeEvaluatedParamFinal, Env.getEvaluatedParams(cache));
ht := Env.getEvaluatedParams(cache);
elts := List.map1(elts, makeEvaluatedParamFinal, ht);
Debug.bcall(Flags.isSet(Flags.PRINT_STRUCTURAL), transformationsBeforeBackendNotification, ht);
outDAElist := DAE.DAE(elts);
// Don't even run the function to try and do this; it doesn't work very well
// outDAElist := transformDerInline(outDAElist);
end transformationsBeforeBackend;

protected function transformationsBeforeBackendNotification
input HashTable.HashTable ht;
algorithm
_ := matchcontinue ht
local
list<DAE.ComponentRef> crs;
list<String> strs;
String str;
case _
equation
(crs as _::_) = BaseHashTable.hashTableKeyList(ht);
strs = List.map(crs, ComponentReference.printComponentRefStr);
strs = List.sort(strs, Util.strcmpBool);
str = stringDelimitList(strs, ", ");
Error.addMessage(Error.NOTIFY_FRONTEND_STRUCTURAL_PARAMETERS, {str});
then ();
else ();
end matchcontinue;
end transformationsBeforeBackendNotification;

protected function makeEvaluatedParamFinal "
This function makes all evaluated parameters final."
input DAE.Element inElement;
Expand Down
10 changes: 1 addition & 9 deletions Compiler/FrontEnd/InstSection.mo
Expand Up @@ -3236,14 +3236,6 @@ algorithm
end matchcontinue;
end checkConstantVariability;

protected function stringGte
input String s1;
input String s2;
output Boolean b;
algorithm
b := stringCompare(s1, s2) >= 0;
end stringGte;

protected function connectExpandableConnectors
"@author: adrpo
this function handle the connections of expandable connectors"
Expand Down Expand Up @@ -3333,7 +3325,7 @@ algorithm
// Debug.fprintln(Flags.EXPANDABLE, "Variables2: " +& stringDelimitList(variables2, ", "));
variablesUnion = List.union(variables1, variables2);
// sort so we have them in order
variablesUnion = List.sort(variablesUnion, stringGte);
variablesUnion = List.sort(variablesUnion, Util.strcmpBool);
// Debug.fprintln(Flags.EXPANDABLE, "Union of expandable connector variables: " +& stringDelimitList(variablesUnion, ", "));

// Debug.fprintln(Flags.EXPANDABLE, "2 connect(expandable, expandable)(" +& PrefixUtil.printPrefixStrIgnoreNoPre(pre) +& "." +& Dump.printComponentRefStr(c1) +& ", " +& PrefixUtil.printPrefixStrIgnoreNoPre(pre) +& "." +& Dump.printComponentRefStr(c2) +& ")");
Expand Down
4 changes: 3 additions & 1 deletion Compiler/Util/Error.mo
Expand Up @@ -651,8 +651,10 @@ public constant Message ARG_TYPE_MISMATCH = MESSAGE(245, TRANSLATION(), ERROR(),
Util.gettext("Type mismatch for positional argument %s in %s(%s=%s). The argument has type:\n %s\nexpected type:\n %s"));
public constant Message OP_OVERLOAD_MULTIPLE_VALID = MESSAGE(246, TRANSLATION(), ERROR(),
Util.gettext("Operator overloading requires exactly one matching expression, but found %s expressions: %s"));
public constant Message OP_OVERLOAD_OPERATOR_NOT_INPUT = MESSAGE(246, TRANSLATION(), ERROR(),
public constant Message OP_OVERLOAD_OPERATOR_NOT_INPUT = MESSAGE(247, TRANSLATION(), ERROR(),
Util.gettext("Operator %s is not an input to the overloaded function: %s"));
public constant Message NOTIFY_FRONTEND_STRUCTURAL_PARAMETERS = MESSAGE(248, TRANSLATION(), NOTIFICATION(),
Util.gettext("The following structural parameters were evaluated in the front-end: %s\nStructural parameters are parameters used to calculate array dimensions or branch selection in certain if-equations or if-expressions among other things."));

public constant Message UNBOUND_PARAMETER_WITH_START_VALUE_WARNING = MESSAGE(499, TRANSLATION(), WARNING(),
Util.gettext("Parameter %s has no value, and is fixed during initialization (fixed=true), using available start value (start=%s) as default value."));
Expand Down
5 changes: 4 additions & 1 deletion Compiler/Util/Flags.mo
Expand Up @@ -387,6 +387,8 @@ constant DebugFlag IMPL_ODE = DEBUG_FLAG(110, "implOde", false,
Util.gettext("activates implicit codegen"));
constant DebugFlag EVAL_FUNC_DUMP = DEBUG_FLAG(111, "evalFuncDump", false,
Util.gettext("dumps debug information about the function evaluation"));
constant DebugFlag PRINT_STRUCTURAL = DEBUG_FLAG(112, "printStructuralParameters", false,
Util.gettext("Prints the structural parameters identified by the front-end"));

// This is a list of all debug flags, to keep track of which flags are used. A
// flag can not be used unless it's in this list, and the list is checked at
Expand Down Expand Up @@ -503,7 +505,8 @@ constant list<DebugFlag> allDebugFlags = {
HPCOM_ANALYZATION_MODE,
STRICT_RML,
IMPL_ODE,
EVAL_FUNC_DUMP
EVAL_FUNC_DUMP,
PRINT_STRUCTURAL
};

// CONFIGURATION FLAGS
Expand Down

0 comments on commit bb4ad8d

Please sign in to comment.