| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Translate parse tree to Mojom IR""" | 6 """Translate parse tree to Mojom IR""" |
| 7 | 7 |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 out = attribute[2] | 47 out = attribute[2] |
| 48 return out | 48 return out |
| 49 | 49 |
| 50 | 50 |
| 51 def MapFields(fields): | 51 def MapFields(fields): |
| 52 out = [] | 52 out = [] |
| 53 for field in fields: | 53 for field in fields: |
| 54 if field[0] == 'FIELD': | 54 if field[0] == 'FIELD': |
| 55 out.append({'name': field[2], | 55 out.append({'name': field[2], |
| 56 'kind': MapKind(field[1]), | 56 'kind': MapKind(field[1]), |
| 57 'ordinal': MapOrdinal(field[3])}) | 57 'ordinal': MapOrdinal(field[3]), |
| 58 'default': field[4]}) |
| 58 return out | 59 return out |
| 59 | 60 |
| 60 | 61 |
| 61 def MapParameters(parameters): | 62 def MapParameters(parameters): |
| 62 out = [] | 63 out = [] |
| 63 for parameter in parameters: | 64 for parameter in parameters: |
| 64 if parameter[0] == 'PARAM': | 65 if parameter[0] == 'PARAM': |
| 65 out.append({'name': parameter[2], | 66 out.append({'name': parameter[2], |
| 66 'kind': MapKind(parameter[1]), | 67 'kind': MapKind(parameter[1]), |
| 67 'ordinal': MapOrdinal(parameter[3])}) | 68 'ordinal': MapOrdinal(parameter[3])}) |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 print("usage: %s filename" % (sys.argv[0])) | 156 print("usage: %s filename" % (sys.argv[0])) |
| 156 sys.exit(1) | 157 sys.exit(1) |
| 157 tree = eval(open(sys.argv[1]).read()) | 158 tree = eval(open(sys.argv[1]).read()) |
| 158 name = os.path.splitext(os.path.basename(sys.argv[1]))[0] | 159 name = os.path.splitext(os.path.basename(sys.argv[1]))[0] |
| 159 result = Translate(tree, name) | 160 result = Translate(tree, name) |
| 160 print(result) | 161 print(result) |
| 161 | 162 |
| 162 | 163 |
| 163 if __name__ == '__main__': | 164 if __name__ == '__main__': |
| 164 Main() | 165 Main() |
| OLD | NEW |