~zorba-coders/zorba/trunk

« back to all changes in this revision

Viewing changes to src/compiler/expression/flwor_expr.cpp

  • Committer: Zorba Build Bot
  • Author(s): markos_za at yahoo
  • Date: 2013-05-04 21:54:40 UTC
  • mfrom: (10900.1.197 markos-scratch)
  • Revision ID: chillery+buildbot@lambda.nu-20130504215440-1486xtg6g7wy522h
Apply count optimization after index matching. Approved: Markos Zaharioudakis

Show diffs side-by-side

added added

removed removed

Lines of Context:
1225
1225
}
1226
1226
 
1227
1227
 
 
1228
 
 
1229
/*******************************************************************************
 
1230
 
 
1231
********************************************************************************/
 
1232
bool flwor_expr::is_single_for(csize& pos) const
 
1233
{
 
1234
  csize numClauses = num_clauses();
 
1235
 
 
1236
  csize numFors = 0;
 
1237
  bool discardable = true;
 
1238
 
 
1239
  for (csize i = 0; i < numClauses; ++i)
 
1240
  {
 
1241
    flwor_clause* c = theClauses[i];
 
1242
 
 
1243
    switch (c->get_kind())
 
1244
    {
 
1245
    case flwor_clause::for_clause:
 
1246
    {
 
1247
      if (numFors > 0)
 
1248
        return false;
 
1249
 
 
1250
      ++numFors;
 
1251
      pos = i;
 
1252
      break;
 
1253
    }
 
1254
    case flwor_clause::let_clause:
 
1255
    {
 
1256
      let_clause* lc = static_cast<let_clause*>(c);
 
1257
      if (lc->get_expr()->isNonDiscardable())
 
1258
      {
 
1259
        if (numFors > 0)
 
1260
          return false;
 
1261
 
 
1262
        discardable = false;
 
1263
        break;
 
1264
      }
 
1265
    }
 
1266
    default:
 
1267
      return false;
 
1268
    }
 
1269
  }
 
1270
 
 
1271
  if (numFors ==  1 && discardable)
 
1272
    return true;
 
1273
 
 
1274
  return false;
 
1275
}
 
1276
 
 
1277
 
1228
1278
} // namespace zorba
1229
1279
/* vim:set et sw=2 ts=2: */