Skip to content

Commit

Permalink
Use goto instead of longjmp when a pattern in a case fails to match. …
Browse files Browse the repository at this point in the history
…We know the place we want to go to, so just do it :)

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18006 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 4, 2013
1 parent e370734 commit 608f327
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Compiler/Template/CodegenC.tpl
Expand Up @@ -8831,7 +8831,7 @@ case exp as MATCHEXPRESSION(__) then
error(sourceInfo(), 'Unknown switch: <%printExpStr(exp)%>')
else tempDecl('mmc_switch_type', &varDeclsInner)
let done = tempDecl('int', &varDeclsInner)
let onPatternFail = match exp.matchType case MATCHCONTINUE(__) then "MMC_THROW_INTERNAL()" case MATCH(__) then "break"
let onPatternFail = 'goto <%prefix%>_end'
let &preExp +=
<<
<%endModelicaLine()%>
Expand All @@ -8852,7 +8852,9 @@ case exp as MATCHEXPRESSION(__) then
<%daeExpMatchCases(exp.cases,tupleAssignExps,exp.matchType,ix,res,startIndexOutputs,prefix,startIndexInputs,exp.inputs,onPatternFail,done,context,&varDecls)%>
}

<% match exp.matchType case MATCHCONTINUE(__) then "MMC_CATCH_INTERNAL(mmc_jumper)" %>
goto <%prefix%>_end;
<%prefix%>_end: ;
<% match exp.matchType case MATCHCONTINUE(__) then "MMC_CATCH_INTERNAL(mmc_jumper);" %>
}

if (!<%done%>) MMC_THROW_INTERNAL();
Expand Down

0 comments on commit 608f327

Please sign in to comment.