@@ -369,7 +369,7 @@ def implemented_instructions(archdef)
369369
370370 return @implemented_instructions unless @implemented_instructions . nil?
371371
372- @implemented_instructions = archdef . implemented_instructions . select do |inst |
372+ @implemented_instructions = archdef . implementesd_instructions . select do |inst |
373373 inst . defined_by? ( self )
374374 end
375375 end
@@ -422,15 +422,24 @@ def satisfying_versions(archdef)
422422 # @param extension_version [ExtensionVersion] A specific extension version
423423 # @return [Boolean] whether or not the extension_version meets this requirement
424424 # @overload
425+ # @param extension_requirement [ExtensionRequirement] A range of extension versions
426+ # @return [Boolean] whether or not extension_requirement is satisfied by this requirement
427+ # @overload
425428 # @param extension_name [#to_s] An extension name
426429 # @param extension_name [#to_s] An extension version
427430 # @return [Boolean] whether or not the extension_version meets this requirement
428431 def satisfied_by? ( *args )
429432 if args . size == 1
430- raise ArgumentError , "Single argument must be an ExtensionVersion" unless args [ 0 ] . is_a? ( ExtensionVersion )
431-
432- args [ 0 ] . name == @name &&
433- @requirement . satisfied_by? ( Gem ::Version . new ( args [ 0 ] . version ) )
433+ if args [ 0 ] . is_a? ( ExtensionVersion )
434+ args [ 0 ] . name == @name &&
435+ @requirement . satisfied_by? ( Gem ::Version . new ( args [ 0 ] . version ) )
436+ elsif args [ 0 ] . is_a? ( ExtensionRequirement )
437+ satisfying_versions . all? do |ext_ver |
438+ satified_by? ( ext_ver )
439+ end
440+ else
441+ raise ArgumentError , "Single argument must be an ExtensionVersion or ExtensionRquirement"
442+ end
434443 elsif args . size == 2
435444 raise ArgumentError , "First parameter must be an extension name" unless args [ 0 ] . respond_to? ( :to_s )
436445 raise ArgumentError , "First parameter must be an extension version" unless args [ 1 ] . respond_to? ( :to_s )
@@ -442,6 +451,17 @@ def satisfied_by?(*args)
442451 end
443452 end
444453
454+ # @return [Array<Csr>] List of CSRs defined by any extension satisfying this requirement
455+ def csrs ( arch_def )
456+ return @csrs unless @csrs . nil?
457+
458+ @csrs = arch_def . csrs . select do |csr |
459+ satisfying_versions ( arch_def ) . any? do |ext_ver |
460+ csr . defined_by? ( ext_ver )
461+ end
462+ end
463+ end
464+
445465 # sorts by name
446466 def <=>( other )
447467 raise ArgumentError , "ExtensionRequirements are only comparable to other extension requirements" unless other . is_a? ( ExtensionRequirement )
0 commit comments