Class: SorobanRustBackend::Instruction::InstantiateObject
- Defined in:
- lib/instruction/instantiate_object.rb
Overview
This class is responsible for generating Rust code for the LogString instruction.
Instance Method Summary collapse
Methods inherited from Handler
#format_assign, handle, #initialize
Constructor Details
This class inherits a constructor from SorobanRustBackend::Instruction::Handler
Instance Method Details
#handle ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/instruction/instantiate_object.rb', line 5 def handle @ref_preface = false if @instruction.inputs[0] == '&' @ref_preface = true @instruction.inputs.shift end case @instruction.inputs[0] when 'List' handle_list when 'UDT' handle_udt when 'Tuple' if @instruction.assign.include?('.') || @instruction.assign == 'Thing_to_return' "#{@instruction.assign} = #{@ref_preface ? '&' : ''}(#{normalish_inputs});" else "let mut #{@instruction.assign} = #{@ref_preface ? '&' : ''}(#{normalish_inputs});" end when 'Range' if @instruction.assign.include?('.') || @instruction.assign == 'Thing_to_return' "#{@instruction.assign} = #{@ref_preface ? '&' : ''}#{range_inputs};" else "let mut #{@instruction.assign} = #{@ref_preface ? '&' : ''}#{range_inputs};" end else raise "Unknown object type: #{@instruction.inputs[0]}" end end |