Skip to content

Commit

Permalink
- added flag +showErrorMessages to show error messages while they hap…
Browse files Browse the repository at this point in the history
…pen.

  + the flag is used in Print.printErrorBuf
- disable the ClassLoader.loadCompletePackageFromMp failure message as it might happen because
  of directories with no .mo files.
- return the entire program in Interactive.getTotalModel as we have missing functionality right now.


git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/MathCoreOSMC@3774 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Dec 15, 2008
1 parent 5e72615 commit a690e2f
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 31 deletions.
19 changes: 9 additions & 10 deletions Compiler/Ceval.mo
Expand Up @@ -3838,12 +3838,11 @@ algorithm

case (cache,env,className,(st as Interactive.SYMBOLTABLE(ast = p,explodedAst = sp,instClsLst = ic,lstVarVal = iv,compiledFunctions = cf)),msg)
equation
_ = Error.getMessagesStr() "Clear messages";
Print.clearErrorBuf() "Clear error buffer";
ptot = Interactive.getTotalProgram(className,p);
//(cache,dae as DAE.DAE(dael),env) = checkModelInstantiateCall(cache,ptot, className);

//(cache,dae as DAE.DAE(dael),env) = checkModelInstantiateCall(cache,ptot, className);
Absyn.CLASS(_,_,_,_,Absyn.R_FUNCTION(),_,_) = Interactive.getPathedClassInProgram(className, p);
_ = Error.getMessagesStr() "Clear messages";
Print.clearErrorBuf() "Clear error buffer";
p_1 = SCode.elaborate(ptot);
(cache, dae as DAE.DAE(dael), env) = Inst.instantiateFunctionImplicit(inCache, p_1, className);

Expand All @@ -3856,13 +3855,13 @@ algorithm
(cache,Values.STRING(retStr),st);

case (cache,env,className,st,_) local
String errorMsg; Boolean strEmpty;
String errorMsg; Boolean strEmpty; String errorBuffer;
equation
classNameStr = Absyn.pathString(className);
errorMsg = Error.printMessagesStr();
strEmpty = (System.strcmp("",errorMsg)==0);
errorMsg = Util.if_(strEmpty,"Internal error, check of model failed with no error message.",errorMsg);
errorMsg = errorMsg +& selectIfNotEmpty("Error Buffer:\n", Print.getErrorString());
// errorMsg = errorMsg +& selectIfNotEmpty("Error Buffer:\n", Print.getErrorString());
then (cache,Values.STRING(errorMsg),st);

end matchcontinue;
Expand Down Expand Up @@ -7629,10 +7628,10 @@ algorithm
local Integer res;
case (inStr)
equation
res = System.stringFind(inStr, "Internal");
res = System.stringFind(inStr, "successfully");
true = (res >= 0);
then "FAILED!";
case (_) then "OK";
then "OK";
case (_) then "FAILED!";
end matchcontinue;
end failOrSuccess;

Expand Down Expand Up @@ -7674,7 +7673,7 @@ algorithm
// filter out packages
false = Interactive.isPackage(cr, p);
// filter out functions
false = Interactive.isFunction(cr, p);
// false = Interactive.isFunction(cr, p);
// filter out types
false = Interactive.isType(cr, p);
print("Checking: " +& Dump.unparseClassAttributesStr(c) +& " " +& Absyn.pathString(className) +& "... ");
Expand Down
3 changes: 2 additions & 1 deletion Compiler/ClassLoader.mo
Expand Up @@ -300,7 +300,8 @@ algorithm

case (_,_,_,_)
equation
print("ClassLoader.loadCompletePackageFromMp failed\n");
// adrpo: not needed as it might fail due to no package file!
// print("ClassLoader.loadCompletePackageFromMp failed\n");
then fail();

end matchcontinue;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/DAELow.mo
Expand Up @@ -6786,7 +6786,7 @@ algorithm
list<CrefIndex> vs;
case (cr,{})
equation
Debug.fprint("failtrace", "-DAELow.getVar3 failed on:" +& Exp.printComponentRefStr(cr) +& "\n");
//Debug.fprint("failtrace", "-DAELow.getVar3 failed on:" +& Exp.printComponentRefStr(cr) +& "\n");
then
fail();
case (cr,(CREFINDEX(cref = cr2,index = v) :: _))
Expand Down
5 changes: 4 additions & 1 deletion Compiler/Interactive.mo
Expand Up @@ -17443,7 +17443,9 @@ Retrieves a total program for a model by only building dependencies for the affe
input Absyn.Program p;
output Absyn.Program outP;
algorithm
outP := matchcontinue(modelName,p)
outP := p;
/*
matchcontinue(modelName,p)
local AbsynDep.Depends dep; AbsynDep.AvlTree uses; Absyn.Program p2,p1;
case(modelName,p) equation
dep = getTotalProgram2(modelName,p);
Expand All @@ -17454,6 +17456,7 @@ algorithm
p = updateProgram(p1,p2);
then p;
end matchcontinue;
*/
end getTotalProgram;

protected function getTotalProgram2 "Help function to getTotalProgram"
Expand Down
3 changes: 2 additions & 1 deletion Compiler/Main.mo
Expand Up @@ -934,7 +934,8 @@ algorithm
print("\t+annotationVersion=1.x what annotation version should we use\n");
print("\t accept 1.x or 2.x (default) or 3.x\n");
print("\t+q run in quiet mode, ouput nothing\n");
print("\t+metaModelica accept MetaModelica grammar and semantics\n");
print("\t+metaModelica accept MetaModelica grammar and semantics\n");
print("\t+showErrorMessages show error messages while they happen; default to no. \n");
print("\t+d=flags set debug flags: \n");
print("\t+d=bltdump dump the blt form\n");
print("\t+d=failtrace print what function fail\n");
Expand Down
42 changes: 27 additions & 15 deletions Compiler/runtime/printimpl.c
Expand Up @@ -55,7 +55,7 @@ void Print_5finit(void)
int print_error_buf_impl(char *str)
{
/* printf("cursize: %d, nfilled %d, strlen: %d\n",cursize,nfilled,strlen(str));*/

if (str == NULL) {
return -1;
}
Expand All @@ -75,9 +75,9 @@ RML_BEGIN_LABEL(Print__setBufSize)
{
int newSize = (int)RML_IMMEDIATE(RML_UNTAGFIXNUM(rmlA0));
if (newSize > 0) {
printf(" setting init_size to: %d\n",newSize);
printf(" setting init_size to: %d\n",newSize);
increase_buffer_fixed(newSize);
}
}
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL
Expand All @@ -90,15 +90,22 @@ RML_BEGIN_LABEL(Print__unSetBufSize)
}
RML_END_LABEL

extern int showErrorMessages;

RML_BEGIN_LABEL(Print__printErrorBuf)
{
char* str = RML_STRINGDATA(rmlA0);

if (showErrorMessages) /* adrpo: should we show error messages while they happen? */
{
fprintf(stderr, "%s", str);
fflush(stderr);
}

if (print_error_buf_impl(str) != 0) {
RML_TAILCALLK(rmlFC);
}

/* printf("%s",str);*/


RML_TAILCALLK(rmlSC);
}
RML_END_LABEL
Expand All @@ -107,7 +114,10 @@ RML_BEGIN_LABEL(Print__clearErrorBuf)
{
errorNfilled=0;
if (errorBuf != 0) {
errorBuf[0]='\0';
/* adrpo 2008-12-15 free the error buffer as it might have got quite big meantime */
free(errorBuf);
errorBuf = NULL;
errorCursize=0;
}

RML_TAILCALLK(rmlSC);
Expand All @@ -132,7 +142,7 @@ RML_BEGIN_LABEL(Print__printBuf)
{
char* str = RML_STRINGDATA(rmlA0);
/* printf("cursize: %d, nfilled %d, strlen: %d\n",cursize,nfilled,strlen(str));*/

while (nfilled + strlen(str)+1 > cursize) {
if(increase_buffer()!= 0) {
RML_TAILCALLK(rmlFC);
Expand All @@ -151,7 +161,9 @@ RML_BEGIN_LABEL(Print__clearBuf)
{
nfilled=0;
if (buf != 0) {
buf[0]='\0';
/* adrpo 2008-12-15 free the print buffer as it might have got quite big meantime */
buf = NULL;
cursize = 0;
}

RML_TAILCALLK(rmlSC);
Expand All @@ -177,9 +189,9 @@ RML_BEGIN_LABEL(Print__writeBuf)
FILE * file;

file = fopen(filename,"w");

if (file == NULL || buf == NULL || buf[0]=='\0') {
/* HOWTO: RML fail */
/* HOWTO: RML fail */
/* RML_TAILCALLK(rmlFC); */
}

Expand All @@ -190,13 +202,13 @@ RML_BEGIN_LABEL(Print__writeBuf)
/* RMLFAIL */
/* RML_TAILCALLK(rmlFC); */
}

RML_TAILCALLK(rmlSC);
}
RML_END_LABEL


int increase_buffer(void)
int increase_buffer(void)
{
char * new_buf;
int new_size;
Expand Down Expand Up @@ -243,9 +255,9 @@ int increase_buffer_fixed(int increase)
}
buf = new_buf;
return 0;
}
}

int error_increase_buffer(void)
int error_increase_buffer(void)
{
char * new_buf;
int new_size;
Expand Down
21 changes: 19 additions & 2 deletions Compiler/runtime/rtopts.c
Expand Up @@ -83,6 +83,12 @@ extern char* corbaSessionName;
*/
char* annotation_version = "2.x";

/*
* adrpo 2008-12-15
* flag +showErrorMessages for printing all messages comming to the error buffer
*/
int showErrorMessages = 0;

void RTOpts_5finit(void)
{
type_info = 0;
Expand All @@ -100,6 +106,7 @@ void RTOpts_5finit(void)
corbaSessionName = 0;
acceptedGrammar = GRAMMAR_MODELICA;
annotation_version = "2.x";
showErrorMessages = 0;
}

/*
Expand Down Expand Up @@ -242,12 +249,12 @@ int check_debug_flag(char const* strdata)
return flg;
}


#define VERSION_OPT1 "++v"
#define VERSION_OPT2 "+version"
#define ANNOTATION_VERSION "+annotationVersion"
#define TARGET "+target"
#define METAMODELICA "+g"
#define SHOW_ERROR_MESSAGES "+showErrorMessages"

RML_BEGIN_LABEL(RTOpts__args)
{
Expand All @@ -256,7 +263,7 @@ RML_BEGIN_LABEL(RTOpts__args)
int strLen_TARGET = strlen(TARGET);
int strLen_METAMODELICA = strlen(METAMODELICA);
int strLen_ANNNOTATION_VERSION = strlen(ANNOTATION_VERSION);
debug_none = 1;
int strLen_SHOW_ERROR_MESSAGES = strlen(SHOW_ERROR_MESSAGES);

debug_none = 1;

Expand Down Expand Up @@ -306,6 +313,16 @@ RML_BEGIN_LABEL(RTOpts__args)
RML_TAILCALLK(rmlFC);
}
}
else if(strncmp(arg,SHOW_ERROR_MESSAGES,strLen_SHOW_ERROR_MESSAGES) == 0)
{
if (strlen(arg) == strLen_SHOW_ERROR_MESSAGES)
showErrorMessages = 1;
else
{
fprintf(stderr, "# Wrong option: usage: omc [+showErrorMessages], default to not show them.\n");
RML_TAILCALLK(rmlFC);
}
}
else if (arg[0] == '+')
{
if (strlen(arg) < 2)
Expand Down

0 comments on commit a690e2f

Please sign in to comment.