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) | ||||
|         int1      = literal('1') | ||||
|         index     = on_int(predicate) | ||||
|         index     = to_int(predicate) | ||||
|         index_var = literal('index') | ||||
| 
 | ||||
|         inner = process(test, input) do |matched_test_node| | ||||
|  | @ -293,7 +293,7 @@ module Oga | |||
|       # @param [Oga::Ruby::Node] input | ||||
|       # @return [Oga::Ruby::Node] | ||||
|       def on_int(ast, *) | ||||
|         literal(ast.children[0].to_i.to_s) | ||||
|         literal(ast.children[0].to_f.to_s) | ||||
|       end | ||||
| 
 | ||||
|       # @param [AST::Node] ast | ||||
|  | @ -382,6 +382,12 @@ module Oga | |||
|         literal('variables') | ||||
|       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 | ||||
|       # @return [TrueClass|FalseClass] | ||||
|       def number?(ast) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue