Class: Uinit::Sig::MethodCompiler

Inherits:
Uinit::Struct
  • Object
show all
Defined in:
lib/uinit/sig/method_compiler.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.compileObject



6
7
8
# File 'lib/uinit/sig/method_compiler.rb', line 6

def self.compile(...)
  new(...).compile
end

Instance Method Details

#compileObject



14
15
16
17
# File 'lib/uinit/sig/method_compiler.rb', line 14

def compile
  compile_arguments_check_method
  compile_wrapped_method
end

#compile_arguments_check_methodObject



19
20
21
22
23
24
25
26
# File 'lib/uinit/sig/method_compiler.rb', line 19

def compile_arguments_check_method
  compile_method(<<~RUBY, __FILE__, __LINE__ + 1)
    def __check_#{method.method_name}(#{compile_parameters_sig})
      __method__ = _signed_methods.#{method.signed_name}
      #{compile_parameters_check}
    end
  RUBY
end

#compile_wrapped_methodObject



28
29
30
31
32
33
34
35
36
# File 'lib/uinit/sig/method_compiler.rb', line 28

def compile_wrapped_method
  compile_method(<<~RUBY, __FILE__, __LINE__ + 1)
    def #{method.method_name}(...)
      method = _signed_methods.#{method.signed_name}
      __check_#{method.method_name}(...)
      #{compile_original_method_call}
    end
  RUBY
end