Cast compiled predicate indexes to integers

This commit is contained in:
Yorick Peterse 2015-07-24 00:30:20 +02:00
parent 1f2545c03b
commit bea7e19d57
1 changed files with 8 additions and 2 deletions

View File

@ -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)