Skip to content

Commit

Permalink
Refactor LLVM::Attribute#each_kind to use Enum#each
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Mar 27, 2023
1 parent 8a509b6 commit ee33f03
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/llvm/enums.cr
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,10 @@ module LLVM
@@kind_ids = load_llvm_kinds_from_names.as(Hash(Attribute, UInt32))
@@typed_attrs = load_llvm_typed_attributes.as(Array(Attribute))

def each_kind(&block)
return if value == 0
{% for member in @type.constants %}
{% if member.stringify != "All" %}
if includes?({{@type}}::{{member}})
yield @@kind_ids[{{@type}}::{{member}}]
end
{% end %}
{% end %}
def each_kind(& : UInt32 ->)
each do |member|
yield @@kind_ids[member.value]
end
end

private def self.kind_for_name(name : String)
Expand Down

0 comments on commit ee33f03

Please sign in to comment.