Class: Yadriggy::C::OclTypeChecker
- Inherits:
-
ClangTypeChecker
- Object
- Yadriggy::Checker
- TypeChecker
- RubyTypeChecker
- RubyTypeInferer
- ClangTypeChecker
- Yadriggy::C::OclTypeChecker
- Defined in:
- lib/yadriggy/c/opencl.rb
Constant Summary
Constants included from CType
CType::Float32Array, CType::FloatArray, CType::Int, CType::IntArray, CType::Void
Constants included from Yadriggy
Instance Attribute Summary collapse
-
#blocks ⇒ Hash<Block,Tuple<String,Hash<Symbol,Type>,Set<Object>>] a map to tuples of a block name, ...
readonly
A map from blocks to their names and free variables.
Attributes inherited from ClangTypeChecker
#instance_variables, #local_vars_table
Instance Method Summary collapse
-
#initialize(syntax = nil) ⇒ OclTypeChecker
constructor
A new instance of OclTypeChecker.
- #method_with_block?(name) ⇒ Boolean
- #typecheck_call_with_block(ast) ⇒ Object
Methods inherited from ClangTypeChecker
#is_subsumed_by?, #valid_type?, #valid_var_type?
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) ⇒ OclTypeChecker
Returns a new instance of OclTypeChecker.
88 89 90 91 92 |
# File 'lib/yadriggy/c/opencl.rb', line 88 def initialize(syntax=nil) super(syntax) @blocks = {} @block_count = 0 end |
Instance Attribute Details
Instance Method Details
#method_with_block?(name) ⇒ Boolean
94 95 96 |
# File 'lib/yadriggy/c/opencl.rb', line 94 def method_with_block?(name) super || name == 'ocl_times' end |
#typecheck_call_with_block(ast) ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/yadriggy/c/opencl.rb', line 98 def typecheck_call_with_block(ast) if ast.name.name == 'ocl_times' 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") tenv = FreeVarFinder.new(type_env) type_as(ast.block.params[0], RubyClass::Integer) tenv.bind_name(ast.block.params[0], RubyClass::Integer) tenv.bind_name(:return, Void) old_ins_vars = @instance_variables @instance_variables = Set.new type(ast.block, tenv) captured_ins_vars = @instance_variables @instance_variables = old_ins_vars @instance_variables += captured_ins_vars @blocks[ast.block] = ["block#{@block_count}", tenv.free_variables, captured_ins_vars] @block_count += 1 Void else super end end |