summaryrefslogtreecommitdiff
path: root/src/reduce.cc
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2015-10-21 13:03:30 -0400
committerAdrian Thurston <thurston@complang.org>2015-10-21 13:03:30 -0400
commit0b175a8ed019785233618b3bb8e3c064e567f2ec (patch)
tree96af4d993e2c2505ec31aa543d796f1cf9538d99 /src/reduce.cc
parent924fbf2224b7e39e68230c568ef4ce3ac57eb569 (diff)
downloadcolm-0b175a8ed019785233618b3bb8e3c064e567f2ec.tar.gz
allow multiple reducers
selection is currently manual using a numberical identifier
Diffstat (limited to 'src/reduce.cc')
-rw-r--r--src/reduce.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/reduce.cc b/src/reduce.cc
index 271560e1..989329ee 100644
--- a/src/reduce.cc
+++ b/src/reduce.cc
@@ -298,14 +298,19 @@ void Compiler::writeCommit()
"\n"
" if ( !( lel->flags & PF_COMMITTED ) ) {\n"
" /* Now can execute the reduction action. */\n"
- " switch ( kid->tree->id ) {\n";
+ " switch ( reducer->current ) {\n";
for ( ReductionVect::Iter r = rootNamespace->reductions; r.lte(); r++ ) {
+ Reduction *reduction = *r;
+
+ *outStream <<
+ " case " << reduction->id << ": { switch ( kid->tree->id ) {\n";
+
/* Populate a vector with the reduce actions. */
Vector<ReduceAction*> actions;
- actions.setAsNew( (*r)->reduceActions.length() );
+ actions.setAsNew( reduction->reduceActions.length() );
long pos = 0;
- for ( ReduceActionList::Iter rdi = (*r)->reduceActions; rdi.lte(); rdi++ )
+ for ( ReduceActionList::Iter rdi = reduction->reduceActions; rdi.lte(); rdi++ )
actions[pos++] = rdi;
/* Sort it by lhs id, then prod num. */
@@ -354,6 +359,9 @@ void Compiler::writeCommit()
" break;\n"
" }\n";
}
+
+ *outStream <<
+ " } break; }\n";
}
*outStream <<