Class: Yadriggy::C::ClangTypeChecker
- Inherits:
-
RubyTypeInferer
- Object
- Yadriggy::Checker
- TypeChecker
- RubyTypeChecker
- RubyTypeInferer
- Yadriggy::C::ClangTypeChecker
- Includes:
- CType
- Defined in:
- lib/yadriggy/c/ctypecheck.rb
Direct Known Subclasses
Constant Summary
Constants included from CType
Yadriggy::C::CType::Float32Array, Yadriggy::C::CType::FloatArray, Yadriggy::C::CType::Int, Yadriggy::C::CType::IntArray, Yadriggy::C::CType::Void
Constants included from Yadriggy
Instance Attribute Summary collapse
-
#instance_variables ⇒ Set<IvarObj>
readonly
Accessed instance variables.
-
#local_vars_table ⇒ Hash<Def,Hash<Symbol,Type>>
readonly
A map from functions to their local variables.
Instance Method Summary collapse
-
#initialize(syntax = nil) ⇒ ClangTypeChecker
constructor
A new instance of ClangTypeChecker.
- #is_subsumed_by?(sub_type, super_type) ⇒ Boolean
-
#method_with_block?(name) ⇒ Boolean
Specifies the names of methods with a block.
- #typecheck_call_with_block(call_ast) ⇒ Object
- #valid_type?(t) ⇒ Boolean
- #valid_var_type?(t) ⇒ Boolean
Methods included from CType
Methods inherited from RubyTypeInferer
#bind_local_var, #get_instance_variable_type
Methods inherited from RubyTypeChecker
#bind_local_var, #get_call_expr_type, #get_name_type, #get_return_type, #lookup_ruby_classes, #type_args_and_block, #type_assert_params, #type_assert_subsume, #type_parameters
Methods inherited from TypeChecker
#add_typedef, #error_group, #make_base_env, #type, #type?, #type_as, #type_assert, #type_assert_false, #type_assert_later, #type_env, #typecheck, #typedef
Methods inherited from Yadriggy::Checker
#ast, #ast_env, #check, #check_all, #check_later, #error!, #error_found!, #error_messages, #errors?, #last_error, #make_base_env, #proceed, rule
Methods included from Yadriggy
debug, debug=, define_syntax, reify, reset_pry
Constructor Details
#initialize(syntax = nil) ⇒ ClangTypeChecker
Returns a new instance of ClangTypeChecker.
59 60 61 62 63 |
# File 'lib/yadriggy/c/ctypecheck.rb', line 59 def initialize(syntax=nil) super(syntax || C::syntax) @local_vars_table = {} @instance_variables = Set.new end |
Instance Attribute Details
#instance_variables ⇒ Set<IvarObj> (readonly)
Returns accessed instance variables.
57 58 59 |
# File 'lib/yadriggy/c/ctypecheck.rb', line 57 def instance_variables @instance_variables end |
Instance Method Details
#is_subsumed_by?(sub_type, super_type) ⇒ Boolean
78 79 80 81 |
# File 'lib/yadriggy/c/ctypecheck.rb', line 78 def is_subsumed_by?(sub_type, super_type) (valid_var_type?(sub_type) && valid_var_type?(super_type)) || sub_type <= super_type end |
#method_with_block?(name) ⇒ Boolean
Specifies the names of methods with a block.
321 322 323 |
# File 'lib/yadriggy/c/ctypecheck.rb', line 321 def method_with_block?(name) name == 'times' end |
#typecheck_call_with_block(call_ast) ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/yadriggy/c/ctypecheck.rb', line 325 def typecheck_call_with_block(call_ast) type_assert(ast.name.name == 'times', "no such method: #{ast.name.name}") type_assert(type(ast.receiver) == RubyClass::Integer, 'the receiver must be an integer') type_assert(ast.block.params.size == 1, "wrong number of block parameters") type_as(ast.block.params[0], RubyClass::Integer) tenv = type_env.new_tenv tenv.bind_name(ast.block.params[0], RubyClass::Integer) tenv.bind_name(:return, Void) type(ast.block, tenv) Void end |