module Expression: sig
.. end
Evaluation of binary operations and comparaison of values
Various helper functions for expression evaluation
Author(s): Tony BenBrahim < tony.benbrahim at gmail.com >
val list_of_array : Ast.runtime_variable_value -> Ast.runtime_variable_value list
Converts a MapValue array to a list of values
Returns a list of values
arr
: array
val string_of_value : Ast.runtime_variable_value -> string
Converts a value to a string
Returns a string representing the value
type
valuetype =
| |
IntegerType |
| |
FloatType |
| |
BooleanType |
| |
StringType |
| |
FunctionType |
| |
LibraryCallType |
| |
MapType |
| |
ArrayType |
| |
VoidType |
| |
NaNType |
| |
UndefinedType |
enumeration of a value's possible types
val value_type : Ast.runtime_variable_value -> valuetype
Returns a value's type
Returns the value's type
val string_of_value_type : Ast.runtime_variable_value -> string
returns a string name for a value's type
Returns string name for the value's type
type
cast_type =
| |
IntegerCast of int * int |
| |
FloatCast of float * float |
| |
StringCast of string * string |
| |
BoolCast of bool * bool |
type to hold the result of casting two values to the same type
val cast_to_integer : Ast.runtime_variable_value -> int
cast a value to an integer
Raises EInvalidCast
if the value cannot be cast
Returns an integer representation of the value
value
: the runtime value
val cast_to_float : Ast.runtime_variable_value -> float
cast a value to a float
Raises EInvalidCast
if the value cannot be cast
Returns an float representation of the value
value
: the runtime value
val evaluate_op : Ast.runtime_variable_value ->
Ast.runtime_variable_value -> Ast.operator -> Ast.runtime_variable_value
Evaluate the operation
Returns the value that results from the operation
value1
: the first value
value2
: the second value
operator
: the operator
val compare : Ast.runtime_variable_value ->
Ast.comparator -> Ast.runtime_variable_value -> Ast.runtime_variable_value
Implements comparaison of two values, according to the following semantics:
-Integer Integer Any Comparison of integer values
-Float Float Any Comparison of float values
-Float Integer Any Comparison of float values
-String any type Float comparison of first value to second value,
-Integer with non string values converted to strings
-Both types are Booleans,== and != comparison of first value to second value
-maps, arrays, functions,== and != comparison of first value to second value
-NaN or void == and != comparison of first value to second value
-Different types == always returns false != always returns true
Returns a boolean value type
v1
: the first value to compare
op
: the comparaison operator
v2
: the second value to compare
val opname : Ast.comparator -> string
val hashtbl_equal : (string, Ast.runtime_variable_value) Hashtbl.t ->
(string, Ast.runtime_variable_value) Hashtbl.t -> bool
val mismatched_compare : Ast.runtime_variable_value ->
Ast.comparator -> Ast.runtime_variable_value -> Ast.runtime_variable_value
val make_stackframe : int ->
int ->
bool ->
Ast.runtime_variable_value list ->
Ast.runtime_variable_value -> Ast.runtime_variable_value array
Makes a stack frame from the supplied value list
Returns a stack frame (an array of values)
size
: size of stack frame
vararg
: true if the last argument is a vararg, false otherwise
value_list
: list of values to add to the stack frame
this
: the value of this
val array_of_value_list : Ast.runtime_variable_value list -> Ast.runtime_variable_value
Creates an Array from a list of values
Returns a MapValue with the array
value_list
: a list of values