Skip to content

Commit

Permalink
- Made the dumping of external declarations better.
Browse files Browse the repository at this point in the history
- Changed so that only constant complex equations are constant evaluated in
  InstSection.instEqEquation2.
- Added handling of integers in omc-diff, so that integers are compared exactly
  (otherwise we allow a relative error for line numbers in errors).


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9758 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Sep 8, 2011
1 parent 3c1fa65 commit fbdf37d
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 111 deletions.
28 changes: 14 additions & 14 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -3565,26 +3565,26 @@ qualified part, and ident part (all_but_last, last);
input Path inPath;
output Path outPath1;
output Path outPath2;
algorithm (outPath1,outPath2) := matchcontinue(inPath)
algorithm (outPath1,outPath2) := match(inPath)
local
Path qPath,curPath,identPath;
String s1,s2;
case (QUALIFIED(name = s1,path = IDENT(name = s2))) then(IDENT(s1),IDENT(s2));
case(QUALIFIED(name=s1, path=qPath)) equation
(curPath,identPath) = splitQualAndIdentPath(qPath);
then (QUALIFIED(s1,curPath),identPath);
case(FULLYQUALIFIED(qPath))

case (QUALIFIED(name = s1, path = IDENT(name = s2)))
then (IDENT(s1), IDENT(s2));

case (QUALIFIED(name = s1, path = qPath))
equation
(curPath,identPath) = splitQualAndIdentPath(qPath);
then
(curPath,identPath);
case(qPath)
(curPath, identPath) = splitQualAndIdentPath(qPath);
then
(QUALIFIED(s1, curPath), identPath);

case (FULLYQUALIFIED(qPath))
equation
print(" Failure in: " +& pathString(qPath) +& "\n");
(curPath, identPath) = splitQualAndIdentPath(qPath);
then
fail();
case(_) equation print(" failure in splitQualAndIdentPath\n"); then fail();
end matchcontinue;
(curPath, identPath);
end match;
end splitQualAndIdentPath;

public function stripFirst "function: stripFirst
Expand Down
31 changes: 20 additions & 11 deletions Compiler/FrontEnd/Ceval.mo
Expand Up @@ -1173,9 +1173,9 @@ algorithm
(cache,newval,st);

// This case prevents the constructor call of external objects of being evaluated
case (cache,env,(e as DAE.CALL(path = funcpath,expLst = expl)),vallst,impl,st,msg)
case (cache,env as _ :: _,(e as DAE.CALL(path = funcpath,expLst = expl)),vallst,impl,st,msg)
equation
cevalIsExternalObjectConstructor(cache,funcpath,env);
cevalIsExternalObjectConstructor(cache,funcpath,env,msg);
then
fail();

Expand All @@ -1193,7 +1193,7 @@ algorithm
case (cache,env, DAE.CALL(path = funcpath, attr = DAE.CALL_ATTR(builtin = false)), vallst, impl, st, msg)
equation
false = RTOpts.debugFlag("noevalfunc");
failure(cevalIsExternalObjectConstructor(cache, funcpath, env));
failure(cevalIsExternalObjectConstructor(cache, funcpath, env, msg));
Debug.fprintln("dynload", "CALL: try constant evaluation: " +& Absyn.pathString(funcpath));
(cache,
sc as SCode.CLASS(
Expand Down Expand Up @@ -1221,7 +1221,7 @@ algorithm
(st as SOME(Interactive.SYMBOLTABLE(p as Absyn.PROGRAM(globalBuildTimes=Absyn.TIMESTAMP(_,edit)),_,_,_,_,cflist,_))),msg)
equation
false = RTOpts.debugFlag("nogen");
failure(cevalIsExternalObjectConstructor(cache,funcpath,env));
failure(cevalIsExternalObjectConstructor(cache,funcpath,env,msg));

Debug.fprintln("dynload", "CALL: [func from file] check if is in CF list: " +& Absyn.pathString(funcpath));

Expand All @@ -1242,7 +1242,7 @@ algorithm
(st as SOME(Interactive.SYMBOLTABLE(p as Absyn.PROGRAM(globalBuildTimes=Absyn.TIMESTAMP(_,edit)),_,_,_,_,cflist,_))),msg)
equation
false = RTOpts.debugFlag("nogen");
failure(cevalIsExternalObjectConstructor(cache,funcpath,env));
failure(cevalIsExternalObjectConstructor(cache,funcpath,env,msg));

Debug.fprintln("dynload", "CALL: [func from buffer] check if is in CF list: " +& Absyn.pathString(funcpath));

Expand All @@ -1266,7 +1266,7 @@ algorithm
SOME(Interactive.SYMBOLTABLE(p as Absyn.PROGRAM(globalBuildTimes=ts),aDep,a,b,c,cf,lf)),msg) // yeha! we have a symboltable!
equation
false = RTOpts.debugFlag("nogen");
failure(cevalIsExternalObjectConstructor(cache,funcpath,env));
failure(cevalIsExternalObjectConstructor(cache,funcpath,env,msg));

Debug.fprintln("dynload", "CALL: [SOME SYMTAB] not in in CF list: " +& Absyn.pathString(funcpath));

Expand Down Expand Up @@ -1308,7 +1308,7 @@ algorithm
case (cache,env,(e as DAE.CALL(path = funcpath,expLst = expl,attr = DAE.CALL_ATTR(builtin = false))),vallst,impl,NONE(),msg) // crap! we have no symboltable!
equation
false = RTOpts.debugFlag("nogen");
failure(cevalIsExternalObjectConstructor(cache,funcpath,env));
failure(cevalIsExternalObjectConstructor(cache,funcpath,env,msg));

Debug.fprintln("dynload", "CALL: [NO SYMTAB] not in in CF list: " +& Absyn.pathString(funcpath));

Expand Down Expand Up @@ -1345,14 +1345,23 @@ protected function cevalIsExternalObjectConstructor
input Env.Cache cache;
input Absyn.Path funcpath;
input Env.Env env;
input Msg msg;
protected
Absyn.Path funcpath2;
DAE.Type tp;
Option<Absyn.Info> info;
algorithm
"constructor" := Absyn.pathLastIdent(funcpath);
funcpath2:=Absyn.stripLast(funcpath);
(_,tp,_) := Lookup.lookupType(cache,env,funcpath2,SOME(Absyn.dummyInfo));
Types.externalObjectConstructorType(tp);
_ := match(cache, funcpath, env, msg)
case (_, _, {}, NO_MSG()) then fail();
case (_, _, _, NO_MSG())
equation
(funcpath2, Absyn.IDENT("constructor")) = Absyn.splitQualAndIdentPath(funcpath);
info = Util.if_(Util.isEqual(msg, NO_MSG()), NONE(), SOME(Absyn.dummyInfo));
(_, tp, _) = Lookup.lookupType(cache, env, funcpath2, info);
Types.externalObjectConstructorType(tp);
then
();
end match;
end cevalIsExternalObjectConstructor;

protected function cevalKnownExternalFuncs "function: cevalKnownExternalFuncs
Expand Down
57 changes: 28 additions & 29 deletions Compiler/FrontEnd/DAEDump.mo
Expand Up @@ -469,11 +469,10 @@ algorithm
DAE.ExtArg retty;
case DAE.EXTERNALDECL(name = id,args = extargs,returnArg = retty,language = lang)
equation
extargsstr = Dump.getStringList(extargs, dumpExtArgStr, ",");
extargsstr = Dump.getStringList(extargs, dumpExtArgStr, ", ");
rettystr = dumpExtArgStr(retty);
str = stringAppendList(
{"EXTERNALDECL(",id,", (",extargsstr,"), ",rettystr,", \"",
lang,"\")"});
rettystr = Util.if_(stringEq(rettystr, ""), rettystr, rettystr +& " = ");
str = stringAppendList({"external \"", lang, "\" ", rettystr, id,"(",extargsstr,");"});
then
str;
end matchcontinue;
Expand All @@ -496,27 +495,22 @@ algorithm
DAE.Exp exp,dim;
DAE.Attributes attr;

case DAE.NOEXTARG() then "void";
case DAE.NOEXTARG() then "";
case DAE.EXTARG(componentRef = cr,attributes = DAE.ATTR(flowPrefix = fl,streamPrefix=st,variability = var,direction = dir),type_ = ty)
equation
crstr = ComponentReference.printComponentRefStr(cr);
dirstr = Dump.directionSymbol(dir);
tystr = Types.getTypeName(ty);
str = stringAppendList({dirstr," ",tystr," ",crstr});
then
str;
crstr;
case DAE.EXTARGEXP(exp = exp,type_ = ty)
equation
crstr = ExpressionDump.printExpStr(exp);
tystr = Types.getTypeName(ty);
str = stringAppendList({"(",tystr,") ",crstr});
then
str;
crstr;
case DAE.EXTARGSIZE(componentRef = cr,attributes = attr,type_ = ty,exp = dim)
equation
crstr = ComponentReference.printComponentRefStr(cr);
dimstr = ExpressionDump.printExpStr(dim);
str = stringAppendList({"size(",crstr,",",dimstr,")"});
str = stringAppendList({"size(",crstr,", ",dimstr,")"});
then
str;
end matchcontinue;
Expand Down Expand Up @@ -1319,13 +1313,13 @@ protected function dumpFunction
algorithm
_ := matchcontinue (inElement)
local
String fstr,inlineTypeStr,daestr,str;
String fstr,inlineTypeStr,daestr,str, ext_decl_str;
Absyn.Path fpath;
list<DAE.Element> daeElts;
DAE.Type t;
DAE.InlineType inlineType;
String lang;
Option<SCode.Comment> c;
DAE.ExternalDecl ext_decl;

case DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_DEF(body = daeElts)::_),type_ = t, comment = c)
equation
Expand All @@ -1347,7 +1341,7 @@ algorithm
then
();

case DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_EXT(body = daeElts, externalDecl = DAE.EXTERNALDECL(language=lang))::_),type_ = t, comment = c)
case DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_EXT(body = daeElts, externalDecl = ext_decl)::_),type_ = t, comment = c)
equation
Print.printBuf("function ");
fstr = Absyn.pathStringNoQual(fpath);
Expand All @@ -1357,11 +1351,11 @@ algorithm
Print.printBuf(dumpCommentOptionStr(c));
Print.printBuf("\n");
dumpFunctionElements(daeElts);
Print.printBuf("\n external \"C\";\n");
ext_decl_str = dumpExtDeclStr(ext_decl);
Print.printBuf("\n " +& ext_decl_str +& "\n");
Print.printBuf("end ");
Print.printBuf(fstr);
Print.printBuf(";\n\n");

then
();

Expand Down Expand Up @@ -2742,9 +2736,6 @@ algorithm
// classify DAE
(v,ie,ia,e,a,o) = DAEUtil.splitElements(l);

// dump objects
str = IOStream.appendList(str, Util.listMap(o, dumpExtObjClassStr));

// dump variables
str = dumpVarsStream(v, false, str);

Expand Down Expand Up @@ -3299,14 +3290,20 @@ protected function dumpExtObjClassStr
algorithm
outString := matchcontinue (inElement)
local
String fstr,str,c_str,d_str;
String s1, s2;
Absyn.Path fpath;
case DAE.EXTOBJECTCLASS(path = fpath)

case DAE.EXTOBJECTCLASS(path = _)
equation
fstr = Absyn.pathString(fpath);
str = stringAppendList({"class ",fstr,"\n extends ExternalObject;\nend ",fstr,";\n"});
s1 = Print.getString();
Print.clearBuf();
dumpExtObjectClass(inElement);
s2 = Print.getString();
Print.clearBuf();
Print.printBuf(s1);
then
str;
s2;

case _ then "";
end matchcontinue;
end dumpExtObjClassStr;
Expand All @@ -3320,14 +3317,15 @@ protected function dumpFunctionStream
algorithm
outStream := matchcontinue (inElement, inStream)
local
String fstr, lang;
String fstr, ext_decl_str;
Absyn.Path fpath;
list<DAE.Element> daeElts;
DAE.Type t;
DAE.Type tp;
DAE.InlineType inlineType;
IOStream.IOStream str;
Option<SCode.Comment> c;
DAE.ExternalDecl ext_decl;

case (DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_DEF(body = daeElts)::_),type_ = t, comment = c), str)
equation
Expand All @@ -3348,7 +3346,7 @@ algorithm
then
str;

case (DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_EXT(body = daeElts, externalDecl = DAE.EXTERNALDECL(language=lang))::_),type_ = t, comment = c), str)
case (DAE.FUNCTION(path = fpath,inlineType=inlineType,functions = (DAE.FUNCTION_EXT(body = daeElts, externalDecl = ext_decl)::_),type_ = t, comment = c), str)
equation
fstr = Absyn.pathStringNoQual(fpath);
str = IOStream.append(str, "function ");
Expand All @@ -3357,7 +3355,8 @@ algorithm
str = IOStream.append(str, dumpCommentOptionStr(c));
str = IOStream.append(str, "\n");
str = dumpFunctionElementsStream(daeElts, str);
str = IOStream.appendList(str, {"\n external \"",lang,"\";\nend ",fstr,";\n\n"});
ext_decl_str = dumpExtDeclStr(ext_decl);
str = IOStream.appendList(str, {"\n ", ext_decl_str, "\nend ", fstr, ";\n\n"});
then
str;

Expand Down

0 comments on commit fbdf37d

Please sign in to comment.