| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Translates parse tree to Mojom IR.""" | 5 """Translates parse tree to Mojom IR.""" |
| 6 | 6 |
| 7 | 7 |
| 8 from . import ast | 8 from . import ast |
| 9 | 9 |
| 10 | 10 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 assert isinstance(tree, ast.Mojom) | 146 assert isinstance(tree, ast.Mojom) |
| 147 self.mojom['name'] = name | 147 self.mojom['name'] = name |
| 148 self.mojom['namespace'] = tree.module.name[1] if tree.module else '' | 148 self.mojom['namespace'] = tree.module.name[1] if tree.module else '' |
| 149 self.mojom['imports'] = \ | 149 self.mojom['imports'] = \ |
| 150 [{'filename': imp.import_filename} for imp in tree.import_list] | 150 [{'filename': imp.import_filename} for imp in tree.import_list] |
| 151 self.mojom['attributes'] = \ | 151 self.mojom['attributes'] = \ |
| 152 _AttributeListToDict(tree.module.attribute_list) if tree.module else {} | 152 _AttributeListToDict(tree.module.attribute_list) if tree.module else {} |
| 153 self.mojom['structs'] = \ | 153 self.mojom['structs'] = \ |
| 154 _MapTreeForType(StructToDict, tree.definition_list, ast.Struct) | 154 _MapTreeForType(StructToDict, tree.definition_list, ast.Struct) |
| 155 self.mojom['unions'] = \ | 155 self.mojom['union'] = \ |
| 156 _MapTreeForType(UnionToDict, tree.definition_list, ast.Union) | 156 _MapTreeForType(UnionToDict, tree.definition_list, ast.Union) |
| 157 self.mojom['interfaces'] = \ | 157 self.mojom['interfaces'] = \ |
| 158 _MapTreeForType(InterfaceToDict, tree.definition_list, ast.Interface) | 158 _MapTreeForType(InterfaceToDict, tree.definition_list, ast.Interface) |
| 159 self.mojom['enums'] = \ | 159 self.mojom['enums'] = \ |
| 160 _MapTreeForType(_EnumToDict, tree.definition_list, ast.Enum) | 160 _MapTreeForType(_EnumToDict, tree.definition_list, ast.Enum) |
| 161 self.mojom['constants'] = \ | 161 self.mojom['constants'] = \ |
| 162 _MapTreeForType(_ConstToDict, tree.definition_list, ast.Const) | 162 _MapTreeForType(_ConstToDict, tree.definition_list, ast.Const) |
| 163 return self.mojom | 163 return self.mojom |
| 164 | 164 |
| 165 | 165 |
| 166 def Translate(tree, name): | 166 def Translate(tree, name): |
| 167 return _MojomBuilder().Build(tree, name) | 167 return _MojomBuilder().Build(tree, name) |
| OLD | NEW |