Class: Ikra::Symbolic::StencilSingleInput
- Defined in:
- lib/symbolic/input.rb,
lib/symbolic/input_visitor.rb,
lib/translator/input_translator.rb,
lib/types/inference/input_inference.rb
Instance Attribute Summary collapse
-
#offsets ⇒ Object
readonly
Returns the value of attribute offsets.
-
#out_of_bounds_value ⇒ Object
readonly
Returns the value of attribute out_of_bounds_value.
Attributes inherited from Input
Instance Method Summary collapse
- #==(other) ⇒ Object
- #accept(visitor) ⇒ Object
- #get_parameters(parent_command:, start_eat_params_offset: 0) ⇒ Object
-
#initialize(command:, pattern:, offsets:, out_of_bounds_value:) ⇒ StencilSingleInput
constructor
A new instance of StencilSingleInput.
- #translate_input(parent_command:, command_translator:, start_eat_params_offset: 0) ⇒ Object
Methods inherited from Input
Constructor Details
#initialize(command:, pattern:, offsets:, out_of_bounds_value:) ⇒ StencilSingleInput
Returns a new instance of StencilSingleInput.
65 66 67 68 69 70 71 |
# File 'lib/symbolic/input.rb', line 65 def initialize(command:, pattern:, offsets:, out_of_bounds_value:) super(pattern: pattern) @command = command @offsets = offsets @out_of_bounds_value = out_of_bounds_value end |
Instance Attribute Details
#offsets ⇒ Object (readonly)
Returns the value of attribute offsets.
62 63 64 |
# File 'lib/symbolic/input.rb', line 62 def offsets @offsets end |
#out_of_bounds_value ⇒ Object (readonly)
Returns the value of attribute out_of_bounds_value.
63 64 65 |
# File 'lib/symbolic/input.rb', line 63 def out_of_bounds_value @out_of_bounds_value end |
Instance Method Details
#==(other) ⇒ Object
73 74 75 76 77 |
# File 'lib/symbolic/input.rb', line 73 def ==(other) return super(other) && offsets == other.offsets && out_of_bounds_value == other.out_of_bounds_value end |
#accept(visitor) ⇒ Object
25 26 27 |
# File 'lib/symbolic/input_visitor.rb', line 25 def accept(visitor) visitor.visit_stencil_single_input(self, pattern: pattern) end |
#get_parameters(parent_command:, start_eat_params_offset: 0) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/types/inference/input_inference.rb', line 42 def get_parameters(parent_command:, start_eat_params_offset: 0) # Pass separate parameters # Count number of parameters num_parameters = parent_command.offsets.size # Take return type from previous computation parameters = [] for index in start_eat_params_offset...(start_eat_params_offset + num_parameters) parameters.push(Translator::Variable.new( name: parent_command.block_parameter_names[index], type: command.result_type)) end return parameters end |
#translate_input(parent_command:, command_translator:, start_eat_params_offset: 0) ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/translator/input_translator.rb', line 91 def translate_input(parent_command:, command_translator:, start_eat_params_offset: 0) # Pass separate parameters # Translate input using visitor input_command_translation_result = command_translator.translate_input(self) # Count number of parameters num_parameters = parent_command.offsets.size # Take return type from previous computation parameters = [] for index in start_eat_params_offset...(start_eat_params_offset + num_parameters) parameters.push(Translator::Variable.new( name: parent_command.block_parameter_names[index], type: input_command_translation_result.result_type)) end return Translator::InputTranslationResult.new( parameters: parameters, command_translation_result: input_command_translation_result) end |