Skip to content

Commit

Permalink
- Propagate Absyn.Info from every equation and algorithm up to the DA…
Browse files Browse the repository at this point in the history
…E AST

  - One exception: The parser segfauls on Absyn.Algorithm in mosfiles, so dummyInfo is provided for most algorithm sections.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5842 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jul 10, 2010
1 parent 875344a commit 9d3d913
Show file tree
Hide file tree
Showing 24 changed files with 979 additions and 936 deletions.
163 changes: 85 additions & 78 deletions Compiler/Algorithm.mo

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Compiler/ConnectUtil.mo
Expand Up @@ -703,7 +703,7 @@ algorithm
list<tuple<DAE.ComponentRef,DAE.ElementSource>> cs;
DAE.ElementSource src,src1,src2;
DAE.FunctionTree funcs;
list<Absyn.Info> infoLst;
Absyn.Info info;
list<Absyn.Within> partOfLst;
list<Option<DAE.ComponentRef>> instanceOptLst;
list<Option<tuple<DAE.ComponentRef, DAE.ComponentRef>>> connectEquationOptLst;
Expand All @@ -713,9 +713,9 @@ algorithm
case ((x,src1) :: ((y,src2) :: cs))
equation
DAE.DAE(eq,funcs) = equEquations(((y,src2) :: cs));
DAE.SOURCE(infoLst, partOfLst, instanceOptLst, connectEquationOptLst, typeLst) = DAEUtil.mergeSources(src1,src2);
DAE.SOURCE(info, partOfLst, instanceOptLst, connectEquationOptLst, typeLst) = DAEUtil.mergeSources(src1,src2);
// do not propagate connects from different sources! use the crefs directly!
src = DAE.SOURCE(infoLst, partOfLst, instanceOptLst, {SOME((x,y))}, typeLst);
src = DAE.SOURCE(info, partOfLst, instanceOptLst, {SOME((x,y))}, typeLst);
then
(DAE.DAE(DAE.EQUEQUATION(x,y,src) :: eq,funcs));
case(_) equation print(" FAILURE IN CONNECT \n"); then fail();
Expand Down
23 changes: 21 additions & 2 deletions Compiler/DAE.mo
Expand Up @@ -104,15 +104,15 @@ end VarProtection;

uniontype ElementSource "gives information about the origin of the element"
record SOURCE
list<Absyn.Info> infoLst "the line and column numbers of the equations and algorithms this element came from; info does not yet exist in Absyn, but here is where it will end up";
Absyn.Info info "the line and column numbers of the equations and algorithms this element came from; info does not yet exist in Absyn, but here is where it will end up";
list<Absyn.Within> partOfLst "the model(s) this element came from";
list<Option<ComponentRef>> instanceOptLst "the instance(s) this element is part of";
list<Option<tuple<ComponentRef, ComponentRef>>> connectEquationOptLst "this element came from this connect(s)";
list<Absyn.Path> typeLst "the classes where the type(s) of the element is defined";
end SOURCE;
end ElementSource;

public constant ElementSource emptyElementSource = SOURCE({},{},{},{},{});
public constant ElementSource emptyElementSource = SOURCE(Absyn.dummyInfo,{},{},{},{});

public uniontype Element
record VAR
Expand Down Expand Up @@ -465,24 +465,28 @@ uniontype Statement "There are four kinds of statements. Assignments (`a := b;\
ExpType type_;
Exp exp1;
Exp exp;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_ASSIGN;

record STMT_TUPLE_ASSIGN
ExpType type_;
list<Exp> expExpLst;
Exp exp;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_TUPLE_ASSIGN;

record STMT_ASSIGN_ARR
ExpType type_;
ComponentRef componentRef;
Exp exp;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_ASSIGN_ARR;

record STMT_IF
Exp exp;
list<Statement> statementLst;
Else else_;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_IF;

record STMT_FOR
Expand All @@ -491,67 +495,82 @@ uniontype Statement "There are four kinds of statements. Assignments (`a := b;\
Ident ident;
Exp exp;
list<Statement> statementLst;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_FOR;

record STMT_WHILE
Exp exp;
list<Statement> statementLst;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_WHILE;

record STMT_WHEN
Exp exp;
list<Statement> statementLst;
Option<Statement> elseWhen;
list<Integer> helpVarIndices;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_WHEN;

record STMT_ASSERT "assert(cond,msg)"
Exp cond;
Exp msg;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_ASSERT;

record STMT_TERMINATE "terminate(msg)"
Exp msg;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_TERMINATE;

record STMT_REINIT
Exp var "Variable";
Exp value "Value ";
ElementSource source "the origin of the component/equation/algorithm";
end STMT_REINIT;

record STMT_NORETCALL "call with no return value, i.e. no equation.
Typically sideeffect call of external function."
Exp exp;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_NORETCALL;

record STMT_RETURN
ElementSource source "the origin of the component/equation/algorithm";
end STMT_RETURN;

record STMT_BREAK
ElementSource source "the origin of the component/equation/algorithm";
end STMT_BREAK;

// MetaModelica extension. KS
record STMT_TRY
list<Statement> tryBody;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_TRY;

record STMT_CATCH
list<Statement> catchBody;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_CATCH;

record STMT_THROW
ElementSource source "the origin of the component/equation/algorithm";
end STMT_THROW;

record STMT_GOTO
String labelName;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_GOTO;

record STMT_LABEL
String labelName;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_LABEL;

record STMT_MATCHCASES "matchcontinue helper"
list<Exp> caseStmt;
ElementSource source "the origin of the component/equation/algorithm";
end STMT_MATCHCASES;

//-----
Expand Down
18 changes: 9 additions & 9 deletions Compiler/DAEDump.mo
Expand Up @@ -1470,19 +1470,19 @@ algorithm
Print.printBuf(");\n");
then
();
case (DAE.STMT_RETURN(),i)
case (DAE.STMT_RETURN(source = _),i)
equation
indent(i);
Print.printBuf("return;\n");
then
();
case (DAE.STMT_BREAK(),i)
case (DAE.STMT_BREAK(source = _),i)
equation
indent(i);
Print.printBuf("break;\n");
then
();
case (DAE.STMT_REINIT(e1,e2),i)
case (DAE.STMT_REINIT(var = e1, value = e2),i)
local DAE.Exp e1,e2;
equation
indent(i);
Expand All @@ -1493,23 +1493,23 @@ algorithm
Print.printBuf(");\n");
then
();
case (DAE.STMT_TRY(stmts),i)
case (DAE.STMT_TRY(tryBody = stmts),i)
equation
indent(i);
Print.printBuf("try\n");
ppStmtList(stmts, i+2);
Print.printBuf("end try;\n");
then
();
case (DAE.STMT_CATCH(stmts),i)
case (DAE.STMT_CATCH(catchBody = stmts),i)
equation
indent(i);
Print.printBuf("catch\n");
ppStmtList(stmts, i+2);
Print.printBuf("end catch;\n");
then
();
case (DAE.STMT_MATCHCASES(expl),i)
case (DAE.STMT_MATCHCASES(caseStmt = expl),i)
equation
indent(i);
Print.printBuf("matchcases ");
Expand Down Expand Up @@ -1717,21 +1717,21 @@ algorithm
then
str;

case (DAE.STMT_NORETCALL(e),i)
case (DAE.STMT_NORETCALL(exp = e),i)
equation
s1 = indentStr(i);
s2 = Exp.printExpStr(e);
str = Util.stringAppendList({s1,s2,"\n"});
then
str;

case (DAE.STMT_BREAK(),i)
case (DAE.STMT_BREAK(source = _),i)
equation
s1 = indentStr(i);
str = stringAppend(s1, "break;\n");
then
str;
case (DAE.STMT_REINIT(e1,e2),i)
case (DAE.STMT_REINIT(var = e1, value = e2),i)
local DAE.Exp e1,e2; String e1_str,e2_str;
equation
s1 = indentStr(i);
Expand Down

0 comments on commit 9d3d913

Please sign in to comment.