Cast compiled predicate indexes to integers
This commit is contained in:
		
							parent
							
								
									1f2545c03b
								
							
						
					
					
						commit
						bea7e19d57
					
				|  | @ -211,7 +211,7 @@ module Oga | ||||||
|       # |       # | ||||||
|       def index_predicate(test, predicate, input) |       def index_predicate(test, predicate, input) | ||||||
|         int1      = literal('1') |         int1      = literal('1') | ||||||
|         index     = on_int(predicate) |         index     = to_int(predicate) | ||||||
|         index_var = literal('index') |         index_var = literal('index') | ||||||
| 
 | 
 | ||||||
|         inner = process(test, input) do |matched_test_node| |         inner = process(test, input) do |matched_test_node| | ||||||
|  | @ -293,7 +293,7 @@ module Oga | ||||||
|       # @param [Oga::Ruby::Node] input |       # @param [Oga::Ruby::Node] input | ||||||
|       # @return [Oga::Ruby::Node] |       # @return [Oga::Ruby::Node] | ||||||
|       def on_int(ast, *) |       def on_int(ast, *) | ||||||
|         literal(ast.children[0].to_i.to_s) |         literal(ast.children[0].to_f.to_s) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       # @param [AST::Node] ast |       # @param [AST::Node] ast | ||||||
|  | @ -382,6 +382,12 @@ module Oga | ||||||
|         literal('variables') |         literal('variables') | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|  |       # @param [AST::Node] ast | ||||||
|  |       # @return [Oga::Ruby::Node] | ||||||
|  |       def to_int(ast) | ||||||
|  |         literal(ast.children[0].to_i.to_s) | ||||||
|  |       end | ||||||
|  | 
 | ||||||
|       # @param [AST::Node] ast |       # @param [AST::Node] ast | ||||||
|       # @return [TrueClass|FalseClass] |       # @return [TrueClass|FalseClass] | ||||||
|       def number?(ast) |       def number?(ast) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue