Class: Rigor::RbsExtended::PredicateEffect
- Inherits:
-
Object
- Object
- Rigor::RbsExtended::PredicateEffect
- Defined in:
- lib/rigor/rbs_extended.rb,
sig/rigor/rbs_extended.rbs
Overview
Returned for predicate-if-true / predicate-if-false. target_kind is :parameter (with target_name
the Ruby parameter symbol) or :self. negative is true when the directive uses the ~ClassName form, in
which case the engine narrows AWAY from class_name (Narrowing.narrow_not_class) instead of toward it.
refinement_type is non-nil when the right-hand side is a kebab-case refinement name (non-empty-string,
lowercase-string, …) instead of a Capitalised class name. The narrowing tier substitutes the carrier for
the current local type; class_name is then nil. negative may be true for refinement-form directives —
~T negation is supported; the narrowing tier computes the complement decomposition (see AssertEffect
docs below).
Instance Attribute Summary collapse
-
#class_name ⇒ String
readonly
Returns the value of attribute class_name.
-
#edge ⇒ predicate_edge
readonly
Returns the value of attribute edge.
-
#negative ⇒ Boolean
readonly
Returns the value of attribute negative.
-
#target_kind ⇒ target_kind
readonly
Returns the value of attribute target_kind.
-
#target_name ⇒ Symbol
readonly
Returns the value of attribute target_name.
Class Method Summary collapse
Instance Method Summary collapse
- #falsey_only? ⇒ Boolean
- #negative? ⇒ Boolean
- #refinement? ⇒ Boolean
-
#to_fact ⇒ Object
ADR-7 § "Slice 4-A" canonical translation.
- #truthy_only? ⇒ Boolean
Instance Attribute Details
#class_name ⇒ String (readonly)
Returns the value of attribute class_name.
12 13 14 |
# File 'sig/rigor/rbs_extended.rbs', line 12 def class_name @class_name end |
#edge ⇒ predicate_edge (readonly)
Returns the value of attribute edge.
9 10 11 |
# File 'sig/rigor/rbs_extended.rbs', line 9 def edge @edge end |
#negative ⇒ Boolean (readonly)
Returns the value of attribute negative.
13 14 15 |
# File 'sig/rigor/rbs_extended.rbs', line 13 def negative @negative end |
#target_kind ⇒ target_kind (readonly)
Returns the value of attribute target_kind.
10 11 12 |
# File 'sig/rigor/rbs_extended.rbs', line 10 def target_kind @target_kind end |
#target_name ⇒ Symbol (readonly)
Returns the value of attribute target_name.
11 12 13 |
# File 'sig/rigor/rbs_extended.rbs', line 11 def target_name @target_name end |
Class Method Details
.new ⇒ PredicateEffect
15 |
# File 'sig/rigor/rbs_extended.rbs', line 15
def self.new: (edge: predicate_edge, target_kind: target_kind, target_name: Symbol, class_name: String, negative: bool) -> PredicateEffect
|
Instance Method Details
#falsey_only? ⇒ Boolean
43 |
# File 'lib/rigor/rbs_extended.rb', line 43 def falsey_only? = edge == :falsey_only |
#negative? ⇒ Boolean
44 |
# File 'lib/rigor/rbs_extended.rb', line 44 def negative? = negative == true |
#refinement? ⇒ Boolean
45 |
# File 'lib/rigor/rbs_extended.rb', line 45 def refinement? = !refinement_type.nil? |
#to_fact ⇒ Object
ADR-7 § "Slice 4-A" canonical translation. Lifts the parser-side carrier into a
Rigor::FlowContribution::Fact that the merger and plugin contribution stream consume uniformly.
class_name lifts to Nominal[<class>]; refinement_type is already a Rigor::Type and passes through.
The edge field doesn't survive the conversion — the slot it lands in (truthy_facts / falsey_facts / ...)
encodes that.
52 53 54 55 56 57 58 59 |
# File 'lib/rigor/rbs_extended.rb', line 52 def to_fact FlowContribution::Fact.new( target_kind: target_kind, target_name: target_name, type: refinement_type || Rigor::Type::Combinator.nominal_of(class_name), negative: negative == true ) end |
#truthy_only? ⇒ Boolean
42 |
# File 'lib/rigor/rbs_extended.rb', line 42 def truthy_only? = edge == :truthy_only |