OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 # TODO(vtl): "data" is a pretty vague name. Rename it? | 5 # TODO(vtl): "data" is a pretty vague name. Rename it? |
6 | 6 |
7 import copy | 7 import copy |
8 | 8 |
9 import module as mojom | 9 import module as mojom |
10 | 10 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 | 95 |
96 return values.get(name) | 96 return values.get(name) |
97 | 97 |
98 def FixupExpression(module, value, scope, kind): | 98 def FixupExpression(module, value, scope, kind): |
99 """Translates an IDENTIFIER into a built-in value or structured NamedValue | 99 """Translates an IDENTIFIER into a built-in value or structured NamedValue |
100 object.""" | 100 object.""" |
101 if isinstance(value, tuple) and value[0] == 'IDENTIFIER': | 101 if isinstance(value, tuple) and value[0] == 'IDENTIFIER': |
102 # Allow user defined values to shadow builtins. | 102 # Allow user defined values to shadow builtins. |
103 result = LookupValue(module.values, value[1], scope, kind) | 103 result = LookupValue(module.values, value[1], scope, kind) |
104 if result: | 104 if result: |
105 if isinstance(result, tuple): | |
106 raise Exception('Unable to resolve expression: %r' % value[1]) | |
viettrungluu
2014/09/05 17:05:30
Does this properly handle, e.g., using constants a
qsr
2014/09/08 09:06:08
Yes, we do have this in our test cases (mojo/publi
| |
105 return result | 107 return result |
106 if IsBuiltinValue(value[1]): | 108 if IsBuiltinValue(value[1]): |
107 return mojom.BuiltinValue(value[1]) | 109 return mojom.BuiltinValue(value[1]) |
108 return value | 110 return value |
109 | 111 |
110 def KindToData(kind): | 112 def KindToData(kind): |
111 return kind.spec | 113 return kind.spec |
112 | 114 |
113 def KindFromData(kinds, data, scope): | 115 def KindFromData(kinds, data, scope): |
114 kind = LookupKind(kinds, data, scope) | 116 kind = LookupKind(kinds, data, scope) |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 | 374 |
373 def OrderedModuleFromData(data): | 375 def OrderedModuleFromData(data): |
374 module = ModuleFromData(data) | 376 module = ModuleFromData(data) |
375 for interface in module.interfaces: | 377 for interface in module.interfaces: |
376 next_ordinal = 0 | 378 next_ordinal = 0 |
377 for method in interface.methods: | 379 for method in interface.methods: |
378 if method.ordinal is None: | 380 if method.ordinal is None: |
379 method.ordinal = next_ordinal | 381 method.ordinal = next_ordinal |
380 next_ordinal = method.ordinal + 1 | 382 next_ordinal = method.ordinal + 1 |
381 return module | 383 return module |
OLD | NEW |