Skip to content

Commit

Permalink
- Added API to get scriptable uses annotation
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15664 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Mar 27, 2013
1 parent ade9352 commit df65c8d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -2684,6 +2684,17 @@ annotation(
preferredView="text");
end getAvailableLibraries;

function getUses
input TypeName pack;
output String[:,:] uses;
external "builtin";
annotation(
Documentation(info="<html>
Returns the libraries used by the package {{\"Library1\",\"Version\"},{\"Library2\",\"Version\"}}.
</html>"),
preferredView="text");
end getUses;

function getDerivedClassModifierNames "Returns the derived class modifier names.
Example command:
type Resistance = Real(final quantity=\"Resistance\",final unit=\"Ohm\");
Expand Down
28 changes: 28 additions & 0 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -920,6 +920,7 @@ algorithm
BackendDAE.Shared shared;
SimCode.SimulationSettings simSettings;
Boolean dumpExtractionSteps;
list<tuple<Absyn.Path,list<String>>> uses;

case (cache,env,"parseString",{Values.STRING(str1),Values.STRING(str2)},st,_)
equation
Expand Down Expand Up @@ -2118,6 +2119,14 @@ algorithm
then
(cache,v,st);

case (cache,env,"getUses",{Values.CODE(Absyn.C_TYPENAME(classpath))},st as Interactive.SYMBOLTABLE(ast=p),_)
equation
(absynClass as Absyn.CLASS(restriction = _)) = Interactive.getPathedClassInProgram(classpath, p);
uses = Interactive.getUsesAnnotation(Absyn.PROGRAM({absynClass},Absyn.TOP(),Absyn.dummyTimeStamp));
v = ValuesUtil.makeArray(List.map(uses,makeUsesArray));
then
(cache,v,st);

case (cache,env,"getDerivedClassModifierNames",{Values.CODE(Absyn.C_TYPENAME(classpath))},st as Interactive.SYMBOLTABLE(ast=p),_)
equation
absynClass = Interactive.getPathedClassInProgram(classpath, p);
Expand Down Expand Up @@ -7258,4 +7267,23 @@ algorithm
end matchcontinue;
end searchClassNames;

protected function makeUsesArray
input tuple<Absyn.Path,list<String>> inTpl;
output Values.Value v;
algorithm
v := match inTpl
local
Absyn.Path p;
String pstr,ver;
case ((p,{ver}))
equation
pstr = Absyn.pathString(p);
then ValuesUtil.makeArray({Values.STRING(pstr),Values.STRING(ver)});
else
equation
Error.addMessage(Error.INTERNAL_ERROR,{"makeUsesArray failed"});
then fail();
end match;
end makeUsesArray;

end CevalScript;

0 comments on commit df65c8d

Please sign in to comment.