Skip to content

Commit

Permalink
- record construction vectorization in Static.elabCallArgs
Browse files Browse the repository at this point in the history
  + testsuite/mofiles/RecordConstructorVectorization.mo
  + this is used in Modelica.Media for FluidConstants.
- disabled stdout printing Type mismatch in equation and changed testsuite/mosfiles/ArrayDivError.mos to match
- check the +s and +showErrorMessages command line parameters and display an error if they are wrong
- display the error message for the flags just once in Main.mo
- added Debug.trace[ln] to print the errors unguarded by debug flags and used this functionality
  to print some of the failtrace guarded by true = RTOpts.debugFlag("failtrace"); 
  This way is faster as no more building of strings happen.
- beautified code and added some comments; got rid of some really old commented out RML code 
- added check for setDebugFlags in CevalScript.mo


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4582 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Nov 26, 2009
1 parent 0275b46 commit 7ab9693
Show file tree
Hide file tree
Showing 12 changed files with 802 additions and 845 deletions.
30 changes: 0 additions & 30 deletions Compiler/Absyn.mo
Expand Up @@ -3165,36 +3165,6 @@ algorithm
end matchcontinue;
end setClassName;

// Use Dump.printExpStr instead
/*
public function printAbsynExp "function: printAbsynExp
Prints an Exp"
input Exp inExp;
algorithm
_:=
matchcontinue (inExp)
local list<ComponentCondition> es;
case (ARRAY(arrayExp = es))
equation
Debug.print("This is an array: ");
Debug.print("[");
Debug.print("]");
then
();
case (TUPLE(expressions = es))
equation
Debug.print("(");
Debug.print(")");
then
();
case (_)
equation
Debug.print("\nNo tuple.");
then
();
end matchcontinue;
end printAbsynExp;*/

public function crefEqual "function: crefEqual
Checks if the name of a ComponentRef is
equal to the name of another ComponentRef, including subscripts.
Expand Down
16 changes: 10 additions & 6 deletions Compiler/Algorithm.mo
Expand Up @@ -59,6 +59,7 @@ public type Statement = DAE.Statement;
public type Else = DAE.Else;

protected import Debug;
protected import RTOpts;
protected import Error;
protected import Exp;
protected import Print;
Expand Down Expand Up @@ -265,8 +266,7 @@ public function makeTupleAssignment "function: makeTupleAssignment
input SCode.Initial initial_;
output Statement outStatement;
algorithm
outStatement:=
matchcontinue (inExpExpLst,inTypesPropertiesLst,inExp,inProperties,initial_)
outStatement := matchcontinue (inExpExpLst,inTypesPropertiesLst,inExp,inProperties,initial_)
local
list<DAE.Const> bvals;
list<Ident> sl;
Expand Down Expand Up @@ -305,13 +305,17 @@ algorithm
DAE.C_VAR() = Util.listReduce(bvals, Types.constOr);
lhrtypes = Util.listMap(lhprops, Types.getPropType);
Types.matchTypeTupleCall(rhs, tpl, lhrtypes);
/* Don\'t use new rhs\', since type conversions of several output args
are not clearly defined. */
/* Don\'t use new rhs\', since type conversions of several output args are not clearly defined. */
then
DAE.STMT_TUPLE_ASSIGN(DAE.ET_OTHER(),expl,rhs);
case (lhs,lprop,rhs,rprop,_)
equation
Debug.fprint("failtrace", "- Algorithm.makeTupleAssignment failed\n");
equation
true = RTOpts.debugFlag("failtrace");
sl = Util.listMap(lhs, Exp.printExpStr);
s = Util.stringDelimitList(sl, ", ");
lhs_str = Util.stringAppendList({"(",s,")"});
rhs_str = Exp.printExpStr(rhs);
Debug.traceln("- Algorithm.makeTupleAssignment failed on: " +& lhs_str +& " = " +& rhs_str);
then
fail();
end matchcontinue;
Expand Down
7 changes: 7 additions & 0 deletions Compiler/CevalScript.mo
Expand Up @@ -1815,6 +1815,13 @@ algorithm
then
(cache,Values.BOOL(true),st);
case (cache,env,DAE.CALL(path = Absyn.IDENT(name = "setDebugFlags"),expLst = {DAE.SCONST(string = str)}),(st as Interactive.SYMBOLTABLE(ast = p,explodedAst = sp,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf)),msg)
equation
str_1 = stringAppend("+d=", str);
failure(args = RTOpts.args({str_1}));
then
(cache,Values.BOOL(false),st);
case (cache,env,DAE.CALL(path = Absyn.IDENT(name = "cd"),expLst = {DAE.SCONST(string = str)}),(st as Interactive.SYMBOLTABLE(ast = p,explodedAst = sp,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf)),msg)
local Integer res;
equation
Expand Down
140 changes: 70 additions & 70 deletions Compiler/Debug.mo
Expand Up @@ -43,31 +43,46 @@ package Debug
fprint(\"inst\", \"Starting instantiation...\"). See runtime/rtopts.c for
implementation of flag checking."


protected import RTOpts;
protected import Print;
protected import Util;

public function print "function: print
author: PR
This function is used for debug printing.
"
public function print
"function: print
author: PR
This function is used for debug printing."
input String s;
algorithm
fprint("olddebug", s);
end print;

public function fprint "function: fprint
author: LS
Flag controlled debugging
"
public function trace
"function: print
author: adrpo
used for debug printing."
input String s;
algorithm
Print.printErrorBuf(s);
end trace;

public function traceln
"function: traceln
author: adrpo
printing with newline."
input String str;
algorithm
Print.printErrorBuf(str);
Print.printErrorBuf("\n");
end traceln;

public function fprint
"function: fprint
author: LS
Flag controlled debugging"
input String inString1;
input String inString2;
algorithm
_:=
matchcontinue (inString1,inString2)
_ := matchcontinue (inString1,inString2)
local String flag,str;
case (flag,str)
equation
Expand All @@ -79,15 +94,13 @@ algorithm
end matchcontinue;
end fprint;

public function fprintln "function: fprintln
Flag controlled debugging, printing with newline.
"
public function fprintln
"function: fprintln
Flag controlled debugging, printing with newline."
input String inString1;
input String inString2;
algorithm
_:=
matchcontinue (inString1,inString2)
_ := matchcontinue (inString1,inString2)
local String flag,str;
case (flag,str)
equation
Expand All @@ -100,15 +113,13 @@ algorithm
end matchcontinue;
end fprintln;

public function fprintl "function: fprintl
flag controlled debugging, printing of string list.
"
public function fprintl
"function: fprintl
flag controlled debugging, printing of string list."
input String inString;
input list<String> inStringLst;
algorithm
_:=
matchcontinue (inString,inStringLst)
_ := matchcontinue (inString,inStringLst)
local
String str,flag;
list<String> strlist;
Expand Down Expand Up @@ -181,17 +192,15 @@ algorithm
end matchcontinue;
end fcall;

public function fcall0 "function: fcall0
Flag controlled calling of given function (2nd arg)
"
public function fcall0
"function: fcall0
Flag controlled calling of given function (2nd arg)"
input String inString;
input FuncTypeTo inFuncTypeTo;
partial function FuncTypeTo
end FuncTypeTo;
algorithm
_:=
matchcontinue (inString,inFuncTypeTo)
_ := matchcontinue (inString,inFuncTypeTo)
local
String flag;
FuncTypeTo func;
Expand All @@ -205,11 +214,10 @@ algorithm
end matchcontinue;
end fcall0;

public function fcallret "function: fcallret
public function fcallret
"function: fcallret
Flag controlled calling of given function (2nd arg).
The passed functions return value is returned.
"
The passed functions return value is returned."
input String inString;
input FuncTypeType_aToType_b inFuncTypeTypeAToTypeB;
input Type_a inTypeA;
Expand All @@ -224,8 +232,7 @@ public function fcallret "function: fcallret
replaceable type Type_a subtypeof Any;
replaceable type Type_b subtypeof Any;
algorithm
outTypeB:=
matchcontinue (inString,inFuncTypeTypeAToTypeB,inTypeA,inTypeB)
outTypeB := matchcontinue (inString,inFuncTypeTypeAToTypeB,inTypeA,inTypeB)
local
Type_b res,def;
String flag;
Expand All @@ -241,10 +248,9 @@ algorithm
end matchcontinue;
end fcallret;

public function bcall "function: bcall
bool controlled calling of function.
"
public function bcall
"function: bcall
bool controlled calling of function."
input Boolean inBoolean;
input FuncTypeType_aTo inFuncTypeTypeATo;
input Type_a inTypeA;
Expand All @@ -254,8 +260,7 @@ public function bcall "function: bcall
end FuncTypeType_aTo;
replaceable type Type_a subtypeof Any;
algorithm
_:=
matchcontinue (inBoolean,inFuncTypeTypeATo,inTypeA)
_ := matchcontinue (inBoolean,inFuncTypeTypeATo,inTypeA)
local
FuncTypeType_aTo func;
Type_a str;
Expand All @@ -268,10 +273,9 @@ algorithm
end matchcontinue;
end bcall;

public function bcall2 "function: bcall2
bool controlled calling of function.
"
public function bcall2
"function: bcall2
bool controlled calling of function."
input Boolean inBoolean;
input FuncTypeType_aType_bTo inFuncTypeTypeATypeBTo;
input Type_a inTypeA;
Expand All @@ -285,8 +289,7 @@ public function bcall2 "function: bcall2
replaceable type Type_a subtypeof Any;
replaceable type Type_b subtypeof Any;
algorithm
_:=
matchcontinue (inBoolean,inFuncTypeTypeATypeBTo,inTypeA,inTypeB)
_ := matchcontinue (inBoolean,inFuncTypeTypeATypeBTo,inTypeA,inTypeB)
local
FuncTypeType_aType_bTo func;
Type_a a;
Expand All @@ -300,11 +303,11 @@ algorithm
end matchcontinue;
end bcall2;

public function notfcall "function: notfcall
Call the given function (2nd arg) if the flag given in 1st arg is
NOT set
"
public function notfcall
"function: notfcall
Call the given function (2nd arg)
if the flag given in 1st arg is
NOT set"
input String inString;
input FuncTypeType_aTo inFuncTypeTypeATo;
input Type_a inTypeA;
Expand All @@ -314,8 +317,7 @@ public function notfcall "function: notfcall
end FuncTypeType_aTo;
replaceable type Type_a subtypeof Any;
algorithm
_:=
matchcontinue (inString,inFuncTypeTypeATo,inTypeA)
_ := matchcontinue (inString,inFuncTypeTypeATo,inTypeA)
local
String flag;
FuncTypeType_aTo func;
Expand All @@ -330,11 +332,10 @@ algorithm
end matchcontinue;
end notfcall;

public function fprintList "function: fprintList
If flag is set, print the elements in the list, using the passed
function.
"
public function fprintList
"function: fprintList
If flag is set, print the elements in
the list, using the passed function."
input String inString1;
input list<Type_a> inTypeALst2;
input FuncTypeType_aTo inFuncTypeTypeATo3;
Expand All @@ -344,8 +345,7 @@ public function fprintList "function: fprintList
input Type_a inTypeA;
end FuncTypeType_aTo;
algorithm
_:=
matchcontinue (inString1,inTypeALst2,inFuncTypeTypeATo3,inString4)
_ := matchcontinue (inString1,inTypeALst2,inFuncTypeTypeATo3,inString4)
local
String flag,sep;
list<Type_a> lst;
Expand All @@ -360,11 +360,10 @@ algorithm
end matchcontinue;
end fprintList;

protected function printList "function: fprintList
If flag is set, print the elements in the list, using the passed
function.
"
protected function printList
"function: fprintList
If flag is set, print the elements in
the list, using the passed function."
input list<Type_a> inTypeALst;
input FuncTypeType_aTo inFuncTypeTypeATo;
input String inString;
Expand All @@ -373,8 +372,7 @@ protected function printList "function: fprintList
input Type_a inTypeA;
end FuncTypeType_aTo;
algorithm
_:=
matchcontinue (inTypeALst,inFuncTypeTypeATo,inString)
_ := matchcontinue (inTypeALst,inFuncTypeTypeATo,inString)
local
Type_a h;
FuncTypeType_aTo r;
Expand All @@ -395,5 +393,7 @@ algorithm
();
end matchcontinue;
end printList;


end Debug;

7 changes: 3 additions & 4 deletions Compiler/Dump.mo
Expand Up @@ -3960,10 +3960,9 @@ algorithm
end matchcontinue;
end printNamedArg;

protected function printNamedArgStr "function: printNamedArgStr

Prettyprint NamedArg to a string.
"
public function printNamedArgStr
"function: printNamedArgStr
Prettyprint NamedArg to a string."
input Absyn.NamedArg inNamedArg;
output String outString;
algorithm
Expand Down

0 comments on commit 7ab9693

Please sign in to comment.