Class: SorobanRustBackend::FunctionHandler
- Inherits:
-
Object
- Object
- SorobanRustBackend::FunctionHandler
- Defined in:
- lib/function_handler.rb
Class Method Summary collapse
Instance Method Summary collapse
- #generate ⇒ Object
-
#initialize(function, is_helper, user_defined_types, function_names) ⇒ FunctionHandler
constructor
A new instance of FunctionHandler.
Constructor Details
#initialize(function, is_helper, user_defined_types, function_names) ⇒ FunctionHandler
Returns a new instance of FunctionHandler.
3 4 5 6 7 8 |
# File 'lib/function_handler.rb', line 3 def initialize(function, is_helper, user_defined_types, function_names) @function = function @is_helper = is_helper @user_defined_types = user_defined_types @function_names = function_names end |
Class Method Details
.generate(function, is_helper, user_defined_types, function_names) ⇒ Object
10 11 12 |
# File 'lib/function_handler.rb', line 10 def self.generate(function, is_helper, user_defined_types, function_names) new(function, is_helper, user_defined_types, function_names).generate end |
Instance Method Details
#generate ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/function_handler.rb', line 14 def generate content = "\n#{@is_helper ? '' : ' '}pub fn #{@function.name}(#{generate_function_args}) " content += generate_function_output content += " {\n" if @function.output content += "#{@is_helper ? ' ' : ' '}let mut Thing_to_return: #{Common::TypeTranslator.translate_type(@function.output)};\n" end content += generate_instructions_for_blocks(@function.instructions) content += "#{@is_helper ? '' : ' '}}\n" content end |