Пример #1
0
    def _analyze_enum(self, enum):
        # Enum can be parsed in one pass
        name = enum['attributes']['name']
        if 'canonicalName' in enum['attributes']:
            canonicalName = enum['attributes']['canonicalName']
        else:
            canonicalName = self.name + '.' + name
        values = []
        for child in enum['children']:
            assert child['name'] == 'EnumValue'
            values.append(child['attributes']['name'])

        new_enum = Enum(name, canonicalName, values)
        new_enum.set_contract(self)
        new_enum.set_offset(enum['src'])
        self._enums[canonicalName] = new_enum
Пример #2
0
    def _analyze_enum(self, enum):
        # Enum can be parsed in one pass
        if self.is_compact_ast:
            name = enum['name']
            canonicalName = enum['canonicalName']
        else:
            name = enum['attributes'][self.get_key()]
            if 'canonicalName' in enum['attributes']:
                canonicalName = enum['attributes']['canonicalName']
            else:
                canonicalName = self.name + '.' + name
        values = []
        for child in enum[self.get_children('members')]:
            assert child[self.get_key()] == 'EnumValue'
            if self.is_compact_ast:
                values.append(child['name'])
            else:
                values.append(child['attributes'][self.get_key()])

        new_enum = Enum(name, canonicalName, values)
        new_enum.set_contract(self)
        new_enum.set_offset(enum['src'], self.slither)
        self._enums[canonicalName] = new_enum
Пример #3
0
    def _analyze_enum(self, enum):
        # Enum can be parsed in one pass
        if self.is_compact_ast:
            name = enum["name"]
            canonicalName = enum["canonicalName"]
        else:
            name = enum["attributes"][self.get_key()]
            if "canonicalName" in enum["attributes"]:
                canonicalName = enum["attributes"]["canonicalName"]
            else:
                canonicalName = self._contract.name + "." + name
        values = []
        for child in enum[self.get_children("members")]:
            assert child[self.get_key()] == "EnumValue"
            if self.is_compact_ast:
                values.append(child["name"])
            else:
                values.append(child["attributes"][self.get_key()])

        new_enum = Enum(name, canonicalName, values)
        new_enum.set_contract(self._contract)
        new_enum.set_offset(enum["src"], self._contract.slither)
        self._contract.enums_as_dict[canonicalName] = new_enum