Skip to content

Commit

Permalink
- add a warning about files and directories (containing package.mo) t…
Browse files Browse the repository at this point in the history
…hat are not present in package.order

  *AND ALSO LOAD THE ONES THAT ARE NOT PRESENT*. 
  I've got bitten by this waaaay too many times to let it slide!
  Now we got 3 more test models in the AVM lib from this.

- way faster extendsFrom (without bothering to fully qualify extends, just checks suffix of extends in class)
  previous took 10 minutes, now is 16 seconds.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14161 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Nov 30, 2012
1 parent c19d131 commit edaba55
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
8 changes: 8 additions & 0 deletions Compiler/FrontEnd/Absyn.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3045,6 +3045,14 @@ algorithm
end matchcontinue;
end pathSuffixOf;

public function pathSuffixOfr "returns true if suffix_path is a suffix of path"
input Path path;
input Path suffix_path;
output Boolean res;
algorithm
res := pathSuffixOf(suffix_path, path);
end pathSuffixOfr;

public function pathToStringList
input Path path;
output list<String> outPaths;
Expand Down
30 changes: 25 additions & 5 deletions Compiler/FrontEnd/ClassLoader.mo
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,12 @@ protected function getPackageContentNames
algorithm
(po) := matchcontinue (cl,filename,mp,numError)
local
String contents, duplicatesStr;
list<String> duplicates, namesToFind, mofiles, subdirs;
String contents, duplicatesStr, differencesStr;
list<String> duplicates, namesToFind, mofiles, subdirs, differences;
list<Absyn.ClassPart> cp;
Absyn.Info info;
list<PackageOrder> po1, po2;

case (Absyn.CLASS(body=Absyn.PARTS(classParts=cp),info=info),_,_,_)
equation
true = System.regularFileExists(filename);
Expand All @@ -413,9 +415,27 @@ algorithm
duplicates = List.sortedFilterDuplicates(List.sort(namesToFind,Util.strcmpBool),stringEq);
duplicatesStr = stringDelimitList(duplicates, ", ");
Error.assertionOrAddSourceMessage(List.isEmpty(duplicates),Error.PACKAGE_ORDER_DUPLICATES,{duplicatesStr},Absyn.INFO(filename,true,0,0,0,0,Absyn.dummyTimeStamp));
po = getPackageContentNamesinParts(namesToFind,cp,{});
List.map2_0(po,checkPackageOrderFilesExist,mp,info);
then po;

// get all the .mo files in the directory!
mofiles = List.map(System.moFiles(mp), Util.removeLast3Char);
// get all the subdirs containing package.mo
subdirs = System.subDirectories(mp);
subdirs = List.filter1OnTrue(subdirs, existPackage, mp);
// build a list
mofiles = listAppend(subdirs,mofiles);
// check if all are present in the package.order
differences = List.setDifference(mofiles, namesToFind);
// issue a warning if not all are present
differencesStr = stringDelimitList(differences, "\n\t");
Error.assertionOrAddSourceMessage(List.isEmpty(differences),Error.PACKAGE_ORDER_FILE_NOT_COMPLETE,{differencesStr},Absyn.INFO(filename,true,0,0,0,0,Absyn.dummyTimeStamp));
po1 = getPackageContentNamesinParts(namesToFind,cp,{});
List.map2_0(po1,checkPackageOrderFilesExist,mp,info);

po2 = List.map(differences, makeClassLoad);

po = List.appendNoCopy(po2, po1);
then
po;

case (Absyn.CLASS(body=Absyn.PARTS(classParts=cp),info=info),_,_,_)
equation
Expand Down
2 changes: 1 addition & 1 deletion Compiler/Script/CevalScript.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1999,7 +1999,7 @@ algorithm
Values.CODE(Absyn.C_TYPENAME(baseClassPath))},st as Interactive.SYMBOLTABLE(ast=p),_)
equation
paths = Interactive.getAllInheritedClasses(classpath, p);
b = List.applyAndFold1(paths, boolOr, Absyn.pathEqual, baseClassPath, false);
b = List.applyAndFold1(paths, boolOr, Absyn.pathSuffixOfr, baseClassPath, false);
then
(cache,Values.BOOL(b),st);

Expand Down
4 changes: 1 addition & 3 deletions Compiler/Script/Interactive.mo
Original file line number Diff line number Diff line change
Expand Up @@ -19811,7 +19811,7 @@ algorithm
equation
acc = pp::acc;
cdef = getPathedClassInProgram(pp, p);
strlst = getClassnamesInClassList(pp, p, cdef,b);
strlst = getClassnamesInClassList(pp, p, cdef, b);
result_path_lst = List.map(List.map1(strlst, joinPaths, pp),Util.makeOption);
(_,acc) = List.map2Fold(result_path_lst, getClassNamesRecursive, p, b, acc);
then (inPath,acc);
Expand Down Expand Up @@ -20016,9 +20016,7 @@ algorithm
case (p_class,p)
equation
cdef = getPathedClassInProgram(p_class, p);
env = getClassEnv(p, p_class);
exts = getExtendsElementspecInClass(cdef);
exts = List.map1(exts, makeExtendsFullyQualified, env);
paths = List.map(exts, getBaseClassNameFromExtends);
then
paths;
Expand Down
4 changes: 3 additions & 1 deletion Compiler/Util/Error.mo
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,9 @@ public constant Message DERIVATIVE_INPUT = MESSAGE(527, TRANSLATION(), ERROR(),
Util.gettext("The model requires derivatives of some inputs as listed below:\n%s"));
public constant Message UTF8_COMMAND_LINE_ARGS = MESSAGE(528, TRANSLATION(), ERROR(),
Util.gettext("The compiler was sent command-line arguments that were not UTF-8 encoded and will abort the current execution."));

public constant Message PACKAGE_ORDER_FILE_NOT_COMPLETE = MESSAGE(529, GRAMMAR(), WARNING(),
Util.gettext("The package.order file does not list all .mo files and directories (containing package.mo) present in its directory.\nMissing names are:\n\t%s"));

public constant Message MATCH_SHADOWING = MESSAGE(5001, TRANSLATION(), ERROR(),
Util.gettext("Local variable '%s' shadows another variable."));
public constant Message META_POLYMORPHIC = MESSAGE(5002, TRANSLATION(), ERROR(),
Expand Down

0 comments on commit edaba55

Please sign in to comment.