Class: Jade::Frontend::PatternAnalysis::Matrix
- Inherits:
-
Data
- Object
- Data
- Jade::Frontend::PatternAnalysis::Matrix
- Defined in:
- lib/jade/frontend/pattern_analysis/matrix.rb
Instance Attribute Summary collapse
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Class Method Summary collapse
Instance Method Summary collapse
- #any? ⇒ Boolean
- #concat(other) ⇒ Object
- #empty? ⇒ Boolean
- #include?(row) ⇒ Boolean
- #map ⇒ Object
- #missing_patterns(env) ⇒ Object
- #size ⇒ Object
Instance Attribute Details
#rows ⇒ Object (readonly)
Returns the value of attribute rows
4 5 6 |
# File 'lib/jade/frontend/pattern_analysis/matrix.rb', line 4 def rows @rows end |
#types ⇒ Object (readonly)
Returns the value of attribute types
4 5 6 |
# File 'lib/jade/frontend/pattern_analysis/matrix.rb', line 4 def types @types end |
Class Method Details
.empty(types = []) ⇒ Object
12 13 14 |
# File 'lib/jade/frontend/pattern_analysis/matrix.rb', line 12 def self.empty(types = []) self.new([], types) end |
Instance Method Details
#any? ⇒ Boolean
34 35 36 |
# File 'lib/jade/frontend/pattern_analysis/matrix.rb', line 34 def any? rows.any? end |
#concat(other) ⇒ Object
38 39 40 |
# File 'lib/jade/frontend/pattern_analysis/matrix.rb', line 38 def concat(other) with(rows: rows + other.rows) end |
#empty? ⇒ Boolean
30 31 32 |
# File 'lib/jade/frontend/pattern_analysis/matrix.rb', line 30 def empty? rows.empty? end |
#include?(row) ⇒ Boolean
22 23 24 |
# File 'lib/jade/frontend/pattern_analysis/matrix.rb', line 22 def include?(row) rows.include?(row) end |
#map ⇒ Object
16 17 18 19 20 |
# File 'lib/jade/frontend/pattern_analysis/matrix.rb', line 16 def map rows .map { yield it } .then { with(rows: it) } end |
#missing_patterns(env) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/jade/frontend/pattern_analysis/matrix.rb', line 42 def missing_patterns(env) if types.empty? return rows.empty? ? Matrix[[[]], types] : Matrix.empty end type = types.first return Matrix.empty if never?(type) return Matrix.wildcard(types) if rows.empty? heads = head_constructors if infinite?(type) || type_var?(type) unmatched_column(env) elsif (type, env) (env).missing_patterns(env) elsif heads.empty? unmatched_column(env) else constructors_of(type, env) .reduce(Matrix.empty.with(types:)) do |acc, constructor| witnesses(constructor, env, heads.include?(constructor.name)) .then { acc.concat(it) } end end end |
#size ⇒ Object
26 27 28 |
# File 'lib/jade/frontend/pattern_analysis/matrix.rb', line 26 def size rows.size end |