class Yadriggy::C::OclTypeChecker
Attributes
blocks[R]
A map from blocks to their names and free variables.
@return [Hash<Block,Tuple<String,Hash<Symbol,Type>,Set<Object>>]
a map to tuples of a block name, free variables, and instance variables accessed in the block.
Public Class Methods
new(syntax=nil)
click to toggle source
Calls superclass method
Yadriggy::C::ClangTypeChecker::new
# File lib/yadriggy/c/opencl.rb, line 88 def initialize(syntax=nil) super(syntax) @blocks = {} @block_count = 0 end
Public Instance Methods
method_with_block?(name)
click to toggle source
Calls superclass method
Yadriggy::C::ClangTypeChecker#method_with_block?
# File lib/yadriggy/c/opencl.rb, line 94 def method_with_block?(name) super || name == 'ocl_times' end
typecheck_call_with_block(ast)
click to toggle source
Calls superclass method
Yadriggy::C::ClangTypeChecker#typecheck_call_with_block
# 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