Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
exeval.c File Reference
#include <expr/exlib.h>
#include <expr/exop.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include <util/agxbuf.h>
#include <util/alloc.h>
#include <util/exit.h>
#include <util/gv_ctype.h>
#include <util/strview.h>
#include <util/unreachable.h>
Include dependency graph for exeval.c:

Go to the source code of this file.

Data Structures

struct  Fmt_t
 

Macros

#define TIME_LEN   80 /* max. characters to store time */
 
#define FRAME   64
 

Functions

static Extype_t eval (Expr_t *, Exnode_t *, void *)
 
static char * lexname (long op, int subop)
 
static int evaldyn (Expr_t *ex, Exnode_t *exnode, void *env, int delete)
 
static Extype_t getdyn (Expr_t *ex, Exnode_t *exnode, void *env, Exassoc_t **assoc)
 
static int prformat (void *vp, Sffmt_t *dp)
 
static int prints (Expr_t *ex, Exnode_t *exnode, void *env, FILE *sp)
 
static int print (Expr_t *ex, Exnode_t *exnode, void *env, FILE *sp)
 
static int scformat (void *vp, Sffmt_t *dp)
 
static int scan (Expr_t *ex, Exnode_t *exnode, void *env, FILE *sp)
 
static char * str_add (Expr_t *ex, char *l, char *r)
 
static char * str_ior (Expr_t *ex, const char *l, const char *r)
 
static char * str_and (Expr_t *ex, const char *l, const char *r)
 
static char * str_xor (Expr_t *ex, const char *l, const char *r)
 
static char * str_mod (Expr_t *ex, const char *l, const char *r)
 
static char * str_mpy (Expr_t *ex, const char *l, const char *r)
 
static void replace (agxbuf *s, char *base, char *repl, int ng, size_t *sub)
 
static void addItem (Dt_t *arr, Extype_t v, char *tok)
 
static Extype_t exsplit (Expr_t *ex, Exnode_t *exnode, void *env)
 
static Extype_t extokens (Expr_t *ex, Exnode_t *exnode, void *env)
 
static Extype_t exsub (Expr_t *ex, Exnode_t *exnode, void *env, bool global)
 
static Extype_t exsubstr (Expr_t *ex, Exnode_t *exnode, void *env)
 
static void xConvert (Expr_t *ex, Exnode_t *exnode, long type, Extype_t v, Exnode_t *tmp)
 
static void xPrint (Expr_t *ex, Exnode_t *exnode, Extype_t v, Exnode_t *tmp)
 
Extype_t exeval (Expr_t *ex, Exnode_t *exnode, void *env)
 
char * exstring (Expr_t *ex, char *s)
 
void * exstralloc (Expr_t *ex, size_t sz)
 

Variables

static long seed
 

Macro Definition Documentation

◆ FRAME

#define FRAME   64

Definition at line 43 of file exeval.c.

◆ TIME_LEN

#define TIME_LEN   80 /* max. characters to store time */

Definition at line 39 of file exeval.c.

Function Documentation

◆ addItem()

static void addItem ( Dt_t arr,
Extype_t  v,
char *  tok 
)
static

Definition at line 780 of file exeval.c.

References dtinsert, dtmatch, exerror(), Exassoc_s::key, EX_STYPE::string, tok(), and Exassoc_s::value.

Referenced by exsplit(), and extokens().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ eval()

static Extype_t eval ( Expr_t ex,
Exnode_t exnode,
void *  env 
)
static

Definition at line 1037 of file exeval.c.

References add(), AND, ARRAY, Exnode_s::binary, BREAK, BUILTIN, CALL, CONSTANT, Exdata_u::constant, CONTINUE, Exnode_s::data, DEC, drand48(), dtclear, dtfirst, dtlast, dtnext, dtprev, dtsize(), Exdata_u::dyna, DYNAMIC, elementsof, EQ, eval(), evaldyn(), EX_ARRAY, EX_CALL, EX_SCALAR, exerror(), exeval(), EXIT, exnospace(), exprintf(), exsplit(), exsub(), exsubstr(), extokens(), exzero(), F2I, F2S, F2X, FLOATING, EX_STYPE::floating, FOR, FRAME, free(), FUNCTION, GE, getdyn(), graphviz_exit(), GSUB, I2F, I2S, I2X, ID, IF, IN_OP, INC, Exdata_u::index, INTEGER, EX_STYPE::integer, ITERATE, ITERATOR, Exassoc_s::key, LE, left, Exdata_u::left, lexname(), Exid_s::local, LSH, Exassoc_s::name, Exid_s::name, NE, Exdata_u::next, NULL, Exnode_s::op, Exdata_u::operand, OR, PRE, print(), PRINT, PRINTF, prints(), RAND, Exdata_u::reference, RETURN, Exdata_u::right, right, RSH, S2B, S2F, S2I, S2X, scan(), SCANF, seed, Exdata_u::select, SPLIT, SPRINTF, SRAND, srand48, SSCANF, Exdata_u::statement, str, str_add(), str_and(), str_ior(), str_mod(), str_mpy(), str_xor(), STRING, EX_STYPE::string, strmatch(), SUB, SUBSTR, SWITCH, Exdata_u::symbol, TOKENS, Exnode_s::type, UNREACHABLE, UNSET, UNSIGNED, Exassoc_s::value, Exid_s::value, Exdata_u::value, Exdata_u::variable, Expr_s::vm, vmalloc(), vmfree(), vmstrdup(), WHILE, X2F, X2I, X2S, X2X, xConvert(), xPrint(), and XPRINT.

Referenced by eval(), evaldyn(), exeval(), exsplit(), exsub(), exsubstr(), extokens(), getdyn(), print(), prints(), and scan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evaldyn()

static int evaldyn ( Expr_t ex,
Exnode_t exnode,
void *  env,
int  delete 
)
static

Definition at line 73 of file exeval.c.

References BUILTIN, Exnode_s::data, dtdelete, dtmatch, eval(), free(), Exdata_u::index, Exid_s::index_type, INTEGER, EX_STYPE::integer, Exid_s::local, STRING, EX_STYPE::string, Exdata_u::symbol, type, Exnode_s::type, and Exdata_u::variable.

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exeval()

Extype_t exeval ( Expr_t ex,
Exnode_t exnode,
void *  env 
)

Definition at line 1965 of file exeval.c.

References Exnode_s::compiled, eval(), FLOATING, EX_STYPE::floating, Exnode_s::floating, EX_STYPE::integer, Exnode_s::integer, RETURN, STRING, EX_STYPE::string, Exnode_s::string, and Exnode_s::type.

Referenced by eval(), evalEdge(), evalNode(), gvpr_core(), and prformat().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exsplit()

static Extype_t exsplit ( Expr_t ex,
Exnode_t exnode,
void *  env 
)
static

Definition at line 797 of file exeval.c.

References addItem(), Exnode_s::data, eval(), exnospace(), EX_STYPE::integer, NULL, str, EX_STYPE::string, tok(), Expr_s::vm, and vmalloc().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exstralloc()

void * exstralloc ( Expr_t ex,
size_t  sz 
)

Definition at line 2008 of file exeval.c.

References vmalloc().

Referenced by bbOf(), toLower(), toUpper(), and xyOf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exstring()

char * exstring ( Expr_t ex,
char *  s 
)

Definition at line 2000 of file exeval.c.

References vmstrdup().

Referenced by bbOf(), canon(), colorx(), nameOf(), readLine(), and xyOf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exsub()

static Extype_t exsub ( Expr_t ex,
Exnode_t exnode,
void *  env,
bool  global 
)
static

Definition at line 891 of file exeval.c.

References agxbfree(), agxbput(), agxbput_n(), agxbuse(), Exnode_s::data, eval(), exwarn(), flags, replace(), str, STR_LEFT, STR_RIGHT, strgrpmatch(), EX_STYPE::string, sub, and vmstrdup().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ exsubstr()

static Extype_t exsubstr ( Expr_t ex,
Exnode_t exnode,
void *  env 
)
static

Definition at line 974 of file exeval.c.

References Exnode_s::data, eval(), exerror(), EX_STYPE::integer, len(), EX_STYPE::string, and vmalloc().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ extokens()

static Extype_t extokens ( Expr_t ex,
Exnode_t exnode,
void *  env 
)
static

Definition at line 850 of file exeval.c.

References addItem(), Exnode_s::data, eval(), exnospace(), EX_STYPE::integer, NULL, str, EX_STYPE::string, tok(), Expr_s::vm, and vmalloc().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getdyn()

static Extype_t getdyn ( Expr_t ex,
Exnode_t exnode,
void *  env,
Exassoc_t **  assoc 
)
static

Definition at line 112 of file exeval.c.

References BUILTIN, Exdata_u::constant, Exnode_s::data, dtinsert, dtmatch, eval(), exnospace(), exzero(), Exdata_u::index, Exid_s::index_type, INTEGER, EX_STYPE::integer, Exassoc_s::key, Exid_s::local, Exassoc_s::name, STRING, EX_STYPE::string, Exdata_u::symbol, type, Exid_s::type, Exnode_s::type, Exassoc_s::value, Exid_s::value, Exdata_u::value, and Exdata_u::variable.

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lexname()

static char * lexname ( long  op,
int  subop 
)
static

Definition at line 45 of file exeval.c.

References agxbdisown(), agxbprint(), exop(), gv_strdup(), MAXTOKEN, and MINTOKEN.

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prformat()

static int prformat ( void *  vp,
Sffmt_t dp 
)
static

Definition at line 181 of file exeval.c.

References Fmt_t::actuals, Print_s::arg, Fmt_t::args, copy(), Exnode_s::data, strview_t::data, Fmt_t::env, excast(), exerror(), exeval(), Fmt_t::expr, _sffmt_s::flags, FLOATING, EX_STYPE::floating, Fmt_t::fmt, _sffmt_s::fmt, fmtquote(), format, free(), gv_isalnum(), gv_isalpha(), gv_islower(), gv_isupper(), gv_tolower_str(), gv_toupper_str(), INTEGER, EX_STYPE::integer, Exdata_u::left, malloc(), _sffmt_s::n_str, NULL, Exdata_u::operand, Print_s::param, Exdata_u::right, SFFMT_VALUE, _sffmt_s::size, strview_t::size, STRING, EX_STYPE::string, strview_str_eq(), _sffmt_s::t_str, TIME_LEN, Exnode_s::type, UNSIGNED, Fmt_t::value, Expr_s::vm, vmalloc(), vmfree(), and vmstrdup().

Referenced by print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print()

static int print ( Expr_t ex,
Exnode_t exnode,
void *  env,
FILE *  sp 
)
static

Definition at line 373 of file exeval.c.

References Fmt_t::actuals, Print_s::arg, Fmt_t::args, Exnode_s::data, elementsof, Fmt_t::env, eval(), exerror(), Fmt_t::expr, _sffmt_s::extf, Expr_s::file, Fmt_t::fmt, _sffmt_s::form, Print_s::format, EX_STYPE::integer, Exdata_u::left, Print_s::next, Exdata_u::operand, prformat(), Exdata_u::right, sfprint(), and EX_STYPE::string.

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ prints()

static int prints ( Expr_t ex,
Exnode_t exnode,
void *  env,
FILE *  sp 
)
static

Definition at line 356 of file exeval.c.

References Exnode_s::data, eval(), Exdata_u::left, Exdata_u::operand, Exdata_u::right, and EX_STYPE::string.

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace()

static void replace ( agxbuf s,
char *  base,
char *  repl,
int  ng,
size_t *  sub 
)
static

Definition at line 757 of file exeval.c.

References agxbput_n(), agxbputc(), gv_isdigit(), offset, and sub.

Referenced by exsub().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scan()

static int scan ( Expr_t ex,
Exnode_t exnode,
void *  env,
FILE *  sp 
)
static

Definition at line 491 of file exeval.c.

References Fmt_t::actuals, Exnode_s::data, elementsof, Fmt_t::env, eval(), exerror(), Fmt_t::expr, _sffmt_s::extf, Expr_s::file, Fmt_t::fmt, _sffmt_s::form, EX_STYPE::integer, Exdata_u::left, Exid_s::name, NULL, Exdata_u::operand, scformat(), sfvscanf(), STRING, EX_STYPE::string, Exdata_u::symbol, and Exdata_u::variable.

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scformat()

static int scformat ( void *  vp,
Sffmt_t dp 
)
static

Definition at line 423 of file exeval.c.

References Fmt_t::actuals, CHARACTER, Exnode_s::data, exerror(), Fmt_t::expr, expr, _sffmt_s::flags, FLOATING, Fmt_t::fmt, _sffmt_s::fmt, INTEGER, Exdata_u::left, Exstate_s::nullstring, Exdata_u::operand, Exdata_u::right, SFFMT_VALUE, _sffmt_s::size, STRING, UNSIGNED, Expr_s::vm, vmalloc(), and vmfree().

Referenced by scan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_add()

static char * str_add ( Expr_t ex,
char *  l,
char *  r 
)
static

Definition at line 544 of file exeval.c.

References exnospace(), NULL, and vmalloc().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_and()

static char * str_and ( Expr_t ex,
const char *  l,
const char *  r 
)
static

Definition at line 606 of file exeval.c.

References exnospace(), len(), NULL, and vmalloc().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_ior()

static char * str_ior ( Expr_t ex,
const char *  l,
const char *  r 
)
static

Definition at line 559 of file exeval.c.

References exnospace(), len(), NULL, and vmalloc().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_mod()

static char * str_mod ( Expr_t ex,
const char *  l,
const char *  r 
)
static

Definition at line 688 of file exeval.c.

References exnospace(), len(), NULL, and vmalloc().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_mpy()

static char * str_mpy ( Expr_t ex,
const char *  l,
const char *  r 
)
static

Definition at line 723 of file exeval.c.

References exnospace(), len(), NULL, and vmalloc().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ str_xor()

static char * str_xor ( Expr_t ex,
const char *  l,
const char *  r 
)
static

Definition at line 641 of file exeval.c.

References exnospace(), len(), NULL, and vmalloc().

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xConvert()

static void xConvert ( Expr_t ex,
Exnode_t exnode,
long  type,
Extype_t  v,
Exnode_t tmp 
)
static

Definition at line 1006 of file exeval.c.

References Exdata_u::constant, Exnode_s::data, exerror(), extypename(), Exdata_u::left, Exid_s::name, Exdata_u::operand, Exdata_u::symbol, type, Exnode_s::type, Exdata_u::value, and Exdata_u::variable.

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ xPrint()

static void xPrint ( Expr_t ex,
Exnode_t exnode,
Extype_t  v,
Exnode_t tmp 
)
static

Definition at line 1022 of file exeval.c.

References Exdata_u::constant, Exnode_s::data, exerror(), extypename(), Exdata_u::left, Exid_s::name, Exdata_u::operand, STRING, Exdata_u::symbol, Exnode_s::type, Exdata_u::value, and Exdata_u::variable.

Referenced by eval().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ seed