Class: LIT::TypeChecker Private
- Inherits:
-
Object
- Object
- LIT::TypeChecker
- Defined in:
- lib/lit/type_checker.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- AST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Parser::AST
- PRIMITIVE_TYPE_NAMESPACE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"AST::Type::Primitive"
Instance Method Summary collapse
- #check_type!(type, value) ⇒ Object private
-
#initialize(mod) ⇒ TypeChecker
constructor
private
A new instance of TypeChecker.
Constructor Details
#initialize(mod) ⇒ TypeChecker
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.
Returns a new instance of TypeChecker.
10 11 12 |
# File 'lib/lit/type_checker.rb', line 10 def initialize(mod) @mod = mod end |
Instance Method Details
#check_type!(type, value) ⇒ 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.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lit/type_checker.rb', line 14 def check_type!(type, value) is_primitive = if type.is_a?(Module) type.name.include?(PRIMITIVE_TYPE_NAMESPACE) else type.class.name.include?(PRIMITIVE_TYPE_NAMESPACE) end if is_primitive check_primitive_type!(type, value) elsif type.is_a?(AST::Type::Alias) check_type_alias!(type.name, value) else raise InvalidTypeError, "invalid type: #{type}" end end |