Commit a85fab10 authored by Hitoshi Yoshida's avatar Hitoshi Yoshida Committed by Commit Bot

IDL compiler: Implement interface inheritances

In processing interface inheritance, we make a copy of unforgeable
member defined in recursively inherited interfaces.


Bug: 839389
Change-Id: I7ad45a90c0540f75aed39982f0831424a3459181
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1728511
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Reviewed-by: default avatarYuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683499}
parent 73388a7a
......@@ -72,6 +72,8 @@ class IdlCompiler(object):
self._merge_partial_dictionaries()
# Merge mixins.
self._merge_interface_mixins()
# Process inheritances.
self._process_interface_inheritances()
# Updates on IRs are finished. Create API objects.
self._create_public_objects()
......@@ -151,6 +153,34 @@ class IdlCompiler(object):
])
self._ir_map.add(new_interface)
def _process_interface_inheritances(self):
def is_own_member(member):
return 'Unfogeable' in member.extended_attributes
def create_inheritance_stack(obj, table):
if obj.inherited is None:
return [obj]
return [obj] + create_inheritance_stack(
table.get(obj.inherited.identifier, None), table)
old_interfaces = self._ir_map.find_by_kind(
IdentifierIRMap.IR.Kind.INTERFACE)
self._ir_map.move_to_new_phase()
for old_interface in old_interfaces.itervalues():
new_interface = old_interface.make_copy()
inheritance_stack = create_inheritance_stack(
old_interface, old_interfaces)
for interface in inheritance_stack[1:]:
new_interface.attributes.extend([
attribute.make_copy() for attribute in interface.attributes
if is_own_member(attribute)
])
new_interface.operations.extend([
operation.make_copy() for operation in interface.operations
if is_own_member(operation)
])
self._ir_map.add(new_interface)
def _create_public_objects(self):
"""Creates public representations of compiled objects."""
dictionary_irs = self._ir_map.find_by_kind(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment