@@ -91,6 +91,7 @@ public function loadClass
9191 input String modelicaPath;
9292 input Option< String > encoding;
9393 input Boolean requireExactVersion = false ;
94+ input Boolean encrypted = false ;
9495 output Absyn.Program outProgram;
9596algorithm
9697 outProgram := matchcontinue (inPath,priorityList,modelicaPath,encoding)
@@ -104,7 +105,7 @@ algorithm
104105 equation
105106 gd = System.groupDelimiter();
106107 mps = System.strtok(mp, gd);
107- p = loadClassFromMps(classname, priorityList, mps, encoding, requireExactVersion);
108+ p = loadClassFromMps(classname, priorityList, mps, encoding, requireExactVersion, encrypted );
108109 checkOnLoadMessage(p);
109110 then
110111 p;
@@ -113,7 +114,7 @@ algorithm
113114 equation
114115 gd = System.groupDelimiter();
115116 mps = System.strtok(mp, gd);
116- p = loadClassFromMps(pack, priorityList, mps, encoding, requireExactVersion);
117+ p = loadClassFromMps(pack, priorityList, mps, encoding, requireExactVersion, encrypted );
117118 checkOnLoadMessage(p);
118119 then
119120 p;
@@ -134,6 +135,7 @@ protected function loadClassFromMps
134135 input list< String > mps;
135136 input Option< String > encoding;
136137 input Boolean requireExactVersion = false ;
138+ input Boolean encrypted = false ;
137139 output Absyn.Program outProgram;
138140protected
139141 String mp, name, pwd, cmd, version, userLibraries;
@@ -164,7 +166,7 @@ algorithm
164166 end try;
165167 // print("System.getLoadModelPath: " + id + " {" + stringDelimitList(prios,",") + "} " + stringDelimitList(mps,",") + " => " + mp + " " + name + " " + boolString(isDir));
166168 Config.setLanguageStandardFromMSL(name);
167- cl := loadClassFromMp(id, mp, name, isDir, encoding);
169+ cl := loadClassFromMp(id, mp, name, isDir, encoding, encrypted );
168170 outProgram := Absyn.PROGRAM({cl},Absyn.TOP());
169171end loadClassFromMps;
170172
@@ -174,6 +176,7 @@ protected function loadClassFromMp
174176 input String name;
175177 input Boolean isDir;
176178 input Option< String > optEncoding;
179+ input Boolean encrypted = false ;
177180 output Absyn.Class outClass;
178181algorithm
179182 outClass := match (id,path,name,isDir,optEncoding)
@@ -204,27 +207,32 @@ algorithm
204207 if Config.getRunningTestsuite() or Config.noProc()== 1 then
205208 strategy = STRATEGY_ON_DEMAND(encoding);
206209 else
207- filenames = getAllFilesFromDirectory(path + pd + name);
210+ filenames = getAllFilesFromDirectory(path + pd + name, encrypted );
208211 // print("Files load in parallel:\n" + stringDelimitList(filenames, "\n") + "\n");
209- strategy = STRATEGY_HASHTABLE(Parser.parallelParseFiles(filenames, encoding));
212+ strategy = STRATEGY_HASHTABLE(Parser.parallelParseFiles(filenames, encoding, Config.noProc(), encrypted ));
210213 end if ;
211- cl = loadCompletePackageFromMp(id, name, path, strategy, Absyn.TOP(), Error.getNumErrorMessages());
214+ cl = loadCompletePackageFromMp(id, name, path, strategy, Absyn.TOP(), Error.getNumErrorMessages(), encrypted );
212215 then
213216 cl;
214217 end match;
215218end loadClassFromMp;
216219
217220protected function getAllFilesFromDirectory
218221 input String dir;
222+ input Boolean encrypted;
219223 input list< String > acc = {};
220224 output list< String > files;
221225protected
222226 list< String > subdirs;
223227 String pd = System.pathDelimiter();
224228algorithm
225- files := (dir + pd + "package.mo" ) :: listAppend(list(dir + pd + f for f in System.moFiles(dir)), acc);
226- subdirs := list(dir + pd + d for d in List.filter1OnTrue(System.subDirectories(dir), existPackage, dir));
227- files := List.fold(subdirs, getAllFilesFromDirectory, files);
229+ if encrypted then
230+ files := (dir + pd + "package.moc" ) :: listAppend(list(dir + pd + f for f in System.mocFiles(dir)), acc);
231+ else
232+ files := (dir + pd + "package.mo" ) :: listAppend(list(dir + pd + f for f in System.moFiles(dir)), acc);
233+ end if ;
234+ subdirs := list(dir + pd + d for d in List.filter2OnTrue(System.subDirectories(dir), existPackage, dir, encrypted));
235+ files := List.fold1(subdirs, getAllFilesFromDirectory, encrypted, files);
228236end getAllFilesFromDirectory;
229237
230238protected function loadCompletePackageFromMp
@@ -235,6 +243,7 @@ protected function loadCompletePackageFromMp
235243 input LoadFileStrategy strategy;
236244 input Absyn.Within inWithin;
237245 input Integer numError;
246+ input Boolean encrypted = false ;
238247 output Absyn.Class cl;
239248algorithm
240249 cl := matchcontinue (id,inIdent,inString,inWithin)
@@ -256,7 +265,7 @@ algorithm
256265 equation
257266 pd = System.pathDelimiter();
258267 mp_1 = stringAppendList({mp,pd,pack});
259- packagefile = stringAppendList({mp_1,pd,"package.mo" });
268+ packagefile = stringAppendList({mp_1,pd,if encrypted then "package.moc" else "package.mo" });
260269 orderfile = stringAppendList({mp_1,pd,"package.order" });
261270 if not System.regularFileExists(packagefile) then
262271 Error.addInternalError("Expected file " + packagefile + " to exist" , sourceInfo());
@@ -265,10 +274,10 @@ algorithm
265274 // print("Look for " + packagefile + "\n");
266275 (cl as Absyn.CLASS(name,pp,fp,ep,r,Absyn.PARTS(tv,ca,cp,ann,cmt),info)) = parsePackageFile(packagefile, strategy, true , within_, id);
267276 // print("Got " + packagefile + "\n");
268- reverseOrder = getPackageContentNames(cl, orderfile, mp_1, Error.getNumErrorMessages());
277+ reverseOrder = getPackageContentNames(cl, orderfile, mp_1, Error.getNumErrorMessages(), encrypted );
269278 path = Absyn.joinWithinPath(within_,Absyn.IDENT(id));
270279 w2 = Absyn.WITHIN(path);
271- cp = List.fold3 (reverseOrder, loadCompletePackageFromMp2, mp_1, strategy, w2, {});
280+ cp = List.fold4 (reverseOrder, loadCompletePackageFromMp2, mp_1, strategy, w2, encrypted , {});
272281 then Absyn.CLASS(name,pp,fp,ep,r,Absyn.PARTS(tv,ca,cp,ann,cmt),info);
273282 case (_,pack,mp,_)
274283 equation
@@ -305,6 +314,7 @@ protected function loadCompletePackageFromMp2
305314 input String mp;
306315 input LoadFileStrategy strategy;
307316 input Absyn.Within w1 "With the parent added" ;
317+ input Boolean encrypted = false ;
308318 input list< Absyn.ClassPart> acc;
309319 output list< Absyn.ClassPart> cps;
310320algorithm
@@ -334,14 +344,14 @@ algorithm
334344 case CLASSLOAD(id)
335345 equation
336346 pd = System.pathDelimiter();
337- file = mp + pd + id + "/package.mo" ;
347+ file = mp + pd + id + ( if encrypted then "/package.moc" else "/package. mo") ;
338348 bDirectoryAndFileExists = System.directoryExists(mp + pd + id) and System.regularFileExists(file);
339349 if bDirectoryAndFileExists then
340- cl = loadCompletePackageFromMp(id,id,mp,strategy,w1,Error.getNumErrorMessages());
350+ cl = loadCompletePackageFromMp(id,id,mp,strategy,w1,Error.getNumErrorMessages(),encrypted );
341351 ei = Absyn.makeClassElement(cl);
342352 cps = mergeBefore(Absyn.PUBLIC({ei}),acc);
343353 else
344- file = mp + pd + id + ". mo" ;
354+ file = mp + pd + id + ( if encrypted then ".moc" else ". mo") ;
345355 if not System.regularFileExists(file) then
346356 Error.addInternalError("Expected file " + file + " to exist" , sourceInfo());
347357 fail();
@@ -408,6 +418,7 @@ protected function getPackageContentNames
408418 input String filename;
409419 input String mp;
410420 input Integer numError;
421+ input Boolean encrypted = false ;
411422 output list< PackageOrder> po "reverse" ;
412423algorithm
413424 (po) := matchcontinue (cl,filename,mp,numError)
@@ -428,11 +439,16 @@ algorithm
428439 duplicatesStr = stringDelimitList(duplicates, ", " );
429440 Error.assertionOrAddSourceMessage(listEmpty(duplicates),Error.PACKAGE_ORDER_DUPLICATES,{duplicatesStr},SOURCEINFO(filename,true ,0 ,0 ,0 ,0 ,0.0 ));
430441
431- // get all the .mo files in the directory!
432- mofiles = List.map(System.moFiles(mp), Util.removeLast3Char);
433- // get all the subdirs containing package.mo
442+ if encrypted then
443+ // get all the .moc files in the directory!
444+ mofiles = List.map(System.mocFiles(mp), Util.removeLast4Char);
445+ else
446+ // get all the .mo files in the directory!
447+ mofiles = List.map(System.moFiles(mp), Util.removeLast3Char);
448+ end if ;
449+ // get all the subdirs
434450 subdirs = System.subDirectories(mp);
435- subdirs = List.filter1OnTrue (subdirs, existPackage, mp);
451+ subdirs = List.filter2OnTrue (subdirs, existPackage, mp, encrypted );
436452 // build a list
437453 intersection = List.intersectionOnTrue(subdirs,mofiles,stringEq);
438454 differencesStr = stringDelimitList(List.map1(intersection, getBothPackageAndFilename, mp), ", " );
@@ -444,15 +460,15 @@ algorithm
444460 differencesStr = stringDelimitList(differences, "\n\t " );
445461 Error.assertionOrAddSourceMessage(listEmpty(differences),Error.PACKAGE_ORDER_FILE_NOT_COMPLETE,{differencesStr},SOURCEINFO(filename,true ,0 ,0 ,0 ,0 ,0.0 ));
446462 po1 = getPackageContentNamesinParts(namesToFind,cp,{});
447- List.map2_0 (po1,checkPackageOrderFilesExist,mp,info);
463+ List.map3_0 (po1,checkPackageOrderFilesExist,mp,info,encrypted );
448464
449465 po2 = List.map(differences, makeClassLoad);
450466
451467 po = listAppend(po2, po1);
452468 else // file not found
453469 mofiles = List.map(System.moFiles(mp), Util.removeLast3Char) "Here .mo files in same directory as package.mo should be loaded as sub-packages" ;
454470 subdirs = System.subDirectories(mp);
455- subdirs = List.filter1OnTrue (subdirs, existPackage, mp);
471+ subdirs = List.filter2OnTrue (subdirs, existPackage, mp, encrypted );
456472 mofiles = List.sort(listAppend(subdirs,mofiles), Util.strcmpBool);
457473 // Look for duplicates
458474 intersection = List.sortedDuplicates(mofiles,stringEq);
@@ -499,14 +515,15 @@ protected function checkPackageOrderFilesExist
499515 input PackageOrder po;
500516 input String mp;
501517 input SourceInfo info;
518+ input Boolean encrypted = false;
502519algorithm
503520 _ := match (po,mp,info)
504521 local
505522 String pd,str;
506523 case (CLASSLOAD(str),_,_)
507524 equation
508525 pd = System.pathDelimiter();
509- Error.assertionOrAddSourceMessage(System.directoryExists(mp + pd + str) or System.regularFileExists(mp + pd + str + " . mo"),Error.PACKAGE_ORDER_FILE_NOT_FOUND,{str},info);
526+ Error.assertionOrAddSourceMessage(System.directoryExists(mp + pd + str) or System.regularFileExists(mp + pd + str + (if encrypted then " .moc " else " . mo") ),Error.PACKAGE_ORDER_FILE_NOT_FOUND,{str},info);
510527 then ();
511528 else ();
512529 end match;
@@ -515,12 +532,13 @@ end checkPackageOrderFilesExist;
515532protected function existPackage
516533 input String name;
517534 input String mp;
535+ input Boolean encrypted = false;
518536 output Boolean b;
519537protected
520538 String pd;
521539algorithm
522540 pd := System.pathDelimiter();
523- b := System.regularFileExists(mp + pd + name + pd + " package.mo");
541+ b := System.regularFileExists(mp + pd + name + pd + (if encrypted then " package.moc " else " package. mo") );
524542end existPackage;
525543
526544protected function getPackageContentNamesinParts
0 commit comments