Skip to content

Commit

Permalink
SCodeFlatten fixes:
Browse files Browse the repository at this point in the history
- Fixed path-merging bug when looking up through imports.
- Propagated Absyn.Info where needed and replaced some print-calls with proper
  error messages.
- Added evaluation of conditional expression when lookup of a component fails.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7778 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Jan 26, 2011
1 parent 06dd617 commit 7375f06
Show file tree
Hide file tree
Showing 3 changed files with 334 additions and 129 deletions.
4 changes: 4 additions & 0 deletions Compiler/FrontEnd/Inst.mo
Expand Up @@ -156,6 +156,7 @@ protected import Util;
protected import Values;
protected import ValuesUtil;
protected import System;
protected import SCodeFlatten;

public function newIdent
"function: newIdent
Expand Down Expand Up @@ -203,6 +204,7 @@ algorithm
InstanceHierarchy oIH1, oIH2, iIH;
case (cache,iIH,p)
equation
//p = SCodeFlatten.flatten(p);
// Debug.fprintln("insttr", "instantiate");
pnofunc = Util.listSelect(p, isNotFunction);
pfunc = Util.listSelect(p, SCode.isFunction);
Expand Down Expand Up @@ -305,6 +307,7 @@ algorithm

case (cache,ih,(cdecls as (_ :: _)),(path as Absyn.IDENT(name = name2))) /* top level class */
equation
//cdecls = SCodeFlatten.flatten(cdecls);
(cache,env) = Builtin.initialEnv(cache);
(cache,env_1,ih,dae1) = instClassDecls(cache, env, ih, cdecls, path);
(cache,env_2,ih,dae2) = instClassInProgram(cache, env_1, ih, cdecls, path);
Expand All @@ -324,6 +327,7 @@ algorithm

case (cache,ih,(cdecls as (_ :: _)),(path as Absyn.QUALIFIED(name = name))) /* class in package */
equation
//cdecls = SCodeFlatten.flatten(cdecls);
pathstr = Absyn.pathString(path);

//System.startTimer();
Expand Down
46 changes: 46 additions & 0 deletions Compiler/FrontEnd/SCode.mo
Expand Up @@ -3542,5 +3542,51 @@ algorithm
end match;
end isBuiltinFunction;

public function getEEquationInfo
"Extracts the Absyn.Info from an EEquation."
input EEquation inEEquation;
output Absyn.Info outInfo;
algorithm
outInfo := match(inEEquation)
local
Absyn.Info info;

case EQ_IF(info = info) then info;
case EQ_EQUALS(info = info) then info;
case EQ_CONNECT(info = info) then info;
case EQ_FOR(info = info) then info;
case EQ_WHEN(info = info) then info;
case EQ_ASSERT(info = info) then info;
case EQ_TERMINATE(info = info) then info;
case EQ_REINIT(info = info) then info;
case EQ_NORETCALL(info = info) then info;
end match;
end getEEquationInfo;

public function getStatementInfo
"Extracts the Absyn.Info from a Statement."
input Statement inStatement;
output Absyn.Info outInfo;
algorithm
outInfo := match(inStatement)
local
Absyn.Info info;

case ALG_ASSIGN(info = info) then info;
case ALG_IF(info = info) then info;
case ALG_FOR(info = info) then info;
case ALG_WHILE(info = info) then info;
case ALG_WHEN_A(info = info) then info;
case ALG_NORETCALL(info = info) then info;
case ALG_RETURN(info = info) then info;
case ALG_BREAK(info = info) then info;
case ALG_TRY(info = info) then info;
case ALG_CATCH(info = info) then info;
case ALG_CATCH(info = info) then info;
case ALG_THROW(info = info) then info;
case ALG_FAILURE(info = info) then info;
end match;
end getStatementInfo;

end SCode;

0 comments on commit 7375f06

Please sign in to comment.