Commit c01eb941 authored by Yuki Shiino's avatar Yuki Shiino Committed by Commit Bot

IDL compiler: Propagate extended attributes to OverloadGroup

Bug: 839389
Change-Id: Ibf3beee17555dbed4a4e3baa64eb7c402a5d5cc2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1973890Reviewed-by: default avatarHitoshi Yoshida <peria@chromium.org>
Commit-Queue: Yuki Shiino <yukishiino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#726267}
parent 03fb55f1
......@@ -57,22 +57,25 @@ class Constructor(FunctionLike, WithExtendedAttributes, WithCodeGeneratorInfo,
WithDebugInfo.__init__(self, ir)
class ConstructorGroup(OverloadGroup, WithCodeGeneratorInfo, WithExposure,
WithOwner, WithComponent, WithDebugInfo):
class ConstructorGroup(OverloadGroup, WithExtendedAttributes,
WithCodeGeneratorInfo, WithExposure, WithOwner,
WithComponent, WithDebugInfo):
"""
Represents a group of constructors for an interface.
Represents a group of constructors of an interface.
The number of constructors in this group may be 1 or 2+. In the latter
case, the constructors are overloaded.
"""
class IR(OverloadGroup.IR, WithCodeGeneratorInfo, WithExposure,
WithDebugInfo):
class IR(OverloadGroup.IR, WithExtendedAttributes, WithCodeGeneratorInfo,
WithExposure, WithDebugInfo):
def __init__(self,
constructors,
extended_attributes=None,
code_generator_info=None,
debug_info=None):
OverloadGroup.IR.__init__(self, constructors)
WithExtendedAttributes.__init__(self, extended_attributes)
WithCodeGeneratorInfo.__init__(self, code_generator_info)
WithExposure.__init__(self)
WithDebugInfo.__init__(self, debug_info)
......@@ -92,6 +95,7 @@ class ConstructorGroup(OverloadGroup, WithCodeGeneratorInfo, WithExposure,
ir = make_copy(ir)
OverloadGroup.__init__(self, functions=constructors)
WithExtendedAttributes.__init__(self, ir, readonly=True)
WithCodeGeneratorInfo.__init__(self, ir, readonly=True)
WithExposure.__init__(self, ir, readonly=True)
WithOwner.__init__(self, owner)
......
......@@ -13,6 +13,7 @@ from .database import Database
from .database import DatabaseBody
from .dictionary import Dictionary
from .enumeration import Enumeration
from .extended_attribute import ExtendedAttribute
from .idl_type import IdlTypeFactory
from .interface import Interface
from .ir_map import IRMap
......@@ -90,6 +91,7 @@ class IdlCompiler(object):
# Make groups of overloaded functions including inherited ones.
self._group_overloaded_functions()
self._propagate_extattrs_to_overload_group()
self._calculate_group_exposure()
self._sort_dictionary_members()
......@@ -336,6 +338,30 @@ class IdlCompiler(object):
if identifier
]
def _propagate_extattrs_to_overload_group(self):
ANY_OF = ("CrossOrigin", "LenientThis", "NotEnumerable",
"PerWorldBindings", "Unforgeable", "Unscopable")
old_irs = self._ir_map.irs_of_kinds(IRMap.IR.Kind.INTERFACE,
IRMap.IR.Kind.NAMESPACE)
self._ir_map.move_to_new_phase()
for old_ir in old_irs:
new_ir = make_copy(old_ir)
self._ir_map.add(new_ir)
for group in new_ir.constructor_groups + new_ir.operation_groups:
for key in ANY_OF:
if any(key in overload.extended_attributes
for overload in group):
group.extended_attributes.append(
ExtendedAttribute(key=key))
if all((overload.extended_attributes.value_of("Affects") ==
"Nothing") for overload in group):
group.extended_attributes.append(
ExtendedAttribute(key="Affects", values="Nothing"))
def _calculate_group_exposure(self):
old_irs = self._ir_map.irs_of_kinds(IRMap.IR.Kind.INTERFACE,
IRMap.IR.Kind.NAMESPACE)
......
......@@ -69,8 +69,9 @@ class Operation(FunctionLike, WithExtendedAttributes, WithCodeGeneratorInfo,
return self._is_stringifier
class OperationGroup(OverloadGroup, WithCodeGeneratorInfo, WithExposure,
WithOwner, WithComponent, WithDebugInfo):
class OperationGroup(OverloadGroup, WithExtendedAttributes,
WithCodeGeneratorInfo, WithExposure, WithOwner,
WithComponent, WithDebugInfo):
"""
Represents a group of operations with the same identifier.
......@@ -78,13 +79,15 @@ class OperationGroup(OverloadGroup, WithCodeGeneratorInfo, WithExposure,
the operations are overloaded.
"""
class IR(OverloadGroup.IR, WithCodeGeneratorInfo, WithExposure,
WithDebugInfo):
class IR(OverloadGroup.IR, WithExtendedAttributes, WithCodeGeneratorInfo,
WithExposure, WithDebugInfo):
def __init__(self,
operations,
extended_attributes=None,
code_generator_info=None,
debug_info=None):
OverloadGroup.IR.__init__(self, operations)
WithExtendedAttributes.__init__(self, extended_attributes)
WithCodeGeneratorInfo.__init__(self, code_generator_info)
WithExposure.__init__(self)
WithDebugInfo.__init__(self, debug_info)
......@@ -103,6 +106,7 @@ class OperationGroup(OverloadGroup, WithCodeGeneratorInfo, WithExposure,
ir = make_copy(ir)
OverloadGroup.__init__(self, functions=operations)
WithExtendedAttributes.__init__(self, ir, readonly=True)
WithCodeGeneratorInfo.__init__(self, ir, readonly=True)
WithExposure.__init__(self, ir, readonly=True)
WithOwner.__init__(self, owner)
......
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