Skip to content

Commit

Permalink
[Janitor mode] Fix whitespace
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@24579 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
OpenModelica-Hudson committed Feb 14, 2015
1 parent 99a799a commit 7b6e7e2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 49 deletions.
20 changes: 10 additions & 10 deletions Compiler/FrontEnd/ComponentReference.mo
Expand Up @@ -1334,24 +1334,24 @@ algorithm
list<DAE.Dimension> dims;
list<DAE.ComponentRef> tempcrefs;
Integer ndim, nsub;

case _ equation {} = crefSubs(inCref); then true;

case _
case _
equation
(subs as (_::_))= crefSubs(inCref);
dims = crefDims(inCref);
// Dimensions may be removed when a component is instantiated if it has
// constant subscripts though, so it may have more subscripts than
// dimensions.
// dimensions.
// mahge: TODO: Does this still happen?
true = listLength(dims) <= listLength(subs);
true = Expression.subscriptConstants(subs);
then
true;

else false;

end matchcontinue;
end crefIsScalarWithAllConstSubs;

Expand All @@ -1367,22 +1367,22 @@ algorithm
list<DAE.Dimension> dims;
list<DAE.ComponentRef> tempcrefs;
Integer ndim, nsub;
case _

case _
equation
(subs as (_::_))= crefSubs(inCref);
dims = crefDims(inCref);
// Dimensions may be removed when a component is instantiated if it has
// constant subscripts though, so it may have more subscripts than
// dimensions.
// dimensions.
// mahge: TODO: Does this still happen?
true = listLength(dims) <= listLength(subs);
false = Expression.subscriptConstants(subs);
then
true;

else false;

end matchcontinue;
end crefIsScalarWithVariableSubs;

Expand Down
6 changes: 3 additions & 3 deletions Compiler/SimCode/SimCodeUtil.mo
Expand Up @@ -13927,15 +13927,15 @@ end getVariableIndex;
public function generateSubPalceholders
input DAE.ComponentRef cr;
output String outdef;
protected
protected
list<DAE.Dimension> dims;
Integer nrdims;
Integer nrdims;
list<String> idxstrlst;
algorithm
dims := ComponentReference.crefDims(cr);
nrdims := listLength(dims);
idxstrlst := List.map(List.intRange(nrdims),intString);
outdef := stringDelimitList(List.threadMap(List.fill("i_", nrdims), idxstrlst, stringAppend), ",");
outdef := stringDelimitList(List.threadMap(List.fill("i_", nrdims), idxstrlst, stringAppend), ",");
end generateSubPalceholders;

public function execStat
Expand Down
52 changes: 26 additions & 26 deletions Compiler/Template/CodegenC.tpl
Expand Up @@ -1043,7 +1043,7 @@ template globalDataParDefine(SimVar simVar, String arrayName)
<<
/* <%crefStrNoUnderscore(c)%> */
#define <%cref(c)%> data->simulationInfo.<%arrayName%>[<%index%>]

<%crefMacroSubsAtEndParNew(name)%>

/* <%crefStrNoUnderscore(name)%> */
Expand Down Expand Up @@ -1078,7 +1078,7 @@ template globalDataVarDefine(SimVar simVar, String arrayName, Integer offset) "t
#define _<%cref(c)%>(i) data->localData[i]-><%arrayName%>[<%intAdd(offset,index)%>]
#define <%cref(c)%> _<%cref(c)%>(0)
#define $P$PRE<%cref(c)%> data->simulationInfo.<%arrayName%>Pre[<%intAdd(offset,index)%>]

<%crefMacroSubsAtEndVarNew(name)%>

/* <%crefStrNoUnderscore(name)%> */
Expand Down Expand Up @@ -7189,31 +7189,31 @@ template algStmtTupleAssign(DAE.Statement stmt, Context context, Text &varDecls,
match stmt
case STMT_TUPLE_ASSIGN(expExpLst={_}) then
error(sourceInfo(), "A tuple assignment of only one variable is a regular assignment")

case STMT_TUPLE_ASSIGN(expExpLst = firstexp::_, exp = CALL(attr=CALL_ATTR(ty=T_TUPLE(types=ntys)))) then
let &preExp = buffer ""
let &postExp = buffer ""
let lhsCrefs = (List.rest(expExpLst) |> e =>
let lhsCrefs = (List.rest(expExpLst) |> e =>
match e
case CREF(componentRef=WILD(__)) then ", NULL"
else ", &" + tupleReturnVariableUpdates(e, context, varDecls, postExp, &auxFunction)
end match)

// The tuple expressions might take fewer variables than the number of outputs. No worries.
let lhsCrefs2 = lhsCrefs + List.fill(", NULL", intMax(0,intSub(listLength(ntys),listLength(expExpLst))))
let call = daeExpCallTuple(exp, lhsCrefs2, context, &preExp, &varDecls, &auxFunction)
let &preExp +=
let &preExp +=
match firstexp
case CREF(componentRef=WILD(__)) then '<%call%>;<%\n%>'
else '<%tupleReturnVariableUpdates(firstexp, context, varDecls, postExp, auxFunction)%> = <%call%>;<%\n%>'
end match

<<
/* tuple assignment <%expExpLst |> e => Util.escapeModelicaStringToCString(printExpStr(e)) ; separator=", "%>*/
<%preExp%>
<%postExp%>
>>

case STMT_TUPLE_ASSIGN(exp=MATCHEXPRESSION(__)) then
let &preExp = buffer ""
let prefix = 'tmp<%System.tmpTick()%>'
Expand All @@ -7237,7 +7237,7 @@ match stmt
<%lhsCrefs%>
>>
else error(sourceInfo(), 'algStmtTupleAssign failed')

end algStmtTupleAssign;

template tupleReturnVariableUpdates(Exp inExp, Context context, Text &varDecls, Text &varCopy, Text &auxFunction)
Expand All @@ -7249,7 +7249,7 @@ template tupleReturnVariableUpdates(Exp inExp, Context context, Text &varDecls,
let &preExp = buffer ""
let rhsStr = tempDecl("base_array_t", &varDecls)
let lhsStr = contextCref(cr, context, &auxFunction)
let &varCopy +=
let &varCopy +=
match context
case SIMULATION_CONTEXT(__) then
<<
Expand All @@ -7270,7 +7270,7 @@ template tupleReturnVariableUpdates(Exp inExp, Context context, Text &varDecls,
let rhsStr = tempDecl(expTypeArrayIf(ty), &varDecls)
let lhsStr = contextCref(cr, context, &auxFunction)
let tmp = tempDecl(expTypeModelica(ty),&varDecls)
let &varCopy +=
let &varCopy +=
/*TODO handle array record memebers. see algStmtAssign*/
<<
<%preExp%>
Expand All @@ -7281,14 +7281,14 @@ template tupleReturnVariableUpdates(Exp inExp, Context context, Text &varDecls,
%>
>> /*varCopy end*/
rhsStr

/*This CALL case shouldn't have been created by the compiler. It only comes because of alias eliminations. On top of that
at least it should have been a record_constractor not a normal call. sigh. */
at least it should have been a record_constractor not a normal call. sigh. */
case CALL(path=path,expLst=expLst,attr=CALL_ATTR(ty=ty as T_COMPLEX(varLst = varLst, complexClassType=RECORD(__)))) then
let &preExp = buffer ""
let rhsStr = tempDecl(expTypeArrayIf(ty), &varDecls)
let tmp = tempDecl(expTypeModelica(ty),&varDecls)
let &varCopy +=
let &varCopy +=
/*TODO handle array record memebers. see algStmtAssign*/
<<
<%preExp%>
Expand All @@ -7300,7 +7300,7 @@ template tupleReturnVariableUpdates(Exp inExp, Context context, Text &varDecls,
%>
>> /*varCopy end*/
rhsStr

case CREF(componentRef=WILD(__)) then
''
case CREF(__) then
Expand Down Expand Up @@ -7898,11 +7898,11 @@ template daeExpCrefRhs(Exp exp, Context context, Text &preExp,
case CREF(componentRef = cr, ty = T_FUNCTION_REFERENCE_FUNC(__)) then
'boxvar_<%crefFunctionName(cr)%>'
case CREF(componentRef = cr, ty = T_FUNCTION_REFERENCE_VAR(__)) then
'((modelica_fnptr) _<%crefStr(cr)%>)'
'((modelica_fnptr) _<%crefStr(cr)%>)'
case CREF(componentRef = cr as CREF_QUAL(subscriptLst={}, identType = T_METATYPE(ty=ty as T_METARECORD(__)), componentRef=cri as CREF_IDENT(__))) then
let offset = intAdd(findVarIndex(cri.ident,ty.fields),2)
'(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(_<%cr.ident%>), <%offset%>)))'
else
else
match context
case FUNCTION_CONTEXT(__) then daeExpCrefRhsFunContext(exp, context, &preExp, &varDecls, &auxFunction)
case PARALLEL_FUNCTION_CONTEXT(__) then daeExpCrefRhsFunContext(exp, context, &preExp, &varDecls, &auxFunction)
Expand All @@ -7916,20 +7916,20 @@ template daeExpCrefRhsSimContext(Exp ecr, Context context, Text &preExp,
match ecr
case ecr as CREF(componentRef = cr, ty = t as T_COMPLEX(complexClassType = EXTERNAL_OBJ(__))) then
contextCref(cr, context, &auxFunction)

case ecr as CREF(componentRef = cr, ty = t as T_COMPLEX(complexClassType = record_state, varLst = var_lst)) then
let vars = var_lst |> v => (", " + daeExp(makeCrefRecordExp(cr,v), context, &preExp, &varDecls, &auxFunction))
let record_type_name = underscorePath(ClassInf.getStateName(record_state))
'omc_<%record_type_name%>(threadData<%vars%>)'

case ecr as CREF(ty=T_ARRAY(ty=aty,dims=dims)) then
let tmpArr = tempDecl(expTypeArray(aty), &varDecls)
let dimsLenStr = listLength(dims)
let dimsValuesStr = (dims |> dim => dimension(dim) ;separator=", ")
let type = expTypeShort(aty)
let &preExp += '<%type%>_array_create(&<%tmpArr%>, ((modelica_<%type%>*)&(<%arrayCrefCStr(ecr.componentRef)%>)), <%dimsLenStr%>, <%dimsValuesStr%>);<%\n%>'
tmpArr

case ecr as CREF(componentRef=cr, ty=ty) then
if crefIsScalarWithAllConstSubs(cr) then
let cast = match ty case T_INTEGER(__) then "(modelica_integer)"
Expand Down Expand Up @@ -8022,7 +8022,7 @@ template daeExpCrefLhs(Exp exp, Context context, Text &preExp,
'((modelica_fnptr)boxptr_<%crefFunctionName(cr)%>)'
case CREF(componentRef = cr, ty = T_FUNCTION_REFERENCE_VAR(__)) then
'_<%crefStr(cr)%>'
else
else
match context
case FUNCTION_CONTEXT(__) then daeExpCrefLhsFunContext(exp, context, &preExp, &varDecls, &auxFunction)
case PARALLEL_FUNCTION_CONTEXT(__) then daeExpCrefLhsFunContext(exp, context, &preExp, &varDecls, &auxFunction)
Expand All @@ -8036,21 +8036,21 @@ template daeExpCrefLhsSimContext(Exp ecr, Context context, Text &preExp,
match ecr
case ecr as CREF(componentRef = cr, ty = t as T_COMPLEX(complexClassType = EXTERNAL_OBJ(__))) then
contextCref(cr, context, &auxFunction)

case ecr as CREF(componentRef = cr, ty = t as T_COMPLEX(complexClassType = record_state, varLst = var_lst)) then
let vars = var_lst |> v => (", " + daeExp(makeCrefRecordExp(cr,v), context, &preExp, &varDecls, &auxFunction))
let record_type_name = underscorePath(ClassInf.getStateName(record_state))
// 'omc_<%record_type_name%>(threadData<%vars%>)'
error(sourceInfo(), 'daeExpCrefLhsSimContext got record <%crefStr(cr)%>. This does not make sense. Assigning to records is handled in a different way in the code generator, and reaching here is probably an error...') // '<%ret_var%>.c1'

case ecr as CREF(ty=T_ARRAY(ty=aty,dims=dims)) then
let tmpArr = tempDecl(expTypeArray(aty), &varDecls)
let dimsLenStr = listLength(dims)
let dimsValuesStr = (dims |> dim => dimension(dim) ;separator=", ")
let type = expTypeShort(aty)
let &preExp += '<%type%>_array_create(&<%tmpArr%>, ((modelica_<%type%>*)&(<%arrayCrefCStr(ecr.componentRef)%>)), <%dimsLenStr%>, <%dimsValuesStr%>);<%\n%>'
tmpArr

case ecr as CREF(componentRef=cr, ty=ty) then
if crefIsScalarWithAllConstSubs(cr) then
'<%contextCref(cr,context, &auxFunction)%>'
Expand Down Expand Up @@ -8092,7 +8092,7 @@ template daeExpCrefLhsFunContext(Exp ecr, Context context, Text &preExp,
>>
else
error(sourceInfo(),'This should have been handled in the new daeExpCrefLhsSimContext function. <%printExpStr(ecr)%>')

else
// The array subscript denotes a slice
let arrName = contextArrayCref(cr, context)
Expand All @@ -8101,7 +8101,7 @@ template daeExpCrefLhsFunContext(Exp ecr, Context context, Text &preExp,
let spec1 = daeExpCrefIndexSpec(crefSubs(cr), context, &preExp, &varDecls, &auxFunction)
let &preExp += 'indexed_assign_<%arrayType%>(<%tmp%>, &<%arrName%>, &<%spec1%>);<%\n%>'
tmp

case ecr then
error(sourceInfo(), 'SimCodeC.tpl template: daeExpCrefLhsFunContext: UNHANDLED EXPRESSION: <%ExpressionDump.printExpStr(ecr)%>')
end daeExpCrefLhsFunContext;
Expand Down
6 changes: 3 additions & 3 deletions Compiler/Template/SimCodeTV.mo
Expand Up @@ -889,7 +889,7 @@ package SimCodeUtil
input SimCode.SimCode simCode;
output list<list<Integer>> outColors;
end translateColorsSimVarInts;

function generateSubPalceholders
input DAE.ComponentRef cr;
output String outdef;
Expand Down Expand Up @@ -2779,12 +2779,12 @@ package ComponentReference
input Boolean expandRecord;
output list<DAE.ComponentRef> outCref;
end expandCref;

function crefIsScalarWithAllConstSubs
input DAE.ComponentRef inCref;
output Boolean isScalar;
end crefIsScalarWithAllConstSubs;

function crefIsScalarWithVariableSubs
input DAE.ComponentRef inCref;
output Boolean isScalar;
Expand Down
14 changes: 7 additions & 7 deletions SimulationRuntime/c/util/base_array.c
Expand Up @@ -310,10 +310,10 @@ size_t calc_base_index_dims_subs(int ndims,...)

int i;
size_t index;
_index_t *dims = (_index_t*)malloc(sizeof(_index_t)*ndims);
_index_t *subs = (_index_t*)malloc(sizeof(_index_t)*ndims);

_index_t *dims = (_index_t*)malloc(sizeof(_index_t)*ndims);
_index_t *subs = (_index_t*)malloc(sizeof(_index_t)*ndims);

va_list ap;
va_start(ap,ndims);
for(i = 0; i < ndims; ++i) {
Expand All @@ -323,7 +323,7 @@ size_t calc_base_index_dims_subs(int ndims,...)
subs[i] = va_arg(ap, _index_t) - 1;
}
va_end(ap);

index = 0;
for(i = 0; i < ndims; ++i) {
if (subs[i] < 0 || subs[i] >= dims[i]) {
Expand All @@ -332,8 +332,8 @@ size_t calc_base_index_dims_subs(int ndims,...)
}
index = (index * dims[i]) + subs[i];
}


return index;
}

Expand Down

0 comments on commit 7b6e7e2

Please sign in to comment.