Skip to content

Commit

Permalink
- Add FileInfo to the top-level scope and fix the builtin environment…
Browse files Browse the repository at this point in the history
… to build the data structures needed to use this

- Handle import MetaModelica in the dependency analysis


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23001 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Oct 28, 2014
1 parent 967779c commit 925a424
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Compiler/FrontEnd/Builtin.mo
Expand Up @@ -54,6 +54,7 @@ protected import Flags;
protected import FGraphBuildEnv;
protected import Global;
protected import List;
protected import MetaUtil;
protected import Parser;
protected import SCodeUtil;
protected import Settings;
Expand Down Expand Up @@ -590,6 +591,7 @@ algorithm
Absyn.PROGRAM(classes=classes2,within_=Absyn.TOP()) = Parser.parsebuiltin(fileMetaModelica,"UTF-8");
classes = listAppend(classes1,classes2);
p = Absyn.PROGRAM(classes,Absyn.TOP(),Absyn.dummyTimeStamp);
(p as Absyn.PROGRAM(classes=classes)) = MetaUtil.createMetaClassesInProgram(p);
sp = List.map(classes, SCodeUtil.translateClass);
assocLst = getGlobalRoot(Global.builtinIndex);
setGlobalRoot(Global.builtinIndex, (Flags.METAMODELICA,(p,sp))::assocLst);
Expand Down
20 changes: 20 additions & 0 deletions Compiler/FrontEnd/MetaModelicaBuiltin.mo
Expand Up @@ -992,4 +992,24 @@ external "builtin";
end listReverseInPlace;

end Dangerous;

end MetaModelica;

uniontype FileInfo "The Info attribute provides location information for elements and classes."
record FILEINFO
String fileName "fileName where the class is defined in";
Boolean isReadOnly "isReadOnly : (true|false). Should be true for libraries";
Integer lineNumberStart "lineNumberStart";
Integer columnNumberStart "columnNumberStart";
Integer lineNumberEnd "lineNumberEnd";
Integer columnNumberEnd "columnNumberEnd";
TimeStamp buildTimes "Build and edit times";
end FILEINFO;
end FileInfo;

uniontype TimeStamp
record TIMESTAMP
Real lastBuildTime "Last Build Time";
Real lastEditTime "Last Edit Time; this is the same as mtime in stat(2)";
end TIMESTAMP;
end TimeStamp;
15 changes: 5 additions & 10 deletions Compiler/FrontEnd/MetaUtil.mo
Expand Up @@ -179,27 +179,22 @@ public function createMetaClassesInProgram "Adds metarecord classes to the AST.
input Absyn.Program program;
output Absyn.Program out;
algorithm
out := matchcontinue(program)
out := match (program)
local
list<Absyn.Class> classes, metaClassesFlat;
list<list<Absyn.Class>> metaClasses;
Absyn.Within w;
Absyn.TimeStamp ts;

case _
equation
false = Config.acceptMetaModelicaGrammar();
then program;

case (Absyn.PROGRAM(classes = classes,within_ = w,globalBuildTimes=ts))
case (Absyn.PROGRAM(classes = classes,within_ = w,globalBuildTimes=ts)) guard Config.acceptMetaModelicaGrammar()
equation
metaClasses = List.map(classes, createMetaClasses);
metaClassesFlat = List.flatten(metaClasses);
classes = List.map(classes, createMetaClassesFromPackage);
classes = listAppend(classes, metaClassesFlat);
then
Absyn.PROGRAM(classes,w,ts);
end matchcontinue;
then Absyn.PROGRAM(classes,w,ts);
else program;
end match;
end createMetaClassesInProgram;

protected function createMetaClassesFromPackage "Helper function to createMetaClassesInProgram"
Expand Down
6 changes: 6 additions & 0 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -7796,6 +7796,7 @@ algorithm
case (SCode.CLASS(name=name, classDef=SCode.PARTS(elementLst=elts), info = Absyn.INFO(fileName=fileName)),_,_,_)
equation
protectedDepends = List.map(List.select(elts,SCode.elementIsProtectedImport),importDepenency);
protectedDepends = List.select(protectedDepends, isNotBuiltinImport);
_::allDepends = Graph.allReachableNodes((name::protectedDepends,{}),deps,stringEq);
allDepends = List.map1r(allDepends, stringAppend, prefix);
allDepends = List.map1(allDepends, stringAppend, ".interface.mo");
Expand All @@ -7808,6 +7809,11 @@ algorithm
end matchcontinue;
end writeModuleDepends;

protected function isNotBuiltinImport
input String module;
output Boolean b := module <> "MetaModelica";
end isNotBuiltinImport;

protected function findFunctionsToCompile
input SCode.Element elt;
input Absyn.Path pathPrefix;
Expand Down

0 comments on commit 925a424

Please sign in to comment.