mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	forwardable/impl.rb
* lib/forwardable/impl.rb (_valid_method?, _compile_method): extract to separate implementation specific part. [ruby-core:78138] [Bug #12938] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									fb8628ecda
								
							
						
					
					
						commit
						2283d14cc9
					
				
					 4 changed files with 50 additions and 15 deletions
				
			
		
							
								
								
									
										1
									
								
								ext/rubyvm/extconf.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								ext/rubyvm/extconf.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1 @@
 | 
			
		|||
create_makefile("rubyvm")
 | 
			
		||||
							
								
								
									
										19
									
								
								ext/rubyvm/lib/forwardable/impl.rb
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								ext/rubyvm/lib/forwardable/impl.rb
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,19 @@
 | 
			
		|||
# :stopdoc:
 | 
			
		||||
module Forwardable
 | 
			
		||||
  FILTER_EXCEPTION = ""
 | 
			
		||||
 | 
			
		||||
  def self._valid_method?(method)
 | 
			
		||||
    iseq = RubyVM::InstructionSequence.compile("().#{method}", nil, nil, 0, false)
 | 
			
		||||
  rescue SyntaxError => e
 | 
			
		||||
    false
 | 
			
		||||
  else
 | 
			
		||||
    iseq.to_a.dig(-1, 1, 1, :mid) == method.to_sym
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def self._compile_method(src, file, line)
 | 
			
		||||
    RubyVM::InstructionSequence.compile(src, file, file, line,
 | 
			
		||||
               trace_instruction: false,
 | 
			
		||||
               tailcall_optimization: true)
 | 
			
		||||
      .eval
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue