Chromium Code Reviews| Index: src/trusted/validator_arm/dgen_core.py |
| =================================================================== |
| --- src/trusted/validator_arm/dgen_core.py (revision 8201) |
| +++ src/trusted/validator_arm/dgen_core.py (working copy) |
| @@ -1,9 +1,8 @@ |
| #!/usr/bin/python |
| # |
| -# Copyright 2009 The Native Client Authors. All rights reserved. |
| -# Use of this source code is governed by a BSD-style license that can |
| -# be found in the LICENSE file. |
| -# Copyright 2009, Google Inc. |
| +# Copyright (c) 2012 The Native Client Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| # |
| """ |
| @@ -228,6 +227,22 @@ |
| parsed.append(BitPattern.parse(col_patterns[i], col[1], col[2])) |
| self.rows.append(Row(parsed, action_string, arch)) |
| + def rows_filtered(self, num_actions): |
| + """Returns rows for building runtime tables. Automatically filters |
| + actions down to the specified number of actions. Typically this |
| + is done to remove unwanted testing data that would minimize the |
| + effect of optimizing the rows of a table. |
| + """ |
| + rows = [] |
| + for r in self.rows: |
| + count = 1 |
| + reduced_actions = [] |
| + for a in r.action.split(): |
|
robertm
2012/04/11 01:28:43
could this be simplified with array slicing, e.g.
Karl
2012/04/16 23:18:10
This code simplified once I removed parsing from t
|
| + if count > num_actions: break; |
| + reduced_actions.append(a) |
| + count += 1 |
| + rows.append(Row(r.patterns, ' '.join(reduced_actions), r.arch)) |
| + return rows |
| class Row(object): |
| """ A row in a Table.""" |