Skip to content

Commit

Permalink
Big changes. You will need to bootstrap omc from scratch.
Browse files Browse the repository at this point in the history
- Added function `sourceInfo()`, which returns the file and positions of the call in the source code (useful to produce error-messages that point inside the compiler itself).
- Changed all Absyn.Info to the built-in SourceInfo uniontype
- Added SourceInfo to GlobalScript.IEXP (previously only statements had SourceInfo)
- Changed System.readLine to fail if the file does not exist. The scripting function returns an empty string on failure.

A new bootstrapping tarball has been created. Some of the new features you can use in the compiler:
- (Limited) assignment to metarecord fields (r23120)
- Use new built-in function arrayAppend and Dangerous.arrayCreateNoInit (r23106)
- import MetaModelica.Dangerous (r23001)
- SourceInfo (this commit)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23138 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 2, 2014
1 parent 6f72cec commit b6f399e
Show file tree
Hide file tree
Showing 127 changed files with 1,929 additions and 2,197 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -2386,7 +2386,7 @@ algorithm
list<DAE.Exp> functionArgs;
list<DAE.ComponentRef> crefLst;
String str;
Absyn.Info info;
SourceInfo info;
list<BackendDAE.Equation> eqns, reqns;
list<DAE.Statement> assrtLst;

Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -419,7 +419,7 @@ public function checkAssertCondition "Succeds if condition of assert is not cons
input DAE.Exp cond;
input DAE.Exp message;
input DAE.Exp level;
input Absyn.Info info;
input SourceInfo info;
algorithm
_ := matchcontinue(cond,message,level,info)
local
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendEquation.mo
Expand Up @@ -1724,7 +1724,7 @@ end traverseEquationToScalarResidualForm;
public function equationInfo "
Retrieve the line number information from a BackendDAE.BackendDAEequation"
input BackendDAE.Equation eq;
output Absyn.Info info;
output SourceInfo info;
algorithm
info := DAEUtil.getElementSourceFileInfo(equationSource(eq));
end equationInfo;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendVarTransform.mo
Expand Up @@ -2077,7 +2077,7 @@ algorithm
Boolean initialCall;
Integer index;
Boolean b,b1,b2,b3;
list<tuple<DAE.ComponentRef,Absyn.Info>> loopPrlVars "list of parallel variables used/referenced in the parfor loop";
list<tuple<DAE.ComponentRef,SourceInfo>> loopPrlVars "list of parallel variables used/referenced in the parfor loop";

case ({},_,_,_,_) then (listReverse(inAcc),inBAcc);

Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/Causalize.mo
Expand Up @@ -230,7 +230,7 @@ protected
list<Integer> unmatched,unmatched1,vars;
String eqn_str,var_str;
DAE.ElementSource source;
Absyn.Info info;
SourceInfo info;
array<Integer> mapIncRowEqn;
BackendDAE.EqSystem syst;
algorithm
Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/EvaluateParameter.mo
Expand Up @@ -451,7 +451,7 @@ algorithm
FCore.Cache cache;
Values.Value value;
BackendDAE.Variables knvars;
Absyn.Info info;
SourceInfo info;
String msg;
// Parameter with evaluate=true
case (BackendDAE.VAR(varName = cr,varKind=BackendDAE.CONST(),bindExp=SOME(e)),_,_,_,_,_,_,_)
Expand Down Expand Up @@ -741,7 +741,7 @@ protected function evaluateFixedAttributeReportWarning
algorithm
outE := match(b,cr,e,e1,source,knvars)
local
Absyn.Info info;
SourceInfo info;
String msg;
DAE.Exp e2;
case (true,_,_,_,_,_) then e1;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/FindZeroCrossings.mo
Expand Up @@ -1133,7 +1133,7 @@ algorithm
DAE.ElementSource source;
DAE.Else algElse;
tuple<DAE.Exp, list<DAE.Exp>, DAE.Exp, tuple<list<BackendDAE.ZeroCrossing>, list<BackendDAE.ZeroCrossing>, list<BackendDAE.ZeroCrossing>, Integer, Integer>, tuple<Integer, BackendDAE.Variables, BackendDAE.Variables>> extraArg;
list<tuple<DAE.ComponentRef, Absyn.Info>> loopPrlVars "list of parallel variables used/referenced in the parfor loop";
list<tuple<DAE.ComponentRef, SourceInfo>> loopPrlVars "list of parallel variables used/referenced in the parfor loop";
list<DAE.ComponentRef> conditions;
Boolean initialCall;

Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/IndexReduction.mo
Expand Up @@ -1837,7 +1837,7 @@ algorithm
(mulAdstates,_) = Expression.extendArrExp(mulAdstates,false);
expset = if intGt(rang,1) then DAE.ARRAY(DAE.T_ARRAY(DAE.T_REAL_DEFAULT,{DAE.DIM_INTEGER(rang)},DAE.emptyTypeSource),true,expcrset) else listGet(expcrset,1);
expderset = if intGt(rang,1) then DAE.ARRAY(DAE.T_ARRAY(DAE.T_REAL_DEFAULT,{DAE.DIM_INTEGER(rang)},DAE.emptyTypeSource),true,expcrdset) else listGet(expcrdset,1);
source = DAE.SOURCE(Absyn.INFO("stateselection",false,0,0,0,0,Absyn.dummyTimeStamp),{},NONE(),{},{},{},{});
source = DAE.SOURCE(SOURCEINFO("stateselection",false,0,0,0,0,0.0),{},NONE(),{},{},{},{});
// set.x = set.A*set.statecandidates
eqn = if intGt(rang,1) then BackendDAE.ARRAY_EQUATION({rang},expset,mulAstates,source,BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC)
else BackendDAE.EQUATION(expset,mulAstates,source,BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/Initialization.mo
Expand Up @@ -2043,7 +2043,7 @@ algorithm
BackendDAE.VarKind varKind;
HashSet.HashSet hs;
String s, str, sv;
Absyn.Info info;
SourceInfo info;

// state
case (var as BackendDAE.VAR(varName=cr, varKind=BackendDAE.STATE(index=_), varType=ty), (vars, fixvars, eqns, hs)) equation
Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/Matching.mo
Expand Up @@ -3909,7 +3909,7 @@ algorithm
String eqn_str,var_str;
BackendDAE.StructurallySingularSystemHandlerArg arg,arg1;
DAE.ElementSource source;
Absyn.Info info;
SourceInfo info;
BackendDAE.EqSystem syst;
BackendDAE.Shared shared;
array<Integer> ass1_1,ass1_2,ass2_1,ass2_2,l_label1,r_label1;
Expand Down Expand Up @@ -6227,7 +6227,7 @@ protected
list<Integer> unmatched,unmatched1,vars;
String eqn_str,var_str;
DAE.ElementSource source;
Absyn.Info info;
SourceInfo info;
array<Integer> mapIncRowEqn;
BackendDAE.EqSystem syst;
algorithm
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/RemoveSimpleEquations.mo
Expand Up @@ -1252,7 +1252,7 @@ algorithm
DAE.ComponentRef cr1, cr2;
DAE.Exp crexp1, crexp2;
String eqn_str, var_str;
Absyn.Info info;
SourceInfo info;
DAE.ElementSource source;

case(false, _, _, _, _, _) then ();
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/SerializeModelInfo.mo
Expand Up @@ -196,7 +196,7 @@ function serializeSource
input DAE.ElementSource source;
input Boolean withOperations;
protected
Absyn.Info info;
SourceInfo info;
list<Absyn.Path> paths,typeLst;
list<Absyn.Within> partOfLst;
Option<DAE.ComponentRef> iopt;
Expand Down Expand Up @@ -239,10 +239,10 @@ end serializeSource;

function serializeInfo
input File.File file;
input Absyn.Info info;
input SourceInfo info;
algorithm
_ := match i as info
case Absyn.INFO()
case SOURCEINFO()
equation
File.write(file, "{\"file\":\"");
File.writeEscape(file, i.fileName,escape=File.Escape.JSON);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/BackEnd/SymbolicJacobian.mo
Expand Up @@ -2345,8 +2345,8 @@ protected function removeStateSetEqn
output Boolean b;
algorithm
b := match(inEqn)
case BackendDAE.ARRAY_EQUATION(source=DAE.SOURCE(info=Absyn.INFO(fileName="stateselection"))) then false;
case BackendDAE.EQUATION(source=DAE.SOURCE(info=Absyn.INFO(fileName="stateselection"))) then false;
case BackendDAE.ARRAY_EQUATION(source=DAE.SOURCE(info=SOURCEINFO(fileName="stateselection"))) then false;
case BackendDAE.EQUATION(source=DAE.SOURCE(info=SOURCEINFO(fileName="stateselection"))) then false;
else true;
end match;
end removeStateSetEqn;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/SynchronousFeatures.mo
Expand Up @@ -276,7 +276,7 @@ protected
Boolean b;
DAE.ComponentRef cr;
String name;
Absyn.Info info;
SourceInfo info;
algorithm
for i in n:-1:1 loop
v := BackendVariable.getVarAt(vars, i);
Expand Down
4 changes: 2 additions & 2 deletions Compiler/FFrontEnd/FBuiltin.mo
Expand Up @@ -589,7 +589,7 @@ algorithm
Absyn.PROGRAM(classes=classes1,within_=Absyn.TOP()) = Parser.parsebuiltin(fileModelica,"UTF-8");
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 = Absyn.PROGRAM(classes,Absyn.TOP());
sp = List.map(classes, SCodeUtil.translateClass);
assocLst = getGlobalRoot(Global.builtinIndex);
setGlobalRoot(Global.builtinIndex, (Flags.METAMODELICA,(p,sp))::assocLst);
Expand All @@ -604,7 +604,7 @@ algorithm
Absyn.PROGRAM(classes=classes1,within_=Absyn.TOP()) = Parser.parsebuiltin(fileModelica,"UTF-8");
Absyn.PROGRAM(classes=classes2,within_=Absyn.TOP()) = Parser.parsebuiltin(fileParModelica,"UTF-8");
classes = listAppend(classes1,classes2);
p = Absyn.PROGRAM(classes,Absyn.TOP(),Absyn.dummyTimeStamp);
p = Absyn.PROGRAM(classes,Absyn.TOP());
sp = List.map(classes, SCodeUtil.translateClass);
assocLst = getGlobalRoot(Global.builtinIndex);
setGlobalRoot(Global.builtinIndex, (Flags.PARMODELICA,(p,sp))::assocLst);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FFrontEnd/FExpand.mo
Expand Up @@ -67,7 +67,7 @@ type Graph = FCore.Graph;
type Extra = FCore.Extra;
type Visited = FCore.Visited;
type Import = FCore.Import;
type Msg = Option<Absyn.Info>;
type Msg = Option<SourceInfo>;

public function path
"@author: adrpo
Expand Down
8 changes: 4 additions & 4 deletions Compiler/FFrontEnd/FGraphBuild.mo
Expand Up @@ -99,7 +99,7 @@ algorithm
String name;
Graph g;
SCode.ClassDef cdef;
Absyn.Info info;
SourceInfo info;

// class (we don't care here if is replaceable or not we can get that from the class)
case (SCode.CLASS( classDef = _), _, _, g)
Expand All @@ -124,7 +124,7 @@ algorithm
SCode.Element cls;
String name;
Graph g;
Absyn.Info info;
SourceInfo info;
Node n;
Ref nr;

Expand Down Expand Up @@ -1161,7 +1161,7 @@ algorithm
SCode.EEquation equ, equf, equr;
SCode.Ident iter_name;
Ref ref;
Absyn.Info info;
SourceInfo info;
Absyn.ComponentRef cref1;
Graph g;
Kind k;
Expand Down Expand Up @@ -1236,7 +1236,7 @@ algorithm
local
Ref ref;
SCode.Statement stmt;
Absyn.Info info;
SourceInfo info;
list<SCode.Statement> parforBody;
String iter_name;
Graph g;
Expand Down
8 changes: 4 additions & 4 deletions Compiler/FFrontEnd/FGraphBuildEnv.mo
Expand Up @@ -101,7 +101,7 @@ algorithm
String name;
Graph g;
SCode.ClassDef cdef;
Absyn.Info info;
SourceInfo info;

// class (we don't care here if is replaceable or not we can get that from the class)
case (SCode.CLASS( classDef = _), _, _, g)
Expand All @@ -128,7 +128,7 @@ algorithm
SCode.Element cls;
String name;
Graph g;
Absyn.Info info;
SourceInfo info;
Node n;
Ref nr;

Expand Down Expand Up @@ -1142,7 +1142,7 @@ algorithm
SCode.EEquation equ, equf, equr;
SCode.Ident iter_name;
Ref ref;
Absyn.Info info;
SourceInfo info;
Absyn.ComponentRef cref1;
Graph g;
Kind k;
Expand Down Expand Up @@ -1217,7 +1217,7 @@ algorithm
local
Ref ref;
SCode.Statement stmt;
Absyn.Info info;
SourceInfo info;
list<SCode.Statement> parforBody;
String iter_name;
Graph g;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FFrontEnd/FInst.mo
Expand Up @@ -76,7 +76,7 @@ type Extra = FCore.Extra;
type Visited = FCore.Visited;
type Import = FCore.Import;

type Msg = Option<Absyn.Info>;
type Msg = Option<SourceInfo>;


public function inst
Expand Down
4 changes: 2 additions & 2 deletions Compiler/FFrontEnd/FLookup.mo
Expand Up @@ -65,9 +65,9 @@ type Graph = FCore.Graph;
type Extra = FCore.Extra;
type Visited = FCore.Visited;
type Import = FCore.Import;
type Msg = Option<Absyn.Info>;
type Msg = Option<SourceInfo>;

constant Option<Absyn.Info> dummyLookupOption = NONE(); // SOME(Absyn.dummyInfo);
constant Option<SourceInfo> dummyLookupOption = NONE(); // SOME(Absyn.dummyInfo);

public uniontype Options
record OPTIONS
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FFrontEnd/FMod.mo
Expand Up @@ -200,7 +200,7 @@ algorithm
SCode.Each ep;
list<SCode.SubMod> submods1, submods2;
Option<tuple<Absyn.Exp, Boolean>> binding;
Absyn.Info info1, info2;
SourceInfo info1, info2;
SCode.Mod mod1, mod2;

// The second modifier has no binding, use the binding from the first.
Expand Down
6 changes: 3 additions & 3 deletions Compiler/FFrontEnd/FNode.mo
Expand Up @@ -238,7 +238,7 @@ algorithm
local
Import imp;
list<Import> qual_imps, unqual_imps;
Absyn.Info info;
SourceInfo info;
Boolean hidden;

// Unqualified imports
Expand Down Expand Up @@ -288,7 +288,7 @@ protected function checkUniqueQualifiedImport
qualified imports with the same name."
input Import inImport;
input list<Import> inImports;
input Absyn.Info inInfo;
input SourceInfo inInfo;
algorithm
_ := matchcontinue(inImport, inImports, inInfo)
local
Expand Down Expand Up @@ -595,7 +595,7 @@ algorithm
Absyn.TypeSpec t;
SCode.Mod m;
SCode.Comment comment;
Absyn.Info info;
SourceInfo info;
Option<Absyn.Exp> condition;
Data nd;
DAE.Var i;
Expand Down
18 changes: 9 additions & 9 deletions Compiler/FFrontEnd/FResolve.mo
Expand Up @@ -70,7 +70,7 @@ type Visited = FCore.Visited;
type Import = FCore.Import;
type Graph = FCore.Graph;

type Msg = Option<Absyn.Info>;
type Msg = Option<SourceInfo>;

public function ext
"@author: adrpo
Expand Down Expand Up @@ -107,7 +107,7 @@ algorithm
Absyn.Path p;
SCode.Element e;
Node n;
Absyn.Info i;
SourceInfo i;
Graph g;

// found extends that has a ref node
Expand Down Expand Up @@ -189,7 +189,7 @@ algorithm
Absyn.Path p;
SCode.ClassDef d;
Node n;
Absyn.Info i;
SourceInfo i;
Graph g;

// found derived that has a ref node
Expand Down Expand Up @@ -264,7 +264,7 @@ algorithm
Absyn.Path p;
SCode.Element e;
Node n;
Absyn.Info i;
SourceInfo i;
Graph g;

// found component that has a ref node
Expand Down Expand Up @@ -342,7 +342,7 @@ algorithm
Absyn.Path p;
SCode.Element e;
Node n;
Absyn.Info i;
SourceInfo i;
Graph g;

// found constraint class that has a ref node
Expand Down Expand Up @@ -416,7 +416,7 @@ algorithm
Ref r, rr, p;
SCode.Element e;
Node n;
Absyn.Info i;
SourceInfo i;
Name id;
Graph g;

Expand Down Expand Up @@ -498,7 +498,7 @@ algorithm
Ref r, rr;
Absyn.ComponentRef cr;
Node n;
Absyn.Info i;
SourceInfo i;
Graph g;


Expand Down Expand Up @@ -573,7 +573,7 @@ algorithm
Ref r, rr;
Absyn.ComponentRef cr;
Node n;
Absyn.Info i;
SourceInfo i;
Graph g;

// found mod that has a ref node
Expand Down Expand Up @@ -653,7 +653,7 @@ algorithm
Ref r, rr, p;
SCode.Element e;
Node n;
Absyn.Info i;
SourceInfo i;
Name id;
Graph g;

Expand Down

0 comments on commit b6f399e

Please sign in to comment.