Mercurial > hg > CbC > old > device
changeset 299:3d260008c449
level 2 looks ok.
author | kono |
---|---|
date | Mon, 07 Jun 2004 00:20:46 +0900 |
parents | 4ccacae1d2e6 |
children | 86255dd7f148 |
files | mc-parse.c mc-switch.c mc-switch.h |
diffstat | 3 files changed, 25 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/mc-parse.c Sun Jun 06 23:07:53 2004 +0900 +++ b/mc-parse.c Mon Jun 07 00:20:46 2004 +0900 @@ -1896,7 +1896,7 @@ checkret(); #if CASE_CODE if (control) jmp(blabel); - genswitch(cslist,cslabel,dlabel); + genswitch(cslist,cslabel); #else if(dlabel) def_label(cslabel,dlabel); else fwddef(cslabel);
--- a/mc-switch.c Sun Jun 06 23:07:53 2004 +0900 +++ b/mc-switch.c Mon Jun 07 00:20:46 2004 +0900 @@ -8,7 +8,7 @@ #if CASE_CODE -extern void genswitch(int cslist,int cslabel,int dlabel); +extern void genswitch(int cslist,int cslabel); /* value label pair @@ -218,26 +218,30 @@ */ static void -switch_make_index(int index0,int count,int cslabel,int level) +switch_make_index(int index0,int count,int cslabel,int gmax,int level) { int index=0; int icount=0; int l,min,max; control=1; - while (index0 && count > CASE_INDEX_COUNT) { - l = backdef(); - min = index_min(index0); - index0=switch_make_index_leaf(CASE_INDEX_COUNT,index0,level); - max = index_min(index0)-1; - index = list4(l,index,max,min); - count-=CASE_INDEX_COUNT; - icount++; - } - if (index) { - switch_make_index(reverse0(index),icount,cslabel,level+1); - } else { + if (count <= CASE_INDEX_COUNT) { fwddef(cslabel); switch_make_index_leaf(-1,index0,level); + } else { + while (index0) { + l = backdef(); + min = index_min(index0); + index0=switch_make_index_leaf(CASE_INDEX_COUNT,index0,level); + if (index0) { + max = index_min(index0)-1; + } else { + max = gmax; + } + index = list4(l,index,max,min); + count-=CASE_INDEX_COUNT; + icount++; + } + switch_make_index(reverse0(index),icount,cslabel,gmax,level+1); } if (control&&dlabel) jmp(dlabel); } @@ -268,7 +272,7 @@ */ static void -switch_index(int merge,int chunks,int cslabel,int dlabel,int gmax) +switch_index(int merge,int chunks,int cslabel,int gmax) { int m,l,max,min; int chnkcnt = 0; @@ -294,7 +298,7 @@ // check lower bound // switch_index_jmp(index,dlabel?dlabel:blabel); // nonsense because no control here. - switch_make_index(index,icount,cslabel,0); + switch_make_index(index,icount,cslabel,gmax,0); } else { fwddef(cslabel); switch_leaf(-1,merge,chunks); @@ -306,7 +310,7 @@ void -genswitch(int cslist,int cslabel,int dlabel) +genswitch(int cslist,int cslabel) { int chunks,merge,gmax; int i,j; @@ -339,7 +343,8 @@ /* make index branch or table jump */ gmax = chunk_max(chunks); chunks = reverse0(chunks); - switch_index(merge,chunks,cslabel,dlabel,gmax); + if (!dlabel) dlabel = blabel; + switch_index(merge,chunks,cslabel,gmax); } #endif