Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

eval.h File Reference

#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "evaltype.h"
#include "lex.h"
#include "evalx.h"

Go to the source code of this file.

Defines

#define MAX_FUNCNAME_LEN   16
#define MAX_SYMBOLNAME_LEN   32
#define MAX_ERRSTR_LEN   128
#define DEBUG_DUMP(text...)
#define DEBUG_DUMP_SCALAR(scalarptr, text...)
#define DEBUG_DUMP_SCALARLIST(scalarlistptr, text...)
#define DEBUG_DUMP_INDENT_IN
#define DEBUG_DUMP_INDENT_OUT

Typedefs

typedef int(* eval_func_handler )(eval_scalar *result, char *name, eval_scalarlist *params)
typedef int(* eval_symbol_handler )(eval_scalar *result, char *name)

Functions

void clear_eval_error ()
int get_eval_error (char **str, int *pos)
void set_eval_error (char *format,...)
void set_eval_error_ex (int pos, char *format,...)
void string_destroy (eval_str *s)
void scalarlist_set (eval_scalarlist *l, eval_scalar *s)
void scalarlist_concat (eval_scalarlist *l, eval_scalarlist *a, eval_scalarlist *b)
void scalarlist_destroy (eval_scalarlist *l)
void scalarlist_destroy_gentle (eval_scalarlist *l)
void scalar_setint (eval_scalar *s, eval_int *i)
void scalar_setstr (eval_scalar *s, eval_str *t)
void scalar_create_int (eval_scalar *result, const eval_int *t)
void scalar_create_int_c (eval_scalar *result, const int i)
void scalar_create_int_q (eval_scalar *result, const qword q)
void scalar_create_str (eval_scalar *result, const eval_str *t)
void scalar_create_str_c (eval_scalar *result, const char *cstr)
void scalar_create_float (eval_scalar *result, const eval_float *t)
void scalar_create_float_c (eval_scalar *result, const double f)
void scalar_clone (eval_scalar *result, const eval_scalar *s)
void scalar_context_str (const eval_scalar *s, eval_str *t)
void scalar_context_int (const eval_scalar *s, eval_int *t)
void scalar_context_float (const eval_scalar *s, eval_float *t)
void string_concat (eval_str *s, eval_str *a, eval_str *b)
void scalar_concat (eval_scalar *s, const eval_scalar *a, const eval_scalar *b)
void scalar_destroy (eval_scalar *s)
int string_compare (const eval_str *a, const eval_str *b)
int scalar_strop (eval_scalar *xr, const eval_scalar *xa, const eval_scalar *xb, int op)
int scalar_float_op (eval_scalar *xr, const eval_scalar *xa, const eval_scalar *xb, int op)
int scalar_int_op (eval_scalar *xr, const eval_scalar *xa, const eval_scalar *xb, int op)
int scalar_op (eval_scalar *xr, eval_scalar *xa, eval_scalar *xb, int op)
void scalar_negset (eval_scalar *xr, eval_scalar *xa)
void scalar_notset (eval_scalar *xr, eval_scalar *xa)
void scalar_lnotset (eval_scalar *xr, eval_scalar *xa)
void scalar_miniif (eval_scalar *xr, eval_scalar *xa, eval_scalar *xb, eval_scalar *xc)
void sprintf_puts (char **b, char *blimit, char *buf)
int sprintf_percent (char **fmt, int *fmtl, char **b, char *blimit, eval_scalar *s)
int func_sprintf (eval_scalar *r, const eval_str *format, const eval_scalarlist *scalars)
int func_eval (eval_scalar *r, eval_str *p)
int func_error (eval_scalar *r, eval_str *s)
eval_protomatch match_evalfunc_proto (char *name, eval_scalarlist *params, eval_func *proto)
int exec_evalfunc (eval_scalar *r, eval_scalarlist *params, eval_func *proto)
int evalsymbol (eval_scalar *r, char *sname)
int std_eval_func_handler (eval_scalar *r, char *fname, eval_scalarlist *params, eval_func *protos)
int evalfunc (eval_scalar *r, char *fname, eval_scalarlist *params)
void * eval_get_context ()
void eval_set_context (void *context)
void eval_set_func_handler (eval_func_handler func_handler)
void eval_set_symbol_handler (eval_symbol_handler symbol_handler)


Define Documentation

#define DEBUG_DUMP text...   ) 
 

Definition at line 203 of file eval.h.

Referenced by eval(), and exec_evalfunc().

#define DEBUG_DUMP_INDENT_IN
 

Definition at line 206 of file eval.h.

Referenced by eval(), and exec_evalfunc().

#define DEBUG_DUMP_INDENT_OUT
 

Definition at line 207 of file eval.h.

Referenced by eval(), and exec_evalfunc().

#define DEBUG_DUMP_SCALAR scalarptr,
text...   ) 
 

Definition at line 204 of file eval.h.

Referenced by eval(), and exec_evalfunc().

#define DEBUG_DUMP_SCALARLIST scalarlistptr,
text...   ) 
 

Definition at line 205 of file eval.h.

Referenced by exec_evalfunc().

#define MAX_ERRSTR_LEN   128
 

Definition at line 60 of file eval.h.

Referenced by exec_evalfunc().

#define MAX_FUNCNAME_LEN   16
 

Definition at line 58 of file eval.h.

Referenced by evalfunc(), set_helpmode(), and std_eval_func_handler().

#define MAX_SYMBOLNAME_LEN   32
 

Definition at line 59 of file eval.h.

Referenced by evalsymbol().


Typedef Documentation

typedef int(* eval_func_handler)(eval_scalar *result, char *name, eval_scalarlist *params)
 

Definition at line 42 of file eval.h.

Referenced by dialog_eval_help(), eval(), and eval_set_func_handler().

typedef int(* eval_symbol_handler)(eval_scalar *result, char *name)
 

Definition at line 43 of file eval.h.

Referenced by dialog_eval_help(), eval(), and eval_set_symbol_handler().


Function Documentation

void clear_eval_error  ) 
 

Definition at line 155 of file eval.cc.

Referenced by eval().

void* eval_get_context  ) 
 

Definition at line 1565 of file eval.cc.

Referenced by ht_linear_func_readbyte(), ht_linear_func_readstring(), and ht_linear_sub_symbol_handler().

void eval_set_context void *  context  ) 
 

Definition at line 1570 of file eval.cc.

Referenced by eval().

void eval_set_func_handler eval_func_handler  func_handler  ) 
 

Definition at line 1575 of file eval.cc.

References eval_func_handler.

Referenced by eval().

void eval_set_symbol_handler eval_symbol_handler  symbol_handler  ) 
 

Definition at line 1580 of file eval.cc.

References eval_symbol_handler.

Referenced by eval().

int evalfunc eval_scalar r,
char *  fname,
eval_scalarlist params
 

Definition at line 1541 of file eval.cc.

References get_eval_error(), MAX_FUNCNAME_LEN, NULL, set_eval_error(), and std_eval_func_handler().

Referenced by yyparse().

int evalsymbol eval_scalar r,
char *  sname
 

Definition at line 1448 of file eval.cc.

References get_eval_error(), MAX_SYMBOLNAME_LEN, NULL, and set_eval_error().

Referenced by yyparse().

int exec_evalfunc eval_scalar r,
eval_scalarlist params,
eval_func proto
 

Definition at line 1329 of file eval.cc.

References eval_scalarlist::count, DEBUG_DUMP, DEBUG_DUMP_INDENT_IN, DEBUG_DUMP_INDENT_OUT, DEBUG_DUMP_SCALAR, DEBUG_DUMP_SCALARLIST, eval_scalarbody::floatnum, eval_func::func, get_eval_error(), int(), eval_scalarbody::integer, malloc(), MAX_ERRSTR_LEN, MAX_EVALFUNC_PARAMS, eval_func::name, NULL, eval_func::ptype, eval_scalar::scalar, SCALAR_ANY, scalar_clone(), scalar_context_float(), scalar_context_int(), scalar_context_str(), scalar_destroy(), SCALAR_FLOAT, SCALAR_INT, SCALAR_NULL, SCALAR_STR, SCALAR_VARARGS, scalarlist_destroy_gentle(), eval_scalarlist::scalars, set_eval_error(), set_eval_error_ex(), eval_scalarbody::str, and eval_scalar::type.

Referenced by std_eval_func_handler().

int func_error eval_scalar r,
eval_str s
 

int func_eval eval_scalar r,
eval_str p
 

int func_sprintf eval_scalar r,
const eval_str format,
const eval_scalarlist scalars
 

int get_eval_error char **  str,
int *  pos
 

Definition at line 160 of file eval.cc.

Referenced by blockop_int_process(), blockop_str_process(), create_blockop_int_context(), create_blockop_str_context(), create_request_evalstr(), eval(), evalfunc(), evalsymbol(), exec_evalfunc(), ht_uformat_viewer::handlemsg(), process_search_expr(), and ht_format_viewer::string_to_qword().

eval_protomatch match_evalfunc_proto char *  name,
eval_scalarlist params,
eval_func proto
 

Definition at line 1311 of file eval.cc.

References eval_scalarlist::count, eval_protomatch, MAX_EVALFUNC_PARAMS, eval_func::name, PROTOMATCH_NAME_FAIL, PROTOMATCH_OK, PROTOMATCH_PARAM_FAIL, eval_func::ptype, SCALAR_NULL, and SCALAR_VARARGS.

Referenced by std_eval_func_handler().

void scalar_clone eval_scalar result,
const eval_scalar s
 

Definition at line 455 of file eval.cc.

References eval_str::len, malloc(), eval_scalar::scalar, SCALAR_FLOAT, SCALAR_INT, SCALAR_STR, eval_scalarbody::str, eval_scalar::type, and eval_str::value.

Referenced by exec_evalfunc().

void scalar_concat eval_scalar s,
const eval_scalar a,
const eval_scalar b
 

Definition at line 477 of file eval.cc.

References eval_scalar::scalar, scalar_context_str(), SCALAR_STR, eval_scalarbody::str, string_concat(), and eval_scalar::type.

Referenced by std_eval_func_handler(), and yyparse().

void scalar_context_float const eval_scalar s,
eval_float t
 

Definition at line 420 of file eval.cc.

References binstr2cstr(), eval_scalarbody::floatnum, eval_scalarbody::integer, eval_str::len, NULL, QWORD_GET_FLOAT, eval_scalar::scalar, SCALAR_FLOAT, SCALAR_INT, SCALAR_STR, eval_scalarbody::str, eval_scalar::type, eval_str::value, eval_int::value, and eval_float::value.

Referenced by exec_evalfunc(), and scalar_float_op().

void scalar_context_int const eval_scalar s,
eval_int t
 

Definition at line 396 of file eval.cc.

References binstr2cstr(), f2i(), eval_scalarbody::floatnum, eval_scalarbody::integer, eval_str::len, eval_scalar::scalar, SCALAR_FLOAT, SCALAR_INT, SCALAR_STR, eval_scalarbody::str, eval_int::type, eval_scalar::type, TYPE_UNKNOWN, eval_float::value, eval_int::value, and eval_str::value.

Referenced by blockop_int_process(), create_blockop_int_context(), exec_evalfunc(), ht_text_viewer::handlemsg(), ht_uformat_viewer::handlemsg(), process_search_expr(), scalar_int_op(), scalar_lnotset(), scalar_miniif(), scalar_negset(), scalar_notset(), and ht_format_viewer::string_to_qword().

void scalar_context_str const eval_scalar s,
eval_str t
 

Definition at line 367 of file eval.cc.

References buf, eval_scalarbody::floatnum, ht_snprintf(), eval_scalarbody::integer, eval_str::len, malloc(), eval_scalar::scalar, SCALAR_FLOAT, SCALAR_INT, SCALAR_STR, eval_scalarbody::str, eval_scalar::type, eval_float::value, eval_str::value, and eval_int::value.

Referenced by blockop_str_process(), create_blockop_str_context(), create_request_evalstr(), dialog_eval_help(), exec_evalfunc(), scalar_concat(), and scalar_strop().

void scalar_create_float eval_scalar result,
const eval_float t
 

Definition at line 355 of file eval.cc.

References eval_scalarbody::floatnum, eval_scalar::scalar, SCALAR_FLOAT, and eval_scalar::type.

Referenced by func_float().

void scalar_create_float_c eval_scalar result,
const double  f
 

Definition at line 361 of file eval.cc.

References eval_scalarbody::floatnum, eval_scalar::scalar, SCALAR_FLOAT, eval_scalar::type, and eval_float::value.

Referenced by ht_linear_func_entropy2().

void scalar_create_int eval_scalar result,
const eval_int t
 

Definition at line 319 of file eval.cc.

References eval_scalarbody::integer, eval_scalar::scalar, SCALAR_INT, and eval_scalar::type.

Referenced by func_int(), func_max(), and func_min().

void scalar_create_int_c eval_scalar result,
const int  i
 

Definition at line 325 of file eval.cc.

References eval_scalarbody::integer, eval_scalar::scalar, SCALAR_INT, to_sint64(), to_uint64(), eval_int::type, eval_scalar::type, TYPE_UNKNOWN, and eval_int::value.

Referenced by func_byte(), func_is_float(), func_is_int(), func_is_string(), func_long(), func_ord(), func_rnd(), func_sbyte(), func_short(), func_strchr(), func_strcmp(), func_strlen(), func_word(), ht_linear_func_entropy(), ht_linear_func_readbyte(), ht_linear_sub_symbol_handler(), ht_hex_viewer::symbol_handler(), and ht_disasm_viewer::symbol_handler().

void scalar_create_int_q eval_scalar result,
const qword  q
 

Definition at line 332 of file eval.cc.

References eval_scalarbody::integer, eval_scalar::scalar, SCALAR_INT, eval_int::type, eval_scalar::type, TYPE_UNKNOWN, and eval_int::value.

Referenced by func_dword(), func_random(), and ht_aviewer::symbol_handler().

void scalar_create_str eval_scalar result,
const eval_str t
 

Definition at line 339 of file eval.cc.

References eval_str::len, malloc(), eval_scalar::scalar, SCALAR_STR, eval_scalarbody::str, eval_scalar::type, and eval_str::value.

Referenced by func_char(), func_string(), func_substr(), ht_linear_func_readstring(), and scalar_create_str_c().

void scalar_create_str_c eval_scalar result,
const char *  cstr
 

Definition at line 347 of file eval.cc.

References eval_str::len, scalar_create_str(), and eval_str::value.

Referenced by func_substr(), func_typeof(), and std_eval_func_handler().

void scalar_destroy eval_scalar s  ) 
 

Definition at line 487 of file eval.cc.

References eval_scalar::scalar, SCALAR_STR, eval_scalarbody::str, string_destroy(), and eval_scalar::type.

Referenced by blockop_int_process(), blockop_str_process(), create_blockop_int_context(), create_blockop_str_context(), create_request_evalstr(), dialog_eval_help(), exec_evalfunc(), ht_uformat_viewer::handlemsg(), scalar_lnotset(), scalar_miniif(), scalar_negset(), scalar_notset(), scalar_op(), scalarlist_destroy(), std_eval_func_handler(), ht_format_viewer::string_to_qword(), and yyparse().

int scalar_float_op eval_scalar xr,
const eval_scalar xa,
const eval_scalar xb,
int  op
 

Definition at line 531 of file eval.cc.

References EVAL_EQ, EVAL_GE, EVAL_GT, EVAL_LAND, EVAL_LE, EVAL_LOR, EVAL_LT, EVAL_LXOR, EVAL_NE, EVAL_POW, eval_scalarbody::floatnum, eval_scalarbody::integer, eval_scalar::scalar, scalar_context_float(), SCALAR_FLOAT, SCALAR_INT, set_eval_error(), eval_int::type, eval_scalar::type, TYPE_UNKNOWN, eval_int::value, and eval_float::value.

Referenced by scalar_op().

int scalar_int_op eval_scalar xr,
const eval_scalar xa,
const eval_scalar xb,
int  op
 

Definition at line 580 of file eval.cc.

References EVAL_EQ, EVAL_GE, EVAL_GT, EVAL_LAND, EVAL_LE, EVAL_LOR, EVAL_LT, EVAL_LXOR, EVAL_NE, EVAL_POW, EVAL_SHL, EVAL_SHR, eval_scalarbody::integer, qword, qword_cmp(), QWORD_GET_LO, eval_scalar::scalar, scalar_context_int(), SCALAR_INT, set_eval_error(), eval_int::type, eval_scalar::type, TYPE_UNKNOWN, and eval_int::value.

Referenced by scalar_op().

void scalar_lnotset eval_scalar xr,
eval_scalar xa
 

Definition at line 680 of file eval.cc.

References eval_scalarbody::integer, eval_scalar::scalar, scalar_context_int(), scalar_destroy(), SCALAR_INT, eval_int::type, eval_scalar::type, TYPE_UNKNOWN, and eval_int::value.

Referenced by yyparse().

void scalar_miniif eval_scalar xr,
eval_scalar xa,
eval_scalar xb,
eval_scalar xc
 

Definition at line 692 of file eval.cc.

References scalar_context_int(), scalar_destroy(), and eval_int::value.

Referenced by yyparse().

void scalar_negset eval_scalar xr,
eval_scalar xa
 

Definition at line 649 of file eval.cc.

References eval_scalarbody::floatnum, eval_scalarbody::integer, eval_scalar::scalar, scalar_context_int(), scalar_destroy(), SCALAR_FLOAT, SCALAR_INT, eval_int::type, eval_scalar::type, TYPE_UNKNOWN, eval_int::value, and eval_float::value.

Referenced by yyparse().

void scalar_notset eval_scalar xr,
eval_scalar xa
 

Definition at line 668 of file eval.cc.

References eval_scalarbody::integer, eval_scalar::scalar, scalar_context_int(), scalar_destroy(), SCALAR_INT, eval_int::type, eval_scalar::type, TYPE_UNKNOWN, and eval_int::value.

Referenced by yyparse().

int scalar_op eval_scalar xr,
eval_scalar xa,
eval_scalar xb,
int  op
 

Definition at line 636 of file eval.cc.

References scalar_destroy(), SCALAR_FLOAT, scalar_float_op(), scalar_int_op(), and eval_scalar::type.

Referenced by yyparse().

void scalar_setint eval_scalar s,
eval_int i
 

Definition at line 283 of file eval.cc.

References eval_scalarbody::integer, eval_scalar::scalar, SCALAR_INT, and eval_scalar::type.

void scalar_setstr eval_scalar s,
eval_str t
 

Definition at line 289 of file eval.cc.

References eval_scalar::scalar, SCALAR_STR, eval_scalarbody::str, and eval_scalar::type.

int scalar_strop eval_scalar xr,
const eval_scalar xa,
const eval_scalar xb,
int  op
 

Definition at line 506 of file eval.cc.

References EVAL_STR_EQ, EVAL_STR_GE, EVAL_STR_GT, EVAL_STR_LE, EVAL_STR_LT, EVAL_STR_NE, eval_scalarbody::integer, eval_scalar::scalar, scalar_context_str(), SCALAR_INT, string_compare(), eval_int::type, eval_scalar::type, TYPE_UNKNOWN, and eval_int::value.

Referenced by yyparse().

void scalarlist_concat eval_scalarlist l,
eval_scalarlist a,
eval_scalarlist b
 

Definition at line 240 of file eval.cc.

References eval_scalarlist::count, malloc(), and eval_scalarlist::scalars.

Referenced by yyparse().

void scalarlist_destroy eval_scalarlist l  ) 
 

Definition at line 248 of file eval.cc.

References eval_scalarlist::count, scalar_destroy(), and eval_scalarlist::scalars.

Referenced by yyparse().

void scalarlist_destroy_gentle eval_scalarlist l  ) 
 

Definition at line 259 of file eval.cc.

References eval_scalarlist::scalars.

Referenced by exec_evalfunc(), and yyparse().

void scalarlist_set eval_scalarlist l,
eval_scalar s
 

Definition at line 233 of file eval.cc.

References eval_scalarlist::count, malloc(), and eval_scalarlist::scalars.

Referenced by yyparse().

void set_eval_error char *  format,
... 
 

Definition at line 172 of file eval.cc.

References ht_vsnprintf(), and lex_current_buffer_pos().

Referenced by evalfunc(), evalsymbol(), exec_evalfunc(), func_ord(), ht_linear_func_readbyte(), ht_linear_func_readstring(), scalar_float_op(), scalar_int_op(), std_eval_func_handler(), ht_aviewer::symbol_handler(), and yyerror().

void set_eval_error_ex int  pos,
char *  format,
... 
 

Definition at line 183 of file eval.cc.

References ht_vsnprintf().

Referenced by exec_evalfunc().

int sprintf_percent char **  fmt,
int *  fmtl,
char **  b,
char *  blimit,
eval_scalar s
 

void sprintf_puts char **  b,
char *  blimit,
char *  buf
 

int std_eval_func_handler eval_scalar r,
char *  fname,
eval_scalarlist params,
eval_func protos
 

Definition at line 1499 of file eval.cc.

References buf, exec_evalfunc(), match_evalfunc_proto(), MAX_FUNCNAME_LEN, eval_func::name, PROTOMATCH_OK, PROTOMATCH_PARAM_FAIL, scalar_concat(), scalar_create_str_c(), scalar_destroy(), and set_eval_error().

Referenced by evalfunc(), ht_xbe_aviewer::func_handler(), ht_pe_aviewer::func_handler(), ht_aviewer::func_handler(), and ht_linear_sub_func_handler().

int string_compare const eval_str a,
const eval_str b
 

Definition at line 498 of file eval.cc.

References eval_str::len, and eval_str::value.

Referenced by scalar_strop().

void string_concat eval_str s,
eval_str a,
eval_str b
 

Definition at line 442 of file eval.cc.

References eval_str::len, malloc(), and eval_str::value.

Referenced by scalar_concat().

void string_destroy eval_str s  ) 
 

Definition at line 224 of file eval.cc.

References eval_str::value.

Referenced by blockop_str_process(), dialog_eval_help(), scalar_destroy(), and ht_blockop_str_context::~ht_blockop_str_context().


Generated on Fri May 7 21:15:47 2004 by doxygen 1.3.5