@@ -565,28 +565,32 @@ protected function loadModel
565
565
input String modelicaPath;
566
566
input Absyn . Program ip;
567
567
input Boolean forceLoad;
568
+ input Boolean notifyLoad;
568
569
output Absyn . Program pnew;
569
570
output Boolean success;
570
571
algorithm
571
- (pnew,success) := matchcontinue (imodelsToLoad,modelicaPath,ip,forceLoad)
572
+ (pnew,success) := matchcontinue (imodelsToLoad,modelicaPath,ip,forceLoad,notifyLoad )
572
573
local
573
574
Absyn . Path path;
574
- String pathStr,versions;
575
+ String pathStr,versions,className,version ;
575
576
list< String > strings;
576
577
Boolean b,b1,b2;
577
578
Absyn . Program p;
578
579
list< tuple< Absyn . Path ,list< String >>> modelsToLoad;
579
580
580
- case ({},_,p,_) then (p,true );
581
- case ((path,strings)::modelsToLoad,modelicaPath,p,forceLoad)
581
+ case ({},_,p,_,_ ) then (p,true );
582
+ case ((path,strings)::modelsToLoad,modelicaPath,p,forceLoad,notifyLoad )
582
583
equation
583
584
b = checkModelLoaded((path,strings),p,forceLoad,NONE ());
584
585
pnew = Debug . bcallret3(not b, ClassLoader . loadClass, path, strings, modelicaPath, Absyn . PROGRAM ({},Absyn . TOP (),Absyn . dummyTimeStamp));
586
+ className = Absyn . pathString(path);
587
+ version = Debug . bcallret2(not b, getPackageVersion, path, pnew, "" );
588
+ Error . assertionOrAddSourceMessage(b or not notifyLoad,Error . NOTIFY_NOT_LOADED ,{className,version},Absyn . dummyInfo);
585
589
p = Interactive . updateProgram(pnew, p);
586
- (p,b1) = loadModel(Interactive . getUsesAnnotationOrDefault(pnew),modelicaPath,p,false );
587
- (p,b2) = loadModel(modelsToLoad,modelicaPath,p,forceLoad);
590
+ (p,b1) = loadModel(Interactive . getUsesAnnotationOrDefault(pnew),modelicaPath,p,false ,notifyLoad );
591
+ (p,b2) = loadModel(modelsToLoad,modelicaPath,p,forceLoad,notifyLoad );
588
592
then (p,b1 and b2);
589
- case ((path,strings)::_,modelicaPath,p,_)
593
+ case ((path,strings)::_,modelicaPath,p,_,_ )
590
594
equation
591
595
pathStr = Absyn . pathString(path);
592
596
versions = stringDelimitList(strings,"," );
@@ -1429,9 +1433,7 @@ algorithm
1429
1433
1430
1434
case (cache,env,"getVersion" ,{Values . CODE (Absyn . C_TYPENAME (path))},st as Interactive . SYMBOLTABLE (ast= p),msg)
1431
1435
equation
1432
- Config . setEvaluateParametersInAnnotations(true );
1433
- Absyn . STRING (str_1) = Interactive . getNamedAnnotation(path, p, "version" , SOME (Absyn . STRING ("" )), Interactive . getAnnotationExp);
1434
- Config . setEvaluateParametersInAnnotations(false );
1436
+ str_1 = getPackageVersion(path,p);
1435
1437
then
1436
1438
(cache,Values . STRING (str_1),st);
1437
1439
@@ -1572,7 +1574,7 @@ algorithm
1572
1574
case (cache,env,"generateSeparateCode" ,{},st,msg)
1573
1575
then (cache,Values . BOOL (false ),st);
1574
1576
1575
- case (cache,env,"loadModel" ,{Values . CODE (Absyn . C_TYPENAME (path)),Values . ARRAY (valueLst= cvars)},
1577
+ case (cache,env,"loadModel" ,{Values . CODE (Absyn . C_TYPENAME (path)),Values . ARRAY (valueLst= cvars), Values . BOOL (b) },
1576
1578
(st as Interactive . SYMBOLTABLE (
1577
1579
ast = p,depends= aDep,instClsLst = ic,
1578
1580
lstVarVal = iv,compiledFunctions = cf,
@@ -1582,7 +1584,7 @@ algorithm
1582
1584
equation
1583
1585
mp = Settings . getModelicaPath();
1584
1586
strings = List . map(cvars, ValuesUtil . extractValueString);
1585
- (p,b) = loadModel({(path,strings)},mp,p,true );
1587
+ (p,b) = loadModel({(path,strings)},mp,p,true ,b );
1586
1588
str = Print . getString();
1587
1589
newst = Interactive . SYMBOLTABLE (p,aDep,NONE (),{},iv,cf,lf);
1588
1590
then
@@ -2589,8 +2591,7 @@ algorithm
2589
2591
re = Absyn . restrString(restriction);
2590
2592
Error . assertionOrAddSourceMessage(relaxedFrontEnd or not (Absyn . isFunctionRestriction(restriction) or Absyn . isPackageRestriction(restriction)),
2591
2593
Error . INST_INVALID_RESTRICTION ,{str,re},Absyn . dummyInfo);
2592
- usedModels = Interactive . getUsesAnnotation(Absyn . PROGRAM ({absynClass},Absyn . TOP (),Absyn . dummyTimeStamp));
2593
- _ = List . map3(usedModels, checkModelLoaded, p, false , SOME (str));
2594
+ (p,true ) = loadModel(Interactive . getUsesAnnotationOrDefault(Absyn . PROGRAM ({absynClass},Absyn . TOP (),Absyn . dummyTimeStamp)),Settings . getModelicaPath(),p,false ,true );
2594
2595
2595
2596
ptot = Dependency . getTotalProgram(className,p);
2596
2597
@@ -2672,14 +2673,6 @@ algorithm
2672
2673
2673
2674
case (cache,env,className,st as Interactive . SYMBOLTABLE (ast= p),fileNamePrefix,addDummy,inSimSettingsOpt)
2674
2675
equation
2675
- (absynClass as Absyn . CLASS (restriction = restriction)) = Interactive . getPathedClassInProgram(className, p);
2676
- str = Absyn . pathString(className);
2677
- re = Absyn . restrString(restriction);
2678
- Error . assertionOrAddSourceMessage(not (Absyn . isFunctionRestriction(restriction) or Absyn . isPackageRestriction(restriction)),
2679
- Error . INST_INVALID_RESTRICTION ,{str,re},Absyn . dummyInfo);
2680
- usedModels = Interactive . getUsesAnnotation(Absyn . PROGRAM ({absynClass},Absyn . TOP (),Absyn . dummyTimeStamp));
2681
- _ = List . map3(usedModels, checkModelLoaded, p, false , SOME (str));
2682
-
2683
2676
(cache, outValMsg, st, indexed_dlow, libs, file_dir, resultValues) =
2684
2677
SimCode . translateModel(cache,env,className,st,fileNamePrefix,addDummy,inSimSettingsOpt,Absyn . FUNCTIONARGS ({},{}));
2685
2678
then
@@ -6338,4 +6331,20 @@ algorithm
6338
6331
end matchcontinue;
6339
6332
end isShortDefinition;
6340
6333
6334
+ protected function getPackageVersion
6335
+ input Absyn . Path path;
6336
+ input Absyn . Program p;
6337
+ output String version;
6338
+ algorithm
6339
+ version := matchcontinue (path,p)
6340
+ case (path,p)
6341
+ equation
6342
+ Config . setEvaluateParametersInAnnotations(true );
6343
+ Absyn . STRING (version) = Interactive . getNamedAnnotation(path, p, "version" , SOME (Absyn . STRING ("" )), Interactive . getAnnotationExp);
6344
+ Config . setEvaluateParametersInAnnotations(false );
6345
+ then version;
6346
+ else "(version unknown)" ;
6347
+ end matchcontinue;
6348
+ end getPackageVersion;
6349
+
6341
6350
end CevalScript ;
0 commit comments