Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 5ef43cc

Browse files
perostOpenModelica-Hudson
authored andcommitted
Handle uses-annotation according to the standard.
- Only consider uses-annotations on top-level classes when deciding which models/libraries to load. Belonging to [master]: - OpenModelica/OpenModelica#137 - #3049
1 parent 9a506ce commit 5ef43cc

2 files changed

Lines changed: 21 additions & 23 deletions

File tree

Compiler/Script/CevalScriptBackend.mo

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3074,13 +3074,8 @@ algorithm
30743074
// print(stringDelimitList(list(Absyn.pathString(path) for path in Interactive.getTopClassnames(p)), ",") + "\n");
30753075
SymbolTable.setAbsyn(p);
30763076
end try;
3077-
try
3078-
absynClass := Interactive.getPathedClassInProgram(className, p);
3079-
else
3080-
success := true; /* Let derived classes possibly be handled by runFrontEndWork */
3081-
return;
3082-
end try;
3083-
(p,success) := CevalScript.loadModel(Interactive.getUsesAnnotationOrDefault(Absyn.PROGRAM({absynClass},Absyn.TOP()), false),Settings.getModelicaPath(Config.getRunningTestsuite()),p,false,true,true,false);
3077+
3078+
(p,success) := CevalScript.loadModel(Interactive.getUsesAnnotationOrDefault(p, false),Settings.getModelicaPath(Config.getRunningTestsuite()),p,false,true,true,false);
30843079
SymbolTable.setAbsyn(p);
30853080
// Always update the SCode structure; otherwise the cache plays tricks on us
30863081
SymbolTable.clearSCode();
@@ -3150,7 +3145,6 @@ algorithm
31503145
re = Absyn.restrString(restriction);
31513146
Error.assertionOrAddSourceMessage(relaxedFrontEnd or not (Absyn.isFunctionRestriction(restriction) or Absyn.isPackageRestriction(restriction)),
31523147
Error.INST_INVALID_RESTRICTION,{str,re},Absyn.dummyInfo);
3153-
(p,true) = CevalScript.loadModel(Interactive.getUsesAnnotationOrDefault(Absyn.PROGRAM({absynClass},Absyn.TOP()), false),Settings.getModelicaPath(Config.getRunningTestsuite()),p,false,true,true,false);
31543148

31553149
//System.stopTimer();
31563150
//print("\nExists+Dependency: " + realString(System.getTimerIntervalTime()));

Compiler/Script/Interactive.mo

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11221,25 +11221,29 @@ algorithm
1122111221
end matchcontinue;
1122211222
end getNamedAnnotation;
1122311223

11224+
constant Absyn.Path USES_PATH = Absyn.Path.IDENT("uses");
11225+
1122411226
public function getUsesAnnotation
11225-
"This function takes a Path and a Program and returns a comma separated
11226-
string of values for the Documentation annotation for the class named by the
11227-
first argument."
11228-
input Absyn.Program p;
11229-
output list<tuple<Absyn.Path,list<String>,Boolean>> usesStr;
11227+
"Returns the uses-annotations of the top-level classes in the given program."
11228+
input Absyn.Program program;
11229+
output list<Annotation> outUses = {};
11230+
11231+
type Annotation = tuple<Absyn.Path, list<String>, Boolean>;
11232+
protected
11233+
Option<list<Annotation>> opt_uses;
11234+
list<Annotation> uses;
11235+
list<Absyn.Class> classes;
1123011236
algorithm
11231-
usesStr := matchcontinue (p)
11232-
local
11233-
Absyn.Class cdef;
11237+
Absyn.PROGRAM(classes = classes) := program;
1123411238

11235-
case (Absyn.PROGRAM(classes={cdef}))
11236-
equation
11237-
SOME(usesStr) = Absyn.getNamedAnnotationInClass(cdef,Absyn.IDENT("uses"),getUsesAnnotationString);
11238-
then
11239-
usesStr;
11239+
for cls in classes loop
11240+
opt_uses := Absyn.getNamedAnnotationInClass(cls, USES_PATH, getUsesAnnotationString);
1124011241

11241-
else {};
11242-
end matchcontinue;
11242+
if isSome(opt_uses) then
11243+
SOME(uses) := opt_uses;
11244+
outUses := listAppend(uses, outUses);
11245+
end if;
11246+
end for;
1124311247
end getUsesAnnotation;
1124411248

1124511249
public function getUsesAnnotationOrDefault

0 commit comments

Comments
 (0)