Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor LLVM::Attribute#each_kind to use Enum#each #13234

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
end
end

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