Method: VCDOM::XPath::Internal::Evaluator#evaluate_equality_expr

Defined in:
lib/vcdom/xpath/internal/evaluator.rb

#evaluate_equality_expr(expr) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/vcdom/xpath/internal/evaluator.rb', line 50

def evaluate_equality_expr( expr )
  # TODO
  val_stack = Array.new()
  expr.each do |e|
    if e.is_value? or e.is_expr? then
      val_stack.push e
    else
      case e.command_type
      when :operation_unary
        operand = val_stack.pop
        val_stack.push operand.send( e.operation_name )
      when :operation_binary
        operand2 = val_stack.pop
        operand1 = val_stack.pop
        val_stack.push operand1.send( e.operation_name, operand2 )
      when :expr_eval
        val_stack.push evaluate_expr( e.expr )
      when :function_call
        args = Array.new()
        e.function_args.each do |arg_expr|
          args << evaluate_expr( arg_expr )
        end
        val_stack.push( call_function( e.function_name, args ) )
      when :node_selection
        target = val_stack.pop
        val_stack.push evaluate_node_selection( target, e )
      when :preds_eval
        target = val_stack.pop
        val_stack.push evaluate_preds( target, e.exprs )
      when :context_node
        val_stack.push create_node_set_value( context_node )
      when :root_node
        # TODO : context_node.class::DOCUMENT_NODE を書き換え
        root_node = ( context_node.node_type == context_node.class::DOCUMENT_NODE ? context_node : context_node.owner_document )
        val_stack.push create_node_set_value( root_node )
      else
        raise "NOT SUPPORTED"
      end
    end
  end
  raise "INTERNAL ERROR" if val_stack.length != 1
  return val_stack.pop
end