Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
fix ticket:4292, handle DAE.REDUCTION also
Browse files Browse the repository at this point in the history
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Mar 1, 2017
1 parent 64ce9d9 commit b1a493a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Compiler/FrontEnd/NFSCodeFlattenImports.mo
Original file line number Diff line number Diff line change
Expand Up @@ -633,18 +633,21 @@ algorithm
Absyn.ForIterators iters;
SourceInfo info;
tuple<Env, SourceInfo> tup;
Absyn.ReductionIterType iterType;

case (Absyn.CREF(componentRef = cref), tup as (env, info))
equation
cref = NFSCodeLookup.lookupComponentRef(cref, env, info);
then
(Absyn.CREF(cref), tup);

case (Absyn.CALL(functionArgs = Absyn.FOR_ITER_FARG(iterators = iters)), (env, info))
case (Absyn.CALL(function_ = cref, functionArgs = args as Absyn.FOR_ITER_FARG(exp = exp, iterType = iterType, iterators = iters)), (env, info))
equation
cref = NFSCodeLookup.lookupComponentRef(cref, env, info);
env = NFSCodeEnv.extendEnvWithIterators(iters, System.tmpTickIndex(NFSCodeEnv.tmpTickIndex), env);
exp = flattenExp(exp, env, info);
then
(inExp, (env, info));
(Absyn.CALL(cref, Absyn.FOR_ITER_FARG(exp, iterType, iters)), (env, info));

case (Absyn.CALL(function_ = Absyn.CREF_IDENT(name = "SOME")), _)
then (inExp,inTuple);
Expand Down
3 changes: 3 additions & 0 deletions Compiler/Script/CevalScript.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1952,6 +1952,9 @@ algorithm
local
String name;

case DAE.REDUCTION(reductionInfo = DAE.REDUCTIONINFO(path = Absyn.FULLYQUALIFIED(Absyn.QUALIFIED(name = name))))
then List.consOnTrue(not listMember(name, inAcc), name, inAcc);

case DAE.CALL(path = Absyn.FULLYQUALIFIED(Absyn.QUALIFIED(name = name)),
attr = DAE.CALL_ATTR(builtin = false))
then List.consOnTrue(not listMember(name, inAcc), name, inAcc);
Expand Down
8 changes: 4 additions & 4 deletions Compiler/SimCode/SimCodeFunction.mo
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ algorithm
equation
// Create FunctionCode
(daeElements,literals) = SimCodeFunctionUtil.findLiterals(daeMainFunction::daeElements);
(mainFunction::fns, extraRecordDecls, includes, includeDirs, libs,libPaths) = SimCodeFunctionUtil.elaborateFunctions(program, daeElements, metarecordTypes, literals, includes);
(mainFunction::fns, extraRecordDecls, includes, includeDirs, libs, libPaths) = SimCodeFunctionUtil.elaborateFunctions(program, daeElements, metarecordTypes, literals, includes);
SimCodeFunctionUtil.checkValidMainFunction(name, mainFunction);
makefileParams = SimCodeFunctionUtil.createMakefileParams(includeDirs, libs,libPaths, true);
makefileParams = SimCodeFunctionUtil.createMakefileParams(includeDirs, libs, libPaths, true);
fnCode = FUNCTIONCODE(name, SOME(mainFunction), fns, literals, includes, makefileParams, extraRecordDecls);
// Generate code
_ = Tpl.tplString(CodegenCFunctions.translateFunctions, fnCode);
Expand All @@ -286,8 +286,8 @@ algorithm
equation
// Create FunctionCode
(daeElements,literals) = SimCodeFunctionUtil.findLiterals(daeElements);
(fns, extraRecordDecls, includes, includeDirs, libs,libPaths) = SimCodeFunctionUtil.elaborateFunctions(program, daeElements, metarecordTypes, literals, includes);
makefileParams = SimCodeFunctionUtil.createMakefileParams(includeDirs, libs,libPaths, true);
(fns, extraRecordDecls, includes, includeDirs, libs, libPaths) = SimCodeFunctionUtil.elaborateFunctions(program, daeElements, metarecordTypes, literals, includes);
makefileParams = SimCodeFunctionUtil.createMakefileParams(includeDirs, libs, libPaths, true);
// remove OpenModelica.threadData.ThreadData
fns = removeThreadDataFunction(fns, {});
extraRecordDecls = removeThreadDataRecord(extraRecordDecls, {});
Expand Down

0 comments on commit b1a493a

Please sign in to comment.