Class: TypedRb::Model::TmConst
Overview
A constant expression
Instance Attribute Summary collapse
-
#val ⇒ Object
readonly
Returns the value of attribute val.
Attributes inherited from Expr
Instance Method Summary collapse
- #check_type(_context) ⇒ Object
-
#initialize(val, node) ⇒ TmConst
constructor
A new instance of TmConst.
Constructor Details
#initialize(val, node) ⇒ TmConst
Returns a new instance of TmConst.
9 10 11 12 |
# File 'lib/typed/model/tm_const.rb', line 9 def initialize(val, node) super(node) @val = val end |
Instance Attribute Details
#val ⇒ Object (readonly)
Returns the value of attribute val.
7 8 9 |
# File 'lib/typed/model/tm_const.rb', line 7 def val @val end |
Instance Method Details
#check_type(_context) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/typed/model/tm_const.rb', line 14 def check_type(_context) value_ruby_type = Types::TypingContext.find_namespace(@val) type = if value_ruby_type.instance_of?(Class) Runtime::TypeParser.parse_singleton_object_type(value_ruby_type.name) elsif value_ruby_type.instance_of?(Module) Runtime::TypeParser.parse_existential_object_type(value_ruby_type.name) else # Must be a user defined constant Types::TyObject.new(value_ruby_type.class) end type.node = node type end |