Skip to content

Commit

Permalink
- Function pointers now work in both Modelica and MetaModelica
Browse files Browse the repository at this point in the history
- Partially evaluated functions now partially works!


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4530 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Stefan Brus committed Nov 17, 2009
1 parent 59f2f41 commit af02c75
Show file tree
Hide file tree
Showing 7 changed files with 988 additions and 1,278 deletions.
18 changes: 17 additions & 1 deletion Compiler/Codegen.mo
Expand Up @@ -2462,7 +2462,7 @@ algorithm
// Only generate these functions if we use MetaModelica grammar
case (fpath,ty1)
equation
false = RTOpts.acceptMetaModelicaGrammar();
false = RTOpts.debugFlag("fnptr") or RTOpts.acceptMetaModelicaGrammar();
then {};
case (fpath,ty1)
equation
Expand Down Expand Up @@ -9532,6 +9532,22 @@ algorithm
outExprLst := matchcontinue (inExpr)
local Exp.Exp e; Exp.Type t;
case((e as Exp.CREF(ty = Exp.ET_FUNCTION_REFERENCE_FUNC()))) then {e};
case(Exp.PARTEVALFUNCTION(ty = Exp.ET_FUNCTION_REFERENCE_VAR(),path=p,expList=expLst))
local
Exp.ComponentRef cref; Absyn.Path p; list<Exp.Exp> expLst,expLst_1;
equation
cref = Exp.pathToCref(p);
e = Exp.makeCrefExp(cref,Exp.ET_FUNCTION_REFERENCE_VAR());
expLst_1 = getMatchingExpsList(expLst,matchFnRefs);
then
e :: expLst_1;
case(Exp.CALL(expLst = expLst))
local
list<Exp.Exp> expLst,expLst_1;
equation
expLst_1 = getMatchingExpsList(expLst,matchFnRefs);
then
expLst_1;
end matchcontinue;
end matchFnRefs;

Expand Down
2 changes: 1 addition & 1 deletion Compiler/Inst.mo
Expand Up @@ -1002,7 +1002,7 @@ algorithm
(c as SCode.CLASS(name = n,encapsulatedPrefix = encflag,restriction = r as SCode.R_FUNCTION(), partialPrefix = true)),
inst_dims,impl,callscope,graph)
equation
true = RTOpts.acceptMetaModelicaGrammar();
true = RTOpts.debugFlag("fnptr") or RTOpts.acceptMetaModelicaGrammar();

env_1 = Env.openScope(env, encflag, SOME(n));
ci_state = ClassInf.start(r, n);
Expand Down

0 comments on commit af02c75

Please sign in to comment.