Class: Ikra::Symbolic::ArrayHostSectionCommand

Inherits:
Object
  • Object
show all
Includes:
ArrayCommand
Defined in:
lib/symbolic/host_section.rb,
lib/symbolic/visitor.rb

Overview

The return value of a host section. For the moment, every host section can only have one result.

Defined Under Namespace

Classes: Binding

Instance Attribute Summary collapse

Attributes included from ArrayCommand

#block_size, #generator_node, #gpu_result_pointer, #input, #keep, #unique_id

Instance Method Summary collapse

Methods included from ArrayCommand

#==, #[], #block_parameter_names, #command_binding, #dimensions, #each, #eql?, #execute, #externals, #has_previous_result?, #hash, #ikra_type, included, #lexical_externals, #pack, #post_execute, reset_unique_id, #result_type, #set_unique_id, #to_c_type, #to_command, #to_ffi_type, #to_ruby_type, #to_s, #with_index

Methods included from Types::RubyType

#class_id, #eql?, #hash, #inspect, #is_primitive?, #is_union_type?, #should_generate_self_arg?, #to_array_type, #to_c_type, #to_ruby_type, #to_str, #to_union_type

Methods included from ParallelOperations

#&, #*, #+, #-, #/, #<, #<=, #>, #>=, #^, #pcombine, #pmap, #preduce, #pstencil, #pzip, #|

Constructor Details

#initialize(*section_input, &block) ⇒ ArrayHostSectionCommand

Returns a new instance of ArrayHostSectionCommand.



13
14
15
16
# File 'lib/symbolic/host_section.rb', line 13

def initialize(*section_input, &block)
    @block = block
    @section_input = section_input
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



10
11
12
# File 'lib/symbolic/host_section.rb', line 10

def block
  @block
end

#section_inputObject (readonly)

Returns the value of attribute section_input.



11
12
13
# File 'lib/symbolic/host_section.rb', line 11

def section_input
  @section_input
end

Instance Method Details

#accept(visitor) ⇒ Object



46
47
48
# File 'lib/symbolic/visitor.rb', line 46

def accept(visitor)
    visitor.visit_array_host_section_command(self)
end

#block_def_nodeObject

Returns the abstract syntax tree for this section.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/symbolic/host_section.rb', line 24

def block_def_node
    if @ast == nil
        # Get array of block parameter names
        block_params = block.parameters.map do |param|
            param[1]
        end

        parser_local_vars = command_binding.local_variables + block_params
        source = Parsing.parse_block(block, parser_local_vars)
        @ast = AST::BlockDefNode.new(
            parameters: block_params,
            ruby_block: block,      # necessary to get binding
            body: AST::HostSectionBuilder.from_parser_ast(source))
    end

    return @ast
end

#command_translator_classObject



42
43
44
# File 'lib/symbolic/host_section.rb', line 42

def command_translator_class
    return Translator::HostSectionCommandTranslator
end

#sizeObject



18
19
20
21
# File 'lib/symbolic/host_section.rb', line 18

def size
    execute
    return @result.size
end