Skip to content

Commit

Permalink
Fixed so a few more external functions can be generated.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4758 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Rickard Lindberg committed Jan 8, 2010
1 parent 0afa330 commit a53758e
Show file tree
Hide file tree
Showing 5 changed files with 1,344 additions and 551 deletions.
33 changes: 31 additions & 2 deletions Compiler/SimCode.mo
Expand Up @@ -323,6 +323,7 @@ uniontype Function
//FunctionArguments functionArguments "the function arguments";
//VariableDeclarations variableDeclarations "the declarations of local variables";
Path name;
Ident extName;
list<Variable> funArgs;
list<SimExtArg> extArgs;
SimExtArg extReturn;
Expand Down Expand Up @@ -928,10 +929,10 @@ algorithm
// wrapper_body = generateFunctionReferenceWrapperBody(fpath, tp);
// cfns = func_decl :: rcw_fn :: ext_decl :: wrapper_body;
simextargs = Util.listMap(extargs, extArgsToSimExtArgs);
simextargs = fixOutputIndex(simextargs, 0);
extReturn = extArgsToSimExtArgs(extretarg);
(simextargs, extReturn) = fixOutputIndexOuter(simextargs, extReturn);
then
(EXTERNAL_FUNCTION(fpath, funArgs, simextargs, extReturn, inVars, outVars, biVars, includes, libs, lang), rt);
(EXTERNAL_FUNCTION(fpath, extfnname, funArgs, simextargs, extReturn, inVars, outVars, biVars, includes, libs, lang), rt);
/* Can we even end up in this case? isFunction returns false for COMP */
//case (DAE.COMP(ident = n,dAElist = DAE.DAE(elementLst = daelist)),rt)
// equation
Expand All @@ -946,6 +947,34 @@ algorithm
end matchcontinue;
end elaborateFunction;

protected function fixOutputIndexOuter
input list<SimExtArg> simExtArgsIn;
input SimExtArg extReturnIn;
output list<SimExtArg> simExtArgsOut;
output SimExtArg extReturnOut;
algorithm
(simExtArgsOut, extReturnOut) :=
matchcontinue (simExtArgsIn, extReturnIn)
local
DAE.ComponentRef cref;
Boolean isInput;
Integer outputIndex;
Boolean isArray;
DAE.ExpType type_;
case (simExtArgsIn, SIMEXTARG(cref, isInput, outputIndex, isArray, type_))
equation
simExtArgsOut = fixOutputIndex(simExtArgsIn, 1);
extReturnOut = SIMEXTARG(cref, isInput, 1, isArray, type_);
then
(simExtArgsOut, extReturnOut);
case (simExtArgsIn, extReturnIn)
equation
simExtArgsOut = fixOutputIndex(simExtArgsIn, 0);
then
(simExtArgsOut, extReturnIn);
end matchcontinue;
end fixOutputIndexOuter;

protected function fixOutputIndex
input list<SimExtArg> simExtArgsIn;
input Integer newOutputIndex;
Expand Down

0 comments on commit a53758e

Please sign in to comment.