Class: Ikra::Translator::ArrayCommandStructBuilder::RequireRuntimeSizeChecker

Inherits:
Symbolic::Visitor show all
Defined in:
lib/translator/array_command_struct_builder.rb

Overview

This class determines if a ‘size` instance method should be generated for an array_command struct type. This is the case iff struct, or its first input, or the first input of its first input, etc., is an ArrayInHostSectionCommand. The size of such arrays is in general not known at compile time.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Symbolic::Visitor

#visit_array_combine_command, #visit_array_host_section_command, #visit_array_index_command, #visit_array_select_command, #visit_array_stencil_command, #visit_array_zip_command

Class Method Details

.require_size_function?(command) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/translator/array_command_struct_builder.rb', line 50

def self.require_size_function?(command)
    return command.accept(self.new)
end

Instance Method Details

#visit_array_command(command) ⇒ Object



74
75
76
77
78
79
80
# File 'lib/translator/array_command_struct_builder.rb', line 74

def visit_array_command(command)
    if command.input.size == 0
        return false
    else
        return command.input.first.command.accept(self)
    end
end

#visit_array_identity_command(command) ⇒ Object



59
60
61
62
# File 'lib/translator/array_command_struct_builder.rb', line 59

def visit_array_identity_command(command)
    # Fully fused, size known at compile time
    return false
end

#visit_array_in_host_section_command(command) ⇒ Object



64
65
66
67
# File 'lib/translator/array_command_struct_builder.rb', line 64

def visit_array_in_host_section_command(command)
    # Cannot be fused, size unknown at compile time
    return true
end

#visit_array_reduce_command(command) ⇒ Object



54
55
56
57
# File 'lib/translator/array_command_struct_builder.rb', line 54

def visit_array_reduce_command(command)
    # Size is always 1
    return false
end

#visit_fixed_size_array_in_host_section_command(command) ⇒ Object



69
70
71
72
# File 'lib/translator/array_command_struct_builder.rb', line 69

def visit_fixed_size_array_in_host_section_command(command)
    # Size is part of the type/command
    return false
end