Skip to content

Commit

Permalink
- Removed inVars from SimCode.FUNCTION (unused)
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7557 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Dec 23, 2010
1 parent 3f9e83c commit fe21650
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions Compiler/BackEnd/SimCode.mo
Expand Up @@ -265,7 +265,6 @@ end AliasVariable;
uniontype Function
record FUNCTION
Absyn.Path name;
list<Variable> inVars;
list<Variable> outVars;
list<Variable> functionArguments;
list<Variable> variableDeclarations;
Expand Down Expand Up @@ -1234,7 +1233,7 @@ algorithm
_ := matchcontinue (name,fn)
local
list<Variable> inVars;
case (_,FUNCTION(inVars = inVars))
case (_,FUNCTION(functionArguments = inVars))
equation
failure(_ = Util.listSelectFirst(inVars, isFunctionPtr));
then ();
Expand All @@ -1249,6 +1248,29 @@ algorithm
end matchcontinue;
end checkValidMainFunction;

public function isBoxedFunction
"Verifies that an in-function can be generated.
This is not the case if the input involves function-pointers."
input Function fn;
output Boolean b;
algorithm
b := matchcontinue fn
local
list<Variable> inVars,outVars;
case (FUNCTION(functionArguments = inVars, outVars = outVars))
equation
Util.listMap0(inVars, isBoxedArg);
Util.listMap0(outVars, isBoxedArg);
then true;
case (EXTERNAL_FUNCTION(inVars = inVars, outVars = outVars))
equation
Util.listMap0(inVars, isBoxedArg);
Util.listMap0(outVars, isBoxedArg);
then true;
else false;
end matchcontinue;
end isBoxedFunction;

protected function isFunctionPtr
"Checks if an input variable is a function pointer"
input Variable var;
Expand All @@ -1264,6 +1286,17 @@ algorithm
end matchcontinue;
end isFunctionPtr;

protected function isBoxedArg
"Checks if a variable is a boxed datatype"
input Variable var;
algorithm
_ := match var
case FUNCTION_PTR(tys = _) then ();
case VARIABLE(ty = DAE.ET_BOXED(_)) then ();
case VARIABLE(ty = DAE.ET_METATYPE()) then ();
end match;
end isBoxedArg;

/* Finds the called functions in BackendDAE and transforms them to a list of
libraries and a list of Function uniontypes. */
public function createFunctions
Expand Down Expand Up @@ -1496,15 +1529,14 @@ algorithm
partialPrefix=false), rt, recordDecls, includes, libs)
equation
outVars = Util.listMap(DAEUtil.getOutputVars(daeElts), daeInOutSimVar);
inVars = Util.listMap(DAEUtil.getInputVars(daeElts), daeInOutSimVar);
funArgs = Util.listMap(args, typesSimFunctionArg);
(recordDecls,rt_1) = elaborateRecordDeclarations(daeElts, recordDecls, rt);
vars = Util.listFilter(daeElts, isVarQ);
varDecls = Util.listMap(vars, daeInOutSimVar);
algs = Util.listFilter(daeElts, DAEUtil.isAlgorithm);
bodyStmts = Util.listMap(algs, elaborateStatement);
then
(FUNCTION(fpath,inVars,outVars,funArgs,varDecls,bodyStmts),rt_1,recordDecls,includes,libs);
(FUNCTION(fpath,outVars,funArgs,varDecls,bodyStmts),rt_1,recordDecls,includes,libs);

// External functions.
case (DAE.FUNCTION(path = fpath,
Expand Down

0 comments on commit fe21650

Please sign in to comment.