Class: Udb::Extension
- Inherits:
-
TopLevelDatabaseObject
- Object
- DatabaseObject
- TopLevelDatabaseObject
- Udb::Extension
- Includes:
- CertifiableObject
- Defined in:
- lib/udb/obj/extension.rb,
lib/udb/exception_code.rb
Overview
Extension definition
Instance Method Summary collapse
- #<=>(other_ext) ⇒ Object
- #cert_coverage_point(id) ⇒ CertNormativeRule? included from CertifiableObject
-
#cert_coverage_point_hash ⇒ Hash<String, CertNormativeRule>
included
from CertifiableObject
Hash with ID as key of all normative rules defined by database object.
- #cert_normative_rules ⇒ Array<CertNormativeRule> included from CertifiableObject
- #cert_test_procedure(id) ⇒ CertTestProcedure? included from CertifiableObject
-
#cert_test_procedure_hash ⇒ Hash<String, CertTestProcedure>
included
from CertifiableObject
Hash of all normative rules defined by database object.
- #cert_test_procedures ⇒ Array<CertTestProcedure> included from CertifiableObject
-
#compact_priv_type ⇒ String
Either unpriv or priv.
- #company ⇒ String?
-
#conflicts_condition ⇒ AbstractRequirement
Logic expression for conflicts.
-
#csrs ⇒ Array<Csr>
The list of CSRs implemented by *any version* of this extension (may be empty).
- #doc_license ⇒ { name: String, url: String}?
- #exception_codes ⇒ Array<ExceptionCode>
-
#implies(version_requirement = nil) ⇒ Array<ExtensionVersion>
Array of extensions implied by the largest version of this extension meeting version_requirement.
-
#instructions ⇒ Array<Instruction>
The list of instructions implemented by *any version* of this extension (may be empty).
- #interrupt_codes ⇒ Array<InterruptCode>
-
#long_name ⇒ String
Long name of the extension.
-
#max_version ⇒ ExtensionVersion
Maximum defined version of this extension.
- #min_ratified_version ⇒ ExtensionVersion?
-
#min_version ⇒ ExtensionVersion
Mimumum defined version of this extension.
-
#params ⇒ Array<Parameter>
List of parameters added by this extension.
-
#priv_type ⇒ String
Either unprivileged or privileged.
-
#ratified ⇒ Boolean
Any version ratified?.
-
#ratified_versions ⇒ Array<ExtensionVersion>
Ratified versions hash from config.
-
#reachable_functions ⇒ Array<Idl::FunctionBodyAst>
return the set of reachable functions from any of this extensions’s CSRs or instructions in the given evaluation context.
-
#versions ⇒ Array<ExtensionVersion>
Versions hash from config, sorted by version number.
Constructor Details
This class inherits a constructor from Udb::TopLevelDatabaseObject
Instance Method Details
#<=>(other_ext) ⇒ Object
165 166 167 168 |
# File 'lib/udb/obj/extension.rb', line 165 def <=>(other_ext) raise ArgumentError, "Can only compare two Extensions" unless other_ext.is_a?(Extension) other_ext.name <=> name end |
#cert_coverage_point(id) ⇒ CertNormativeRule? Originally defined in module CertifiableObject
#cert_coverage_point_hash ⇒ Hash<String, CertNormativeRule> Originally defined in module CertifiableObject
Returns Hash with ID as key of all normative rules defined by database object.
#cert_normative_rules ⇒ Array<CertNormativeRule> Originally defined in module CertifiableObject
#cert_test_procedure(id) ⇒ CertTestProcedure? Originally defined in module CertifiableObject
#cert_test_procedure_hash ⇒ Hash<String, CertTestProcedure> Originally defined in module CertifiableObject
Returns Hash of all normative rules defined by database object.
#cert_test_procedures ⇒ Array<CertTestProcedure> Originally defined in module CertifiableObject
#compact_priv_type ⇒ String
Returns Either unpriv or priv.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/udb/obj/extension.rb', line 30 def compact_priv_type case priv_type when "unprivileged" "unpriv" when "privileged" "priv" else if priv_type.nil? || priv_type.empty? raise ArgumentError, "Extension #{name} missing its type in database (must be privileged or unprivileged)" else raise ArgumentError, "Extension #{name} has illegal privileged/unprivileged type of #{priv_type}" end end end |
#company ⇒ String?
47 48 49 |
# File 'lib/udb/obj/extension.rb', line 47 def company @data["company"] end |
#conflicts_condition ⇒ AbstractRequirement
Returns Logic expression for conflicts.
121 122 123 124 125 126 127 128 |
# File 'lib/udb/obj/extension.rb', line 121 def conflicts_condition @conflicts_condition ||= if @data["conflicts"].nil? AlwaysFalseExtensionRequirementExpression.new else ExtensionRequirementExpression.new(@data["conflicts"], @cfg_arch) end end |
#csrs ⇒ Array<Csr>
Returns the list of CSRs implemented by *any version* of this extension (may be empty).
136 137 138 |
# File 'lib/udb/obj/extension.rb', line 136 def csrs @csrs ||= cfg_arch.csrs.select { |csr| versions.any? { |v| csr.defined_by_condition.possibly_satisfied_by?(v) } } end |
#doc_license ⇒ { name: String, url: String}?
53 54 55 |
# File 'lib/udb/obj/extension.rb', line 53 def doc_license @data["doc_license"] end |
#exception_codes ⇒ Array<ExceptionCode>
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/udb/obj/extension.rb', line 171 def exception_codes @exception_codes ||= if @data.key?("exception_codes") ecodes = [] d = T.cast(@data["exception_codes"], T::Array[T::Hash[String, T.any(Integer, String)]]) d.each do |edata| raise "Duplicate exception code" if ecodes.any? { |e| e.num == edata["num"] || e.name == edata["name"] || e.var == edata["var"] } ecodes << ExceptionCode.new( T.cast(edata.fetch("name"), String), T.cast(edata.fetch("var"), String), T.cast(edata.fetch("num"), Integer), self ) end ecodes else [] end end |
#implies(version_requirement = nil) ⇒ Array<ExtensionVersion>
Returns Array of extensions implied by the largest version of this extension meeting version_requirement.
110 111 112 113 114 115 116 117 |
# File 'lib/udb/obj/extension.rb', line 110 def implies(version_requirement = nil) if version_requirement.nil? max_version.implications else mv = ExtensionRequirement.new(@name, version_requirement, arch: @cfg_arch). mv.implications end end |
#instructions ⇒ Array<Instruction>
Returns the list of instructions implemented by *any version* of this extension (may be empty).
131 132 133 |
# File 'lib/udb/obj/extension.rb', line 131 def instructions @instructions ||= cfg_arch.instructions.select { |i| versions.any? { |v| i.defined_by_condition.possibly_satisfied_by?(v) }} end |
#interrupt_codes ⇒ Array<InterruptCode>
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/udb/obj/extension.rb', line 195 def interrupt_codes @exception_codes ||= if @data.key?("interrupt_codes") ecodes = [] d = T.cast(@data["interrupt_codes"], T::Array[T::Hash[String, T.any(Integer, String)]]) d.each do |edata| raise "Duplicate interrup code" if ecodes.any? { |e| e.num == edata["num"] || e.name == edata["name"] || e.var == edata["var"] } ecodes << InterruptCode.new( T.cast(edata.fetch("name"), String), T.cast(edata.fetch("var"), String), T.cast(edata.fetch("num"), Integer), self ) end ecodes else [] end end |
#long_name ⇒ String
Returns Long name of the extension.
24 |
# File 'lib/udb/obj/extension.rb', line 24 def long_name = @data["long_name"] |
#max_version ⇒ ExtensionVersion
Returns Maximum defined version of this extension.
83 84 85 |
# File 'lib/udb/obj/extension.rb', line 83 def max_version versions.max { |a, b| a.version_spec <=> b.version_spec } end |
#min_ratified_version ⇒ ExtensionVersion?
89 90 91 92 93 |
# File 'lib/udb/obj/extension.rb', line 89 def min_ratified_version return nil if ratified_versions.empty? ratified_versions.min { |a, b| a.version_spec <=> b.version_spec } end |
#min_version ⇒ ExtensionVersion
Returns Mimumum defined version of this extension.
78 79 80 |
# File 'lib/udb/obj/extension.rb', line 78 def min_version versions.min { |a, b| a.version_spec <=> b.version_spec } end |
#params ⇒ Array<Parameter>
Returns List of parameters added by this extension.
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/udb/obj/extension.rb', line 96 def params return @params unless @params.nil? @params = [] if @data.key?("params") @data["params"].each do |param_name, param_data| @params << Parameter.new(self, param_name, param_data) end end @params end |
#priv_type ⇒ String
Returns Either unprivileged or privileged.
27 |
# File 'lib/udb/obj/extension.rb', line 27 def priv_type = @data["type"] |
#ratified ⇒ Boolean
Returns Any version ratified?.
74 |
# File 'lib/udb/obj/extension.rb', line 74 def ratified = ratified_versions.any? |
#ratified_versions ⇒ Array<ExtensionVersion>
Returns Ratified versions hash from config.
69 70 71 |
# File 'lib/udb/obj/extension.rb', line 69 def ratified_versions versions.select { |v| v.state == "ratified" } end |
#reachable_functions ⇒ Array<Idl::FunctionBodyAst>
return the set of reachable functions from any of this extensions’s CSRs or instructions in the given evaluation context
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/udb/obj/extension.rb', line 144 def reachable_functions return @reachable_functions unless @reachable_functions.nil? funcs = T.let([], T::Array[Idl::FunctionBodyAst]) puts "Finding all reachable functions from extension #{name}" instructions.each do |inst| funcs += inst.reachable_functions(32) if inst.defined_in_base?(32) funcs += inst.reachable_functions(64) if inst.defined_in_base?(64) end # The one place in this file that needs a ConfiguredArchitecture object instead of just Architecture. raise "In #{name}, need to provide ConfiguredArchitecture" if cfg_arch.nil? csrs.each do |csr| funcs += csr.reachable_functions end @reachable_functions = funcs.uniq end |
#versions ⇒ Array<ExtensionVersion>
Returns versions hash from config, sorted by version number.
58 59 60 61 62 63 64 65 66 |
# File 'lib/udb/obj/extension.rb', line 58 def versions return @versions unless @versions.nil? @versions = @data["versions"].map do |v| ExtensionVersion.new(name, v["version"], arch) end @versions.sort! @versions end |