Class: Ikra::Symbolic::SingleInput

Inherits:
Input show all
Defined in:
lib/symbolic/input.rb,
lib/symbolic/input_visitor.rb,
lib/translator/input_translator.rb,
lib/types/inference/input_inference.rb

Overview

A single input value produced by one command.

Direct Known Subclasses

ReduceInput

Instance Attribute Summary

Attributes inherited from Input

#command, #pattern

Instance Method Summary collapse

Methods inherited from Input

#==, #eql?, #hash

Constructor Details

#initialize(command:, pattern:) ⇒ SingleInput

Returns a new instance of SingleInput.



34
35
36
37
38
# File 'lib/symbolic/input.rb', line 34

def initialize(command:, pattern:)
    super(pattern: pattern)

    @command = command
end

Instance Method Details

#accept(visitor) ⇒ Object



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

def accept(visitor)
    visitor.visit_single_input(self, pattern: pattern)
end

#get_parameters(parent_command:, start_eat_params_offset: 0) ⇒ Object



10
11
12
13
14
# File 'lib/types/inference/input_inference.rb', line 10

def get_parameters(parent_command:, start_eat_params_offset: 0)
    return [Translator::Variable.new(
        name: parent_command.block_parameter_names[start_eat_params_offset],
        type: command.result_type)]
end

#translate_input(parent_command:, command_translator:, start_eat_params_offset: 0) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/translator/input_translator.rb', line 10

def translate_input(parent_command:, command_translator:, start_eat_params_offset: 0)
    # Translate input using visitor
    input_command_translation_result = command_translator.translate_input(self)

    parameters = [Translator::Variable.new(
        name: parent_command.block_parameter_names[start_eat_params_offset],
        type: input_command_translation_result.result_type)]

    return Translator::InputTranslationResult.new(
        parameters: parameters,
        command_translation_result: input_command_translation_result)
end