Skip to content

Commit

Permalink
- Fixed order of elements loaded by loadFile()
Browse files Browse the repository at this point in the history
- Added API setDocumentationAnnotation()


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12603 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Aug 20, 2012
1 parent 4f21054 commit c7aaa60
Show file tree
Hide file tree
Showing 8 changed files with 360 additions and 23 deletions.
1 change: 0 additions & 1 deletion Compiler/FrontEnd/ClassLoader.mo
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ encapsulated package ClassLoader
loadFile function"

public import Absyn;
public import Interactive;

protected import Config;
protected import Debug;
Expand Down
12 changes: 12 additions & 0 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2267,6 +2267,18 @@ external "builtin";
annotation(preferredView="text");
end getDocumentationAnnotation;

function setDocumentationAnnotation
input TypeName class_;
input String info = "";
input String revisions = "";
output Boolean bool;

external "builtin" ;
annotation(preferredView = "text", Documentation(info = "<html>
<p>Used to set the Documentation annotation of a class. An empty argument (e.g. for revisions) means no annotation is added.</p>
</html>"));
end setDocumentationAnnotation;

function typeNameString
input TypeName cl;
output String out;
Expand Down
4 changes: 2 additions & 2 deletions Compiler/GenerateOMCHeader.mos
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ loadFile("Script/Interactive.mo");
loadFile("FrontEnd/Values.mo");
loadFile("Util/Error.mo");
loadFile("Util/Config.mo");

if getErrorString() == "" then loadOK := true; end if;
err:=getErrorString();
if err == "" then loadOK := true; end if;
a:=loadOK; // Will cause exit(1) if loadOK is undefined
b3:=generateHeader("OpenModelicaBootstrappingHeader.h.new");
if b3 then genOK := true; end if;
Expand Down
14 changes: 14 additions & 0 deletions Compiler/Script/CevalScript.mo
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,7 @@ algorithm
Absyn.CodeNode codeNode;
list<Values.Value> cvars,vals2;
list<Absyn.Path> paths;
list<Absyn.NamedArg> nargs;
list<Absyn.Class> classes;
Absyn.Within within_;
BackendDAE.EqSystem syst;
Expand Down Expand Up @@ -1788,6 +1789,19 @@ algorithm
then
(cache,Values.BOOL(false),st);

case (cache,env,"setDocumentationAnnotation",{Values.CODE(Absyn.C_TYPENAME(classpath)),Values.STRING(str1),Values.STRING(str2)},Interactive.SYMBOLTABLE(p,aDep,_,ic,iv,cf,lf),msg)
equation
nargs = List.consOnTrue(not stringEq(str1,""), Absyn.NAMEDARG("info",Absyn.STRING(str1)), {});
nargs = List.consOnTrue(not stringEq(str2,""), Absyn.NAMEDARG("revisions",Absyn.STRING(str2)), nargs);
aexp = Absyn.CALL(Absyn.CREF_IDENT("Documentation",{}),Absyn.FUNCTIONARGS({},nargs));
p = Interactive.addClassAnnotation(Absyn.pathToCref(classpath), Absyn.NAMEDARG("annotate",aexp)::{}, p);
then
(cache,Values.BOOL(true),Interactive.SYMBOLTABLE(p,aDep,NONE(),ic,iv,cf,lf));

case (cache,env,"setDocumentationAnnotation",_,st as Interactive.SYMBOLTABLE(ast=p),msg)
then
(cache,Values.BOOL(false),st);

case (cache,env,"isPackage",{Values.CODE(Absyn.C_TYPENAME(classpath))},st as Interactive.SYMBOLTABLE(ast=p),msg)
equation
b = Interactive.isPackage(classpath, p);
Expand Down
50 changes: 30 additions & 20 deletions Compiler/Script/Interactive.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9555,51 +9555,61 @@ public function updateProgram
input Absyn.Program inProgram1;
input Absyn.Program inProgram2;
output Absyn.Program outProgram;
protected
list<Absyn.Class> cs;
Absyn.Within w;
algorithm
Absyn.PROGRAM(classes=cs,within_=w) := inProgram1;
outProgram := updateProgram2(listReverse(cs),w,inProgram2);
end updateProgram;

protected function updateProgram2
"function: updateProgram
This function takes an old program (second argument), i.e. the old
symboltable, and a new program (first argument), i.e. a new set of
classes and updates the old program with the definitions in the new one.
It also takes in the current symboltable and returns a new one with any
replaced functions cache cleared."
input list<Absyn.Class> classes;
input Absyn.Within w;
input Absyn.Program inProgram2;
output Absyn.Program outProgram;
algorithm
outProgram := matchcontinue (inProgram1,inProgram2)
outProgram := matchcontinue (classes,w,inProgram2)
local
Absyn.Program prg,newp,p2,newp_1, p1;
Absyn.Class c1;
String name;
Absyn.Path path;
list<Absyn.Class> c2,c3;
Absyn.Within w,w2;
Absyn.Within w2;
Absyn.TimeStamp ts1,ts2;

case (Absyn.PROGRAM(classes = {}),prg)
then prg;
case ({},_,prg) then prg;

case (p1 as Absyn.PROGRAM(classes = ((c1 as Absyn.CLASS(name = name)) :: c2),within_ = (w as Absyn.TOP()),globalBuildTimes=ts1),
(p2 as Absyn.PROGRAM(classes = c3,within_ = w2,globalBuildTimes=ts2)))
case ((c1 as Absyn.CLASS(name = name)) :: c2,Absyn.TOP(), (p2 as Absyn.PROGRAM(classes = c3,within_ = w2,globalBuildTimes=ts2)))
equation
//debug_print("name", name);
//Dump.dump(p1);
false = classInProgram(name, p2);
newp = updateProgram(Absyn.PROGRAM(c2,w,ts1), Absyn.PROGRAM((c1 :: c3),w2,ts2));
newp = updateProgram2(c2,w,Absyn.PROGRAM((c1 :: c3),w2,ts2));
then
newp;

case (p1 as Absyn.PROGRAM(classes = ((c1 as Absyn.CLASS(name = name)) :: c2),within_ = (w as Absyn.TOP()),globalBuildTimes=ts1),
p2)
case ((c1 as Absyn.CLASS(name = name)) :: c2,Absyn.TOP(),p2)
equation
//debug_print("name", name);
//Dump.dump(p1);
true = classInProgram(name, p2);
newp = updateProgram(Absyn.PROGRAM(c2,w,ts1), p2);
newp = updateProgram2(c2,w,p2);
newp_1 = replaceClassInProgram(c1, newp);
then
newp_1;

case (Absyn.PROGRAM(classes = (c1 :: c2),within_ = (w as Absyn.WITHIN(path = path)),globalBuildTimes=ts1),
p2)
case ((c1 :: c2),Absyn.WITHIN(path = _),p2)
equation
newp = insertClassInProgram(c1, w, p2);
newp_1 = updateProgram(Absyn.PROGRAM(c2,w,ts1), newp);
then
newp_1;
newp_1 = updateProgram2(c2,w,newp);
then newp_1;

end matchcontinue;
end updateProgram;
end updateProgram2;

public function addScope
"function: addScope
Expand Down
21 changes: 21 additions & 0 deletions Examples/ReleaseNotes.mos
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
system("mkdir -p wiki");
cd("wiki");
system("ruby ../ReleaseNotes.rb ../ReleaseNotes.yaml");
versions:={
// $TypeName(OpenModelica.UsersGuide.ReleaseNotes.'1.8.1'),
$TypeName(OpenModelica.UsersGuide.ReleaseNotes.'1.9.0')
};
loadFile("../../Compiler/FrontEnd/ModelicaBuiltin.mo");
loadString("function myReadFile
input OpenModelica.$Code.TypeName name;
output String contents;
protected
String strs[:],str;
algorithm
strs := OpenModelica.Scripting.typeNameStrings(name);
str := strs[4];
contents := OpenModelica.Scripting.readFile(\"ReleaseNotes/release-notes/\" + OpenModelica.Scripting.stringReplace(str,\"'\",\"\") + \".html\");
end myReadFile;");getErrorString();
deleteClass(myReadFile);
getClassNames();getErrorString();
writeFile("newf.mo",list());getErrorString();

0 comments on commit c7aaa60

Please sign in to comment.