Class: Udb::ExtensionVersion
- Inherits:
-
Object
- Object
- Udb::ExtensionVersion
- Extended by:
- T::Sig
- Includes:
- Comparable
- Defined in:
- lib/udb/obj/extension.rb,
lib/udb/condition.rb
Overview
A specific version of an extension
Defined Under Namespace
Classes: MemomizedState
Instance Attribute Summary collapse
-
#arch ⇒ Object
readonly
Returns the value of attribute arch.
-
#ext ⇒ Object
readonly
Returns the value of attribute ext.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version_spec ⇒ Object
readonly
Returns the value of attribute version_spec.
-
#version_str ⇒ Object
readonly
Returns the value of attribute version_str.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #all_csrs_that_must_be_implemented ⇒ Object
- #all_instructions_that_must_be_implemented ⇒ Object
- #breaking? ⇒ Boolean
- #canonical_version ⇒ Object
- #changes ⇒ Object
- #compatible?(other) ⇒ Boolean
- #compatible_versions ⇒ Object
- #condition_hash ⇒ Object
- #conditional_extension_requirements(expand:) ⇒ Object
- #contributors ⇒ Object
- #csrs ⇒ Object
- #defining_extension_requirements ⇒ Object
- #directly_defined_instructions ⇒ Object
- #directly_defined_instructions_set ⇒ Object
- #eql?(other) ⇒ Boolean
- #exception_codes ⇒ Object
- #ext_conflicts(expand:) ⇒ Object
- #ext_requirements(expand:) ⇒ Object
- #hash ⇒ Object
- #implied_csrs ⇒ Object
- #implied_instructions ⇒ Object
- #implied_instructions_set ⇒ Object
- #in_scope_csrs(xlens) ⇒ Object
- #in_scope_instructions(xlens) ⇒ Object
-
#initialize(name, version_spec, arch, fail_if_version_does_not_exist: false) ⇒ ExtensionVersion
constructor
A new instance of ExtensionVersion.
- #inspect ⇒ Object private
- #interrupt_codes ⇒ Object
- #params ⇒ Object
- #ratification_date ⇒ Object
- #release_date ⇒ Object
- #requirements_condition ⇒ Object
- #state ⇒ Object
- #to_condition ⇒ Object
- #to_condition_exclusive ⇒ Object
- #to_ext_req ⇒ Object
- #to_h ⇒ Object
- #to_rvi_s ⇒ Object
- #to_s ⇒ Object
- #to_term ⇒ Object
- #unconditional_extension_conflicts(expand:) ⇒ Object
- #unconditional_extension_requirements(expand:) ⇒ Object
- #unconditional_extension_version_conflicts ⇒ Object
- #url ⇒ Object
- #valid? ⇒ Boolean
- #version_specific_requirements_condition ⇒ Object
Constructor Details
#initialize(name, version_spec, arch, fail_if_version_does_not_exist: false) ⇒ ExtensionVersion
Returns a new instance of ExtensionVersion.
518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'lib/udb/obj/extension.rb', line 518 def initialize(name, version_spec, arch, fail_if_version_does_not_exist: false) @name = name.freeze @version_spec = version_spec.freeze @version_str = @version_spec.canonical.freeze @arch = arch @ext = @arch.extension(@name) if fail_if_version_does_not_exist && @ext.nil? raise "Extension #{name} not found in architecture" elsif @ext.nil? Udb.logger.warn "Extension #{name} not found in architecture" return # can't go futher end @data = @ext.data["versions"].find { |v| VersionSpec.new(v["version"]) == @version_spec } if fail_if_version_does_not_exist && @data.nil? raise ArgumentError, "Version #{version_str} of #{@name} extension is not defined" elsif @data.nil? Udb.logger.warn "Version #{version_str} of #{@name} extension is not defined" end @memo = MemomizedState.new end |
Instance Attribute Details
#arch ⇒ Object (readonly)
Returns the value of attribute arch.
466 467 468 |
# File 'lib/udb/obj/extension.rb', line 466 def arch @arch end |
#ext ⇒ Object (readonly)
Returns the value of attribute ext.
455 456 457 |
# File 'lib/udb/obj/extension.rb', line 455 def ext @ext end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
451 452 453 |
# File 'lib/udb/obj/extension.rb', line 451 def name @name end |
#version_spec ⇒ Object (readonly)
Returns the value of attribute version_spec.
459 460 461 |
# File 'lib/udb/obj/extension.rb', line 459 def version_spec @version_spec end |
#version_str ⇒ Object (readonly)
Returns the value of attribute version_str.
463 464 465 |
# File 'lib/udb/obj/extension.rb', line 463 def version_str @version_str end |
Class Method Details
.create(yaml, cfg_arch) ⇒ Object
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'lib/udb/obj/extension.rb', line 475 def self.create(yaml, cfg_arch) requirements = if yaml.key?("version") yaml.fetch("version") else raise "not an extension version" end if requirements.is_a?(Array) if requirements.size != 1 raise "not an extension version: #{requirements} (#{requirements.size})" end requirements = requirements.fetch(0) end begin cfg_arch.extension_version(yaml.fetch("name"), RequirementSpec.new(requirements).version_spec) rescue raise "not an extension version" end end |
.to_ext_req(ext_vers) ⇒ Object
562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/udb/obj/extension.rb', line 562 def self.to_ext_req(ext_vers) raise "ext_vers cannot be empty" if ext_vers.empty? raise "All ext_vers must be of the same extension" unless ext_vers.all? { |ev| ev.name == ext_vers.fetch(0).name } sorted = ext_vers.sort unless T.must(sorted.min).compatible?(T.must(sorted.max)) raise "Impossible to combine because the set contains incompatible versions" end ext_vers.fetch(0).arch.extension_requirement(ext_vers.fetch(0).name, "~> #{T.must(sorted.min).version_str}") end |
Instance Method Details
#<=>(other) ⇒ Object
1173 1174 1175 1176 1177 1178 1179 1180 1181 |
# File 'lib/udb/obj/extension.rb', line 1173 def <=>(other) return nil unless other.is_a?(ExtensionVersion) if other.name != @name @name <=> other.name else @version_spec <=> other.version_spec end end |
#all_csrs_that_must_be_implemented ⇒ Object
778 779 780 |
# File 'lib/udb/obj/extension.rb', line 778 def all_csrs_that_must_be_implemented @all_csrs_that_must_be_implemented ||= csrs + implied_csrs end |
#all_instructions_that_must_be_implemented ⇒ Object
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
# File 'lib/udb/obj/extension.rb', line 730 def all_instructions_that_must_be_implemented @all_instructions_that_must_be_implemented ||= begin pb = Udb.( "Finding implied instructions for #{self} [:bar] :current/:total", total: @arch.instructions.size, clear: true ) @arch.instructions.select do |i| pb.advance (-i.defined_by_condition & to_condition).unsatisfiable_by_arch?(@arch) end end end |
#breaking? ⇒ Boolean
635 636 637 |
# File 'lib/udb/obj/extension.rb', line 635 def breaking? !@data["breaking"].nil? end |
#canonical_version ⇒ Object
641 |
# File 'lib/udb/obj/extension.rb', line 641 def canonical_version = @version_spec.canonical |
#changes ⇒ Object
668 |
# File 'lib/udb/obj/extension.rb', line 668 def changes = @data["changes"].nil? ? [] : T.cast(@data.fetch("changes"), T::Array[String]) |
#compatible?(other) ⇒ Boolean
631 |
# File 'lib/udb/obj/extension.rb', line 631 def compatible?(other) = compatible_versions.include?(other) |
#compatible_versions ⇒ Object
615 616 617 618 619 620 621 622 623 624 625 626 |
# File 'lib/udb/obj/extension.rb', line 615 def compatible_versions return @memo.compatible_versions unless @memo.compatible_versions.nil? @memo.compatible_versions = [] @ext.versions.each do |v| @memo.compatible_versions << v if v.version_spec >= @version_spec break if @memo.compatible_versions.size.positive? && v.breaking? end raise "Didn't even find self?" if compatible_versions.empty? @memo.compatible_versions end |
#condition_hash ⇒ Object
603 604 605 606 607 608 609 610 |
# File 'lib/udb/obj/extension.rb', line 603 def condition_hash { "extension" => { "name" => name, "version" => "= #{version_str}" } } end |
#conditional_extension_requirements(expand:) ⇒ Object
972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 |
# File 'lib/udb/obj/extension.rb', line 972 def conditional_extension_requirements(expand:) if && !@memo..nil? @memo. elsif ! && !@memo..nil? @memo. else req = requirements_condition.to_logic_tree(expand:) cb = LogicNode.make_replace_cb do |node| next node unless node.type == LogicNodeType::Term rterm = node.children.fetch(0) next node unless rterm.is_a?(ExtensionTerm) # remove self next LogicNode::True if rterm.to_ext_req(@arch).satisfied_by?(self) # remove terms unconditionally true or false next LogicNode::True if unconditional_extension_requirements(expand: true).any? { |ext_req| ext_req.satisfied_by?(rterm.to_ext_req(@arch)) } next LogicNode::False if unconditional_extension_conflicts(expand: true).any? { |ext_req| ext_req.satisfied_by?(rterm.to_ext_req(@arch)) } node end remaining = req.replace_terms(cb).minimize(LogicNode::CanonicalizationType::ProductOfSums) list = T.let([], T::Array[ConditionalExtensionRequirement]) # for the remaining terms, find out which ones remaining.terms.each do |term| next unless term.is_a?(ExtensionTerm) # find unconditional reqs of self && term c = Condition.conjunction([term.to_condition(@arch), to_condition], @arch) ctree = c.to_logic_tree(expand: true) unconditional_terms = remaining.terms.select do |cterm| next if cterm.is_a?(ParameterTerm) || cterm.is_a?(XlenTerm) raise "?" if cterm.is_a?(FreeTerm) next if cterm.name == name next if cterm.name == term.name cb = LogicNode.make_replace_cb do |node| if node.type == LogicNodeType::Term && node.node_children.fetch(0).is_a?(ExtensionTerm) node_term = T.cast(node.node_children.fetch(0), ExtensionTerm) if node_term.name == name LogicNode::True elsif node_term.name == cterm.name LogicNode::False else node end else node end end !ctree.replace_terms(cb).satisfiable?(@arch) end next if unconditional_terms.empty? if unconditional_terms.size == 1 cond = T.cast(unconditional_terms.fetch(0), ExtensionTerm).to_ext_req(@arch).to_condition contradiction = Condition.conjunction( [ cond, Condition.not(term.to_condition(@arch), @arch), to_condition ], @arch ) is_needed = !contradiction.satisfiable? if is_needed if Condition.conjunction([cond, Condition.not(term.to_condition(@arch), @arch)], @arch).satisfiable? # skip reqs that are implied list << ConditionalExtensionRequirement.new( ext_req: term.to_ext_req(@arch), cond: ) end end else conj = Condition.conjunction(unconditional_terms.map { |t| T.cast(t, ExtensionTerm).to_condition(@arch) }, @arch) conj_tree = conj.to_logic_tree(expand: false) formula = LogicNode.new( LogicNodeType::And, conj_tree.node_children.map do |node| covered = conj_tree.node_children.any? do |other_node| next false if node.equal?(other_node) if Condition.conjunction([to_condition, Condition.new(other_node.to_h, @arch)], @arch).always_implies?(Condition.new(node.to_h, @arch)) true else false end end if covered LogicNode::True else node end end ) # is this needed? if self can still be satisfied when condition is false but term is true, # this term isn't actually a requirement (it's most likely related to a conflict) contradiction = Condition.conjunction( [ conj, Condition.not(term.to_condition(@arch), @arch), to_condition ], @arch ) is_needed = !contradiction.satisfiable? cond = Condition.new(formula.reduce.to_h, @arch) if is_needed # && Condition.conjunction([cond, term.to_condition(@arch), to_condition], @arch).satisfiable? # make sure it's a requirement if Condition.conjunction([cond, Condition.not(term.to_condition(@arch), @arch)], @arch).satisfiable? list << ConditionalExtensionRequirement.new( ext_req: term.to_ext_req(@arch), cond: ) end end end end if list.each do |cond_ext_req| ext_ver = T.must(cond_ext_req.ext_req..max) ext_ver.ext_requirements(expand:).each do |nested_cond_ext_req| already_in_cond_list = list.any? { |c| c.ext_req.satisfied_by?(nested_cond_ext_req.ext_req) } \ || list.any? { |c| c.cond.to_logic_tree(expand: false).terms.any? { |t| T.cast(t, ExtensionTerm).to_ext_req(@arch).satisfied_by?(nested_cond_ext_req.ext_req) } } already_in_uncond_list = unconditional_extension_requirements(expand:).any? { |ext_req| nested_cond_ext_req.ext_req.satisfied_by?(ext_req) } next if already_in_uncond_list if already_in_cond_list # keep the one with the more expansive condition else if nested_cond_ext_req.cond.empty? list << ConditionalExtensionRequirement.new( ext_req: nested_cond_ext_req.ext_req, cond: cond_ext_req.cond ) else list << ConditionalExtensionRequirement.new( ext_req: nested_cond_ext_req.ext_req, cond: Condition.conjunction([cond_ext_req.cond, nested_cond_ext_req.cond], @arch) ) end end end end end if @memo. = list @memo..freeze else @memo. = list @memo..freeze end end end |
#contributors ⇒ Object
675 676 677 678 679 680 681 682 683 |
# File 'lib/udb/obj/extension.rb', line 675 def contributors return @contributors unless @contributors.nil? @contributors = [] @data["contributors"]&.each do |c| @contributors << Person.new(c) end @contributors end |
#csrs ⇒ Object
753 754 755 756 757 758 |
# File 'lib/udb/obj/extension.rb', line 753 def csrs @csrs ||= ext.csrs.select do |csr| (csr.defined_by_condition & to_condition).satisfiable_by_cfg_arch?(@arch) end end |
#defining_extension_requirements ⇒ Object
833 834 835 836 |
# File 'lib/udb/obj/extension.rb', line 833 def defining_extension_requirements [] # combined_requirements_condition.implied_extension_requirements end |
#directly_defined_instructions ⇒ Object
697 698 699 700 |
# File 'lib/udb/obj/extension.rb', line 697 def directly_defined_instructions @instructions ||= all_instructions_that_must_be_implemented - implied_instructions end |
#directly_defined_instructions_set ⇒ Object
704 705 706 |
# File 'lib/udb/obj/extension.rb', line 704 def directly_defined_instructions_set @instructions_set ||= Set.new(directly_defined_instructions) end |
#eql?(other) ⇒ Boolean
644 645 646 647 648 649 650 |
# File 'lib/udb/obj/extension.rb', line 644 def eql?(other) if other.is_a?(ExtensionVersion) self.==(other) else false end end |
#exception_codes ⇒ Object
1186 1187 1188 1189 1190 1191 1192 1193 1194 |
# File 'lib/udb/obj/extension.rb', line 1186 def exception_codes @exception_codes ||= @arch.exception_codes.select do |ecode| # define every extension version except this one (and compatible), # and test if the condition can be satisfied ecode.defined_by_condition.satisfied_by_ext_req?(@arch.extension_requirement(@name, "~> #{@version_spec}"), include_requirements: false) || ecode.defined_by_condition.satisfiability_depends_on_ext_req?(@arch.extension_requirement(@name, "~> #{@version_spec}")) end end |
#ext_conflicts(expand:) ⇒ Object
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 |
# File 'lib/udb/obj/extension.rb', line 1160 def ext_conflicts(expand:) # make a condition for the version, expand it, and then report what comes out, minus self if @memo. ||= unconditional_extension_conflicts(expand:).map { |ext_req| ConditionalExtensionRequirement.new(ext_req:, cond: AlwaysTrueCondition.new(@arch)) } else @memo. ||= unconditional_extension_conflicts(expand:).map { |ext_req| ConditionalExtensionRequirement.new(ext_req:, cond: AlwaysTrueCondition.new(@arch)) } end end |
#ext_requirements(expand:) ⇒ Object
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 |
# File 'lib/udb/obj/extension.rb', line 1146 def ext_requirements(expand:) # make a condition for the version, expand it, and then report what comes out, minus self if @memo. ||= unconditional_extension_requirements(expand:).map { |ext_req| ConditionalExtensionRequirement.new(ext_req:, cond: AlwaysTrueCondition.new(@arch)) } \ + conditional_extension_requirements(expand:) else @memo. ||= unconditional_extension_requirements(expand:).map { |ext_req| ConditionalExtensionRequirement.new(ext_req:, cond: AlwaysTrueCondition.new(@arch)) } \ + conditional_extension_requirements(expand:) end end |
#hash ⇒ Object
653 654 655 |
# File 'lib/udb/obj/extension.rb', line 653 def hash @memo.key ||= [@name, @version_spec].hash end |
#implied_csrs ⇒ Object
761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 |
# File 'lib/udb/obj/extension.rb', line 761 def implied_csrs @implied_csrs ||= begin pb = Udb.( "Finding implied csrs for #{self} [:bar] :current/:total", total: @arch.csrs.size, clear: true ) @arch.csrs.select do |csr| pb.advance (-csr.defined_by_condition & requirements_condition).satisfiable_by_cfg_arch?(@arch) end end end |
#implied_instructions ⇒ Object
709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 |
# File 'lib/udb/obj/extension.rb', line 709 def implied_instructions @implied_instructions ||= begin pb = Udb.( "Finding implied instructions for #{self} [:bar] :current/:total", total: @arch.instructions.size, clear: true ) @arch.instructions.select do |i| pb.advance (-i.defined_by_condition & requirements_condition).unsatisfiable_by_arch?(@arch) end end end |
#implied_instructions_set ⇒ Object
748 749 750 |
# File 'lib/udb/obj/extension.rb', line 748 def implied_instructions_set @implied_instructions_set ||= Set.new(implied_instructions) end |
#in_scope_csrs(xlens) ⇒ Object
1208 1209 1210 1211 1212 |
# File 'lib/udb/obj/extension.rb', line 1208 def in_scope_csrs(xlens) csrs.select do |csr| csr.base.nil? || xlens.include?(csr.base) end end |
#in_scope_instructions(xlens) ⇒ Object
1215 1216 1217 1218 1219 |
# File 'lib/udb/obj/extension.rb', line 1215 def in_scope_instructions(xlens) directly_defined_instructions.select do |inst| inst.base.nil? || xlens.include?(inst.base) end end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
550 551 552 |
# File 'lib/udb/obj/extension.rb', line 550 def inspect to_s end |
#interrupt_codes ⇒ Object
1199 1200 1201 1202 1203 1204 1205 |
# File 'lib/udb/obj/extension.rb', line 1199 def interrupt_codes @interrupt_codes ||= @arch.interrupt_codes.select do |icode| icode.defined_by_condition.satisfied_by_ext_req?(@arch.extension_requirement(@name, "~> #{@version_spec}"), include_requirements: false) || icode.defined_by_condition.satisfiability_depends_on_ext_req?(@arch.extension_requirement(@name, "~> #{@version_spec}")) end end |
#params ⇒ Object
687 688 689 690 691 692 |
# File 'lib/udb/obj/extension.rb', line 687 def params @params ||= ext.params.select do |param| (param.defined_by_condition & to_condition).satisfiable_by_cfg_arch?(@arch) end end |
#ratification_date ⇒ Object
662 |
# File 'lib/udb/obj/extension.rb', line 662 def ratification_date = @data["ratification_date"] |
#release_date ⇒ Object
665 |
# File 'lib/udb/obj/extension.rb', line 665 def release_date = @data["release_date"] |
#requirements_condition ⇒ Object
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 |
# File 'lib/udb/obj/extension.rb', line 813 def requirements_condition @requirements_condition ||= if @data.key?("requirements") && ext.data.key?("requirements") Condition.new( { "allOf" => [ @data.fetch("requirements"), ext.data.fetch("requirements") ] }, @arch ) elsif !@data.key?("requirements") ext.general_extension_requirements_condition else version_specific_requirements_condition end end |
#state ⇒ Object
659 |
# File 'lib/udb/obj/extension.rb', line 659 def state = T.cast(@data.fetch("state"), String) |
#to_condition ⇒ Object
581 582 583 584 |
# File 'lib/udb/obj/extension.rb', line 581 def to_condition @memo.condition ||= Condition.new(condition_hash, @arch) end |
#to_condition_exclusive ⇒ Object
588 589 590 591 592 593 594 595 596 597 598 599 600 |
# File 'lib/udb/obj/extension.rb', line 588 def to_condition_exclusive @memo.condition_exclusive ||= begin other_versions = @ext.versions - [self] if other_versions.empty? to_condition elsif other_versions.size == 1 to_condition & -other_versions.fetch(0).to_condition else to_condition & -Condition.disjunction(other_versions.map(&:to_condition), @arch) end end end |
#to_ext_req ⇒ Object
1222 1223 1224 |
# File 'lib/udb/obj/extension.rb', line 1222 def to_ext_req @ext_req ||= @arch.extension_requirement(name, "= #{version_str}") end |
#to_h ⇒ Object
1227 1228 1229 1230 1231 1232 1233 |
# File 'lib/udb/obj/extension.rb', line 1227 def to_h @h ||= { "name" => @name, "version" => "= #{version_str}" } end |
#to_rvi_s ⇒ Object
787 788 789 |
# File 'lib/udb/obj/extension.rb', line 787 def to_rvi_s "#{name}#{@version_spec.to_rvi_s}" end |
#to_s ⇒ Object
793 794 795 |
# File 'lib/udb/obj/extension.rb', line 793 def to_s "#{name}@#{@version_spec.canonical}" end |
#to_term ⇒ Object
576 577 578 |
# File 'lib/udb/obj/extension.rb', line 576 def to_term @memo.term ||= ExtensionTerm.new(@name, "=", @version_str) end |
#unconditional_extension_conflicts(expand:) ⇒ Object
916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 |
# File 'lib/udb/obj/extension.rb', line 916 def unconditional_extension_conflicts(expand:) if && !@memo..nil? @memo. elsif ! && !@memo..nil? @memo. else list = begin requirements_condition.ext_req_terms(expand:).select do |ext_req| (requirements_condition & ext_req.to_condition).unsatisfiable? end # req = requirements_condition.to_logic_tree(expand:) # expand_req = requirements_condition.to_logic_tree(expand: true) # # find all unconditional reqs -- that is, # # reqs that must always be satisfied for requirements to be met # unconditional_terms = # req.terms.select do |term| # next if term.is_a?(ParameterTerm) || term.is_a?(XlenTerm) # raise "?" if term.is_a?(FreeTerm) # next if term.name == name # # see if req is unsatisfiable when term is present # cb = LogicNode.make_replace_cb do |node| # if node.type == LogicNodeType::Term && node.node_children.fetch(0).is_a?(ExtensionTerm) # node_term = T.cast(node.node_children.fetch(0), ExtensionTerm) # if node_term.name == name # LogicNode::True # elsif node_term.name == term.name # LogicNode::True # else # node # end # else # node # end # end # !expand_req.replace_terms(cb).satisfiable? # end # T.cast(unconditional_terms, T::Array[ExtensionTerm]).map { |t| t.to_ext_req(@arch) } end if @memo. = list @memo..freeze else @memo. = list @memo..freeze end end end |
#unconditional_extension_requirements(expand:) ⇒ Object
843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 |
# File 'lib/udb/obj/extension.rb', line 843 def unconditional_extension_requirements(expand:) if && !@memo..nil? @memo. elsif ! && !@memo..nil? @memo. else list = begin requirements_condition.ext_req_terms(expand:).select do |ext_req| # is requirements_condition satisfiable when ext_req is not met? (requirements_condition & -ext_req.to_condition).unsatisfiable? end # req = requirements_condition.to_logic_tree(expand:) # expand_req = requirements_condition.to_logic_tree(expand: true) # # find all unconditional reqs -- that is, # # reqs that must always be satisfied for requirements to be met # unconditional_terms = # req.terms.select do |term| # next if term.is_a?(ParameterTerm) || term.is_a?(XlenTerm) # raise "?" if term.is_a?(FreeTerm) # next if term.name == name # # see if req is satisfiable when term is absent # cb = LogicNode.make_replace_cb do |node| # if node.type == LogicNodeType::Term && node.node_children.fetch(0).is_a?(ExtensionTerm) # node_term = T.cast(node.node_children.fetch(0), ExtensionTerm) # if node_term.name == name # LogicNode::True # elsif node_term.name == term.name # LogicNode::False # else # node # end # else # node # end # end # !expand_req.replace_terms(cb).satisfiable? # end # T.cast(unconditional_terms, T::Array[ExtensionTerm]).map { |t| t.to_ext_req(@arch) } end if @memo. = list @memo..freeze else @memo. = list @memo..freeze end end end |
#unconditional_extension_version_conflicts ⇒ Object
901 902 903 904 905 906 907 908 909 |
# File 'lib/udb/obj/extension.rb', line 901 def unconditional_extension_version_conflicts @unconditional_extension_version_conflicts ||= @arch.extension_versions.select do |ext_ver| next if ext_ver.name == name (to_condition & ext_ver.to_condition).unsatisfiable? # !Condition.conjunction([to_condition, ext_ver.to_condition], @arch).satisfiable? end end |
#url ⇒ Object
671 |
# File 'lib/udb/obj/extension.rb', line 671 def url = @data["url"] |
#valid? ⇒ Boolean
547 |
# File 'lib/udb/obj/extension.rb', line 547 def valid? = !@ext.nil? |
#version_specific_requirements_condition ⇒ Object
799 800 801 802 803 804 805 806 807 808 809 |
# File 'lib/udb/obj/extension.rb', line 799 def version_specific_requirements_condition @requirements_condition ||= @data.key?("requirements") \ ? Condition.new( @data.fetch("requirements"), @arch, input_file: Pathname.new(ext.__source), input_line: ext.source_line(["versions", ext.data.fetch("versions").index { |v| VersionSpec.new(v["version"]) == version_spec }]) ) : AlwaysTrueCondition.new(@arch) end |