(***********************************************************************)
(*                                                                     *)
(*                                 GALAX                               *)
(*                              XQuery Engine                          *)
(*                                                                     *)
(*  Copyright 2001-2003, Lucent Technologies.                          *)
(*  Distributed only by permission.                                    *)
(*                                                                     *)
(***********************************************************************)

(* $Id: eval_util.mli,v 1.2 2003/05/28 14:47:38 simeon Exp $ *)

(* Module Eval_util
   Description:
     This module contains some auxiliary evaluation functions, notably
     for function calls, type declarations, axis, element and
     attribute construction.
*)


(* Auxiliary functions for typeswitch *)

val of_type :
    Static_context.static_context -> Datamodel._Item Datamodel._Sequence -> Xquery_ast.datatype -> bool

(* Auxiliary functions for casting *)

val cast_to_elem_symbol : Datamodel._Item Datamodel._Sequence -> Sym.relem_symbol
val cast_to_attr_symbol : Datamodel._Item Datamodel._Sequence -> Sym.rattr_symbol

val cast_to_bool        : Datamodel._Item Datamodel._Sequence -> Datatypes.xs_boolean

(* Auxiliary functions for XPath navigation *)

val eval_axis      : Xquery_ast.axis -> Datamodel._Node -> Datamodel._Node  list

val eval_node_test : Xquery_ast.axis -> Xquery_ast.cnode_test -> Datamodel._Node -> bool

(* Auxiliary functions for sorting *)

val forest_compare :
  Xquery_ast.sortkind ->
  Xquery_ast.emptysortkind -> Datamodel._Value -> Datamodel._Value -> int

(* Auxiliary functions for function calls *)

val match_function_signature :
    Static_context.static_context ->
      Finfo.finfo ->
	Namespace.rqname ->
	  Datamodel._Item Datamodel._Sequence list ->
	    (Xquery_ast.rfname * Xquery_ast.cfunction_signature) list ->
	      Xquery_ast.rfname * Datamodel._Value list

val dynamic_type_check :
    Static_context.static_context -> 
      Finfo.finfo ->
	Xquery_ast.datatype option -> Datamodel._Value -> Datamodel._Value
	    
(* Auxiliary functions for constructors *)

val element_constructor :
    Datamodel._ElemName ->
      Datamodel._Value -> Datamodel._Item Datamodel._Sequence

val attribute_constructor :
    Datamodel._AttrName ->
      Datamodel._Value -> Datamodel._Item Datamodel._Sequence

