Skip to content

Commit 2a0652e

Browse files
author
Jens Frenkel
committed
- use error function to report errors in CodegenC.tpl
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13671 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent ef848b5 commit 2a0652e

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

Compiler/BackEnd/SimCodeUtil.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4362,7 +4362,7 @@ algorithm
43624362
then
43634363
(SimCode.SES_RESIDUAL(uniqueEqIndex,res_exp,source) :: eqSystemsRest,uniqueEqIndex+1,tempvars);
43644364

4365-
// An array equation
4365+
// An array equation
43664366
case (BackendDAE.ARRAY_EQUATION(dimSize=ds,left=e1, right=e2, source=source) :: rest,_,_)
43674367
equation
43684368
ty = Expression.typeof(e1);

Compiler/Template/CodegenC.tpl

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,7 @@ template timeEventTpl(Integer index1, Exp relation, Text &varDecls /*BUFP*/)
771771
data->simulationInfo.rawSampleExps[i++].zc_index = <%index1%>;
772772
>>
773773
else
774-
<<
775-
/* UNKNOWN ZERO CROSSING for <%index1%> */
776-
>>
774+
error(sourceInfo(), ' UNKNOWN ZERO CROSSING for <%index1%>')
777775
end timeEventTpl;
778776

779777
template functionSampleEquations(list<SimEqSystem> sampleEqns)
@@ -1390,9 +1388,7 @@ case (exp1 as LUNARY(__)) then
13901388
case CALL(path=IDENT(name="sample"), expLst={start, interval}) then
13911389
<< >>
13921390
else
1393-
<<
1394-
// UNKNOWN ZERO CROSSING for <%index1%>
1395-
>>
1391+
error(sourceInfo(), ' UNKNOWN ZERO CROSSING for <%index1%>')
13961392
end zeroCrossingTpl;
13971393

13981394
template functionCheckForDiscreteChanges(list<ComponentRef> discreteModelVars) "template functionCheckForDiscreteChanges
@@ -3973,7 +3969,7 @@ case RECORD_CONSTRUCTOR(__) then
39733969
match var
39743970
case VARIABLE(__) then contextCref(name,contextFunction)
39753971
case FUNCTION_PTR(__) then name
3976-
else error(sourceInfo(),"Unknown variable")
3972+
else error(sourceInfo(),"boxRecordConstructor:Unknown variable")
39773973
;separator=", ")
39783974
let funArgCount = incrementInt(listLength(funArgs), 1)
39793975
<<
@@ -4229,7 +4225,9 @@ case var as VARIABLE(parallelism = PARGLOBAL(__)) then
42294225
case var as VARIABLE(parallelism = PARLOCAL(__)) then
42304226
let &varDecls += '#PARLOCAL variable type should not be allowed here. FIXME!!<%\n%>' ""
42314227

4232-
else let &varDecls += '#error Unknown parallel variable type<%\n%>' ""
4228+
else
4229+
let &varDecls += '#error Unknown parallel variable type<%\n%>'
4230+
error(sourceInfo(), 'parVarInit:error Unknown parallel variable type')
42334231
end parVarInit;
42344232

42354233
template varInitParallel(Variable var, String outStruct, Integer i, Text &varDecls /*BUFP*/, Text &varInits /*BUFP*/, Text &varFrees /*BUFP*/)
@@ -4260,7 +4258,9 @@ case var as FUNCTION_PTR(__) then
42604258
let &ignore = buffer ""
42614259
let &varDecls += functionArg(var,&ignore)
42624260
""
4263-
else let &varDecls += '#error Unknown local variable type<%\n%>' ""
4261+
else
4262+
let &varDecls += '#error Unknown local variable type<%\n%>'
4263+
error(sourceInfo(), 'varInitParallel:error Unknown local variable type')
42644264
end varInitParallel;
42654265

42664266

@@ -4802,7 +4802,7 @@ template tempSizeVarName(ComponentRef c, DAE.Exp indices)
48024802
::=
48034803
match indices
48044804
case ICONST(__) then '<%contextCref(c,contextFunction)%>_size_<%integer%>'
4805-
else "tempSizeVarName:UNHANDLED_EXPRESSION"
4805+
else error(sourceInfo(), 'tempSizeVarName:UNHANDLED_EXPRESSION')
48064806
end tempSizeVarName;
48074807

48084808
template funStatement(Statement stmt, Text &varDecls /*BUFP*/)
@@ -4814,7 +4814,7 @@ template funStatement(Statement stmt, Text &varDecls /*BUFP*/)
48144814
algStatement(stmt, contextFunction, &varDecls /*BUFD*/)
48154815
;separator="\n")
48164816
else
4817-
"NOT IMPLEMENTED FUN STATEMENT"
4817+
error(sourceInfo(), 'funStatement:NOT IMPLEMENTED FUN STATEMENT')
48184818
end funStatement;
48194819

48204820
template parModelicafunStatement(Statement stmt, Text &varDecls)
@@ -4827,7 +4827,7 @@ template parModelicafunStatement(Statement stmt, Text &varDecls)
48274827
algStatement(stmt, contextParallelFunction, &varDecls)
48284828
;separator="\n")
48294829
else
4830-
"NOT IMPLEMENTED FUN STATEMENT"
4830+
error(sourceInfo(), 'parModelicafunStatement:NOT IMPLEMENTED FUN STATEMENT')
48314831
end parModelicafunStatement;
48324832

48334833
template extractParFors(Statement stmt, Text &varDecls)
@@ -4841,7 +4841,7 @@ template extractParFors(Statement stmt, Text &varDecls)
48414841
extractParFors_impl(stmt, contextParallelFunction, &varDecls)
48424842
;separator="\n")
48434843
else
4844-
"NOT IMPLEMENTED FUN STATEMENT"
4844+
error(sourceInfo(), 'extractParFors:NOT IMPLEMENTED FUN STATEMENT')
48454845
end extractParFors;
48464846

48474847

@@ -5767,7 +5767,7 @@ template scalarLhsCref(Exp ecr, Context context, Text &preExp, Text &varDecls)
57675767
case ecr as CREF(componentRef=WILD(__)) then
57685768
''
57695769
else
5770-
"ONLY_IDENT_OR_QUAL_CREF_SUPPORTED_SLHS"
5770+
error(sourceInfo(), 'scalarLhsCref:ONLY_IDENT_OR_QUAL_CREF_SUPPORTED_SLHS')
57715771
end scalarLhsCref;
57725772

57735773
template rhsCref(ComponentRef cr, Type ty)
@@ -5776,7 +5776,7 @@ template rhsCref(ComponentRef cr, Type ty)
57765776
match cr
57775777
case CREF_IDENT(__) then '<%rhsCrefType(ty)%><%ident%>'
57785778
case CREF_QUAL(__) then '<%rhsCrefType(ty)%><%ident%>.<%rhsCref(componentRef,ty)%>'
5779-
else "rhsCref:ERROR"
5779+
else error(sourceInfo(), 'rhsCref:ERROR')
57805780
end rhsCref;
57815781

57825782

@@ -6301,7 +6301,7 @@ case BINARY(__) then
63016301
case POW_SCALAR_ARRAY(__) then 'daeExpBinary:ERR for POW_SCALAR_ARRAY'
63026302
case POW_ARR(__) then 'daeExpBinary:ERR for POW_ARR'
63036303
case POW_ARR2(__) then 'daeExpBinary:ERR for POW_ARR2'
6304-
else "daeExpBinary:ERR"
6304+
else error(sourceInfo(), 'daeExpBinary:ERR')
63056305
end daeExpBinary;
63066306

63076307

@@ -6399,8 +6399,7 @@ case rel as RELATION(__) then
63996399
case NEQUAL(ty = T_REAL(__)) then '(<%e1%> != <%e2%>)'
64006400
case NEQUAL(ty = T_ENUMERATION(__)) then '(<%e1%> != <%e2%>)'
64016401

6402-
else "daeExpRelation:ERR"
6403-
6402+
else error(sourceInfo(), 'daeExpRelation:ERR')
64046403
end daeExpRelation;
64056404

64066405

@@ -7740,7 +7739,7 @@ template mmcTypeShort(DAE.Type type)
77407739
case T_ARRAY(__) then "array"
77417740
case T_METATYPE(__) case T_METABOXED(__) then "metatype"
77427741
case T_FUNCTION_REFERENCE_VAR(__) then "fnptr"
7743-
else "mmcTypeShort:ERROR"
7742+
else error(sourceInfo(), 'mmcTypeShort:ERROR')
77447743
end mmcTypeShort;
77457744

77467745

@@ -7904,7 +7903,7 @@ template expTypeFromOpFlag(Operator op, Integer flag)
79047903
case o as OR(__)
79057904
case o as NOT(__) then
79067905
match flag case 1 then "boolean" else "modelica_boolean"
7907-
else "expTypeFromOpFlag:ERROR"
7906+
else error(sourceInfo(), 'expTypeFromOpFlag:ERROR')
79087907
end expTypeFromOpFlag;
79097908

79107909
template dimension(Dimension d)
@@ -7913,7 +7912,7 @@ template dimension(Dimension d)
79137912
case DAE.DIM_INTEGER(__) then integer
79147913
case DAE.DIM_ENUM(__) then size
79157914
case DAE.DIM_UNKNOWN(__) then error(sourceInfo(),"Unknown dimensions may not be part of generated code. This is most likely an error on the part of OpenModelica. Please submit a detailed bug-report.")
7916-
else "INVALID_DIMENSION"
7915+
else error(sourceInfo(), 'dimension: INVALID_DIMENSION')
79177916
end dimension;
79187917

79197918
template algStmtAssignPattern(DAE.Statement stmt, Context context, Text &varDecls)
@@ -7951,7 +7950,7 @@ template patternMatch(Pattern pat, Text rhs, Text onPatternFail, Text &varDecls,
79517950
case c as BCONST(__) then 'if (<%if c.bool then 1 else 0%> != <%urhs%>) <%onPatternFail%>;<%\n%>'
79527951
case c as LIST(valList = {}) then 'if (!listEmpty(<%urhs%>)) <%onPatternFail%>;<%\n%>'
79537952
case c as META_OPTION(exp = NONE()) then 'if (!optionNone(<%urhs%>)) <%onPatternFail%>;<%\n%>'
7954-
else 'UNKNOWN_CONSTANT_PATTERN'
7953+
else error(sourceInfo(), 'UNKNOWN_CONSTANT_PATTERN')
79557954
%>>>
79567955
case p as PAT_SOME(__) then
79577956
let tvar = tempDecl("modelica_metatype", &varDecls)
@@ -8011,7 +8010,7 @@ template patternMatch(Pattern pat, Text rhs, Text onPatternFail, Text &varDecls,
80118010
<<<%&unboxBuf%>
80128011
<%patternMatch(p.pat,rhs,onPatternFail,&varDecls,&assignments)%>
80138012
>>
8014-
else 'UNKNOWN_PATTERN /* rhs: <%rhs%> */<%\n%>'
8013+
else error(sourceInfo(), 'UNKNOWN_PATTERN /* rhs: <%rhs%> */<%\n%>')
80158014
end patternMatch;
80168015

80178016
template infoArgs(Info info)
@@ -8366,7 +8365,7 @@ template ScalarVariableType(String unit, String displayUnit, Option<DAE.Exp> min
83668365
case T_BOOL(__) then '<Boolean <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
83678366
case T_STRING(__) then '<String <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
83688367
case T_ENUMERATION(__) then '<Integer <%ScalarVariableTypeStartAttribute(initialValue, type_)%> <%ScalarVariableTypeFixedAttribute(isFixed)%> <%ScalarVariableTypeUnitAttribute(unit)%> <%ScalarVariableTypeDisplayUnitAttribute(displayUnit)%> />'
8369-
else 'UNKOWN_TYPE'
8368+
else error(sourceInfo(), 'ScalarVariableType: UNKOWN_TYPE')
83708369
end ScalarVariableType;
83718370

83728371
template ScalarVariableTypeStartAttribute(Option<DAE.Exp> initialValue, DAE.Type type_)
@@ -8381,7 +8380,7 @@ match initialValue
83818380
case T_REAL(__) then 'useStart="false" start="0.0"'
83828381
case T_BOOL(__) then 'useStart="false" start="false"'
83838382
case T_STRING(__) then 'useStart="false" start=""'
8384-
else 'UNKOWN_TYPE'
8383+
else error(sourceInfo(), 'ScalarVariableTypeStartAttribute: UNKOWN_TYPE')
83858384
end ScalarVariableTypeStartAttribute;
83868385

83878386
template ScalarVariableTypeFixedAttribute(Boolean isFixed)

0 commit comments

Comments
 (0)