Skip to content

Commit 5aa828a

Browse files
vermaserentueda
authored andcommitted
Sorted out the stuff with OLDNUMEXTRASYMBOLS_
Had also repercussions for %X in #write. Now it should be sane.
1 parent 068fe56 commit 5aa828a

3 files changed

Lines changed: 28 additions & 24 deletions

File tree

sources/optimize.cc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ LONG get_expression (int exprnr) {
185185
}
186186

187187
/*
188-
#] get_expression :
188+
#] get_expression :
189189
#[ PF_get_expression :
190190
*/
191191
#ifdef WITHMPI
@@ -207,7 +207,7 @@ LONG PF_get_expression (int exprnr) {
207207

208208
#endif
209209
/*
210-
#] PF_get_expression :
210+
#] PF_get_expression :
211211
#[ get_brackets :
212212
*/
213213

@@ -1410,7 +1410,7 @@ inline static void next_MCTS_scheme (PHEAD vector<WORD> *porder, vector<WORD> *p
14101410
}
14111411

14121412
/*
1413-
#] next_MCTS_scheme :
1413+
#] next_MCTS_scheme :
14141414
#[ try_MCTS_scheme :
14151415
*/
14161416

@@ -1431,7 +1431,7 @@ inline static void try_MCTS_scheme (PHEAD const vector<WORD> &scheme, int *pnum_
14311431
}
14321432

14331433
/*
1434-
#] try_MCTS_scheme :
1434+
#] try_MCTS_scheme :
14351435
#[ update_MCTS_scheme :
14361436
*/
14371437

@@ -1464,7 +1464,7 @@ inline static void update_MCTS_scheme (int num_oper, const vector<WORD> &scheme,
14641464
}
14651465

14661466
/*
1467-
#] update_MCTS_scheme :
1467+
#] update_MCTS_scheme :
14681468
*/
14691469

14701470
void find_Horner_MCTS_expand_tree () {
@@ -1655,7 +1655,7 @@ void PF_find_Horner_MCTS_expand_tree_slave () {
16551655

16561656
#endif
16571657
/*
1658-
#] PF_find_Horner_MCTS_expand_tree :
1658+
#] PF_find_Horner_MCTS_expand_tree :
16591659
#[ find_Horner_MCTS :
16601660
*/
16611661

@@ -3430,9 +3430,9 @@ vector<WORD> recycle_variables (const vector<WORD> &all_instr) {
34303430
}
34313431

34323432
// put the number of variables used in a preprocessor variable
3433-
UBYTE numbuf[24];
3434-
NumCopy(numvar,numbuf);
3435-
PutPreVar(AM.oldnumextrasymbols,numbuf,0,1);
3433+
// UBYTE numbuf[24];
3434+
// NumCopy(numvar,numbuf);
3435+
// PutPreVar(AM.oldnumextrasymbols,numbuf,0,1);
34363436

34373437
// generate new instructions with the renumbering
34383438
vector<WORD> newinstr;
@@ -3692,7 +3692,7 @@ void PF_optimize_expression_given_Horner_slave () {
36923692

36933693
#endif
36943694
/*
3695-
#] PF_optimize_expression_given_Horner :
3695+
#] PF_optimize_expression_given_Horner :
36963696
#[ generate_output :
36973697
*/
36983698

@@ -4312,6 +4312,7 @@ int ClearOptimize()
43124312
*w = SetExprCases(DROP,1,*w);
43134313
if ( *w < 0 ) error = 1;
43144314
}
4315+
PutPreVar(AM.oldnumextrasymbols,(UBYTE *)("0"),0,0);
43154316
return(error);
43164317
}
43174318

sources/pre.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5837,7 +5837,16 @@ nodollar: MesPrint("@$-variable expected in #write instruction");
58375837
else if ( *fstring == 'X' ) {
58385838
fstring++;
58395839
if ( cbuf[AM.sbufnum].numrhs > 0 ) {
5840-
PrintSubtermList(1,cbuf[AM.sbufnum].numrhs);
5840+
/*
5841+
This should be only to the value of AM.oldnumextrasymbols
5842+
*/
5843+
UBYTE *s = GetPreVar(AM.oldnumextrasymbols,0);
5844+
WORD x = 0;
5845+
while ( *s >= '0' && *s <= '9' ) x = 10*x + *s++ - '0';
5846+
if ( x > 0 )
5847+
PrintSubtermList(1,x);
5848+
else
5849+
PrintSubtermList(1,cbuf[AM.sbufnum].numrhs);
58415850
}
58425851
}
58435852
else if ( *fstring == 'O' ) {
@@ -5847,14 +5856,14 @@ nodollar: MesPrint("@$-variable expected in #write instruction");
58475856
/*
58485857
First test whether there is an optimization buffer
58495858
*/
5850-
if ( AO.OptimizeResult.code == NULL ) {
5859+
if ( AO.OptimizeResult.code == NULL && AO.OptimizationLevel != 0 ) {
58515860
MesPrint("@In #write instruction: no optimization results available!");
58525861
return(-1);
58535862
}
58545863
num = to - Out;
58555864
WriteString(wtype,Out,num);
58565865
to = Out;
5857-
{
5866+
if ( AO.OptimizationLevel != 0 ) {
58585867
WORD oldoutskip = AO.OutSkip;
58595868
AO.OutSkip = number;
58605869
optimize_print_code(0);
@@ -6256,6 +6265,7 @@ int DoOptimize(UBYTE *s)
62566265
int firstterm;
62576266
WORD *term = AT.WorkPointer;
62586267
ClearOptimize();
6268+
if ( AO.OptimizationLevel == 0 ) return(0);
62596269
switch ( e->status ) {
62606270
case LOCALEXPRESSION:
62616271
case GLOBALEXPRESSION:
@@ -6277,6 +6287,8 @@ int DoOptimize(UBYTE *s)
62776287
}
62786288
for ( i = 0; i < NumExpressions; i++ ) {
62796289
if ( i == numexpr ) {
6290+
PutPreVar(AM.oldnumextrasymbols,
6291+
GetPreVar((UBYTE *)"EXTRASYMBOLS_",0),0,1);
62806292
Optimize(numexpr, 0);
62816293
AO.OptimizeResult.nameofexpr = strDup1(exprname,"optimize expression name");
62826294
continue;

sources/sch.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,7 @@ WORD WriteSubTerm(WORD *sterm, WORD first)
16711671
}
16721672

16731673
/*
1674-
#] WriteSubTerm :
1674+
#] WriteSubTerm :
16751675
#[ WriteInnerTerm : WORD WriteInnerTerm(term,first)
16761676
16771677
Writes the contents of term to the output.
@@ -2217,9 +2217,7 @@ WORD WriteAll()
22172217
continue;
22182218
}
22192219
e->printflag = 0;
2220-
/* Needed? (TU 27 Jul 2013)
22212220
PutPreVar(AM.oldnumextrasymbols, GetPreVar((UBYTE *)"EXTRASYMBOLS_", 0), 0, 1);
2222-
*/
22232221
if ( AO.OptimizationLevel > 0 ) {
22242222
if ( Optimize(0, 1) ) return(-1);
22252223
}
@@ -2484,16 +2482,9 @@ WORD WriteOne(UBYTE *name, int alreadyinline, int nosemi)
24842482
MesPrint("@ReadError in expression %s",name);
24852483
goto AboWrite;
24862484
}
2485+
/*
24872486
PutPreVar(AM.oldnumextrasymbols,
24882487
GetPreVar((UBYTE *)"EXTRASYMBOLS_",0),0,1);
2489-
/*
2490-
if ( AC.OutputMode == VORTRANMODE ) {
2491-
AO.OutSkip = 6;
2492-
if ( Optimize(AO.termbuf[3], 1) ) goto AboWrite;
2493-
AO.OutSkip = 3;
2494-
FiniLine();
2495-
}
2496-
else
24972488
*/
24982489
/*
24992490
* Currently WriteOne() is called only from writeToChannel() with setting

0 commit comments

Comments
 (0)