Graphviz 12.0.1~dev.20240716.0800
|
#include "config.h"
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <gvpr/compile.h>
#include <assert.h>
#include <cgraph/agxbuf.h>
#include <cgraph/alloc.h>
#include <cgraph/cgraph.h>
#include <cgraph/exit.h>
#include <cgraph/prisize_t.h>
#include <cgraph/startswith.h>
#include <cgraph/streq.h>
#include <cgraph/unreachable.h>
#include <ast/error.h>
#include <gvpr/actions.h>
#include <inttypes.h>
#include <string.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <math.h>
#include <gvpr/gdefs.h>
#include <ctype.h>
#include <gvpr/trie.c>
Go to the source code of this file.
Macros | |
#define | MIN(a, b) ((a)<(b)?(a):(b)) |
#define | MAX(a, b) ((a)>(b)?(a):(b)) |
#define | BITS_PER_BYTE 8 |
#define | MINTYPE (LAST_M+1) /* First type occurs after last M_ */ |
#define | haveGraph (1 <= codePhase && codePhase <= 4) |
#define | haveTarget (2 <= codePhase && codePhase <= 4) |
#define | inWalk (2 <= codePhase && codePhase <= 3) |
Functions | |
static int | isedge (Agobj_t *obj) |
static void * | int2ptr (long long i) |
static long long | ptr2int (const void *p) |
static int | iofread (void *chan, char *buf, int bufsize) |
static int | ioputstr (void *chan, const char *str) |
static int | ioflush (void *chan) |
static char * | nameOf (Expr_t *ex, Agobj_t *obj, agxbuf *tmps) |
static char * | bbOf (Expr_t *pgm, char *pt, bool getll) |
static char * | xyOf (Expr_t *pgm, char *pt, bool getx) |
static int | posOf (Agnode_t *np, int idx, double *v) |
static Agdesc_t | xargs (char *args) |
static char * | deparse (Expr_t *ex, Exnode_t *n, agxbuf *xb) |
static Agobj_t * | deref (Expr_t *pgm, Exnode_t *x, Exref_t *ref, Agobj_t *objp, Gpr_t *state) |
static void | assignable (Agobj_t *objp, unsigned char *name) |
static int | setattr (Agobj_t *objp, char *name, char *val) |
static char * | kindToStr (int kind) |
static char * | kindOf (Agobj_t *objp) |
static int | lookup (Expr_t *pgm, Agobj_t *objp, Exid_t *sym, Extype_t *v) |
static char * | getArg (int n, Gpr_t *state) |
static int | setDfltAttr (Agraph_t *gp, char *k, char *name, char *value) |
static int | toKind (char *k, char *fn) |
static char * | nxtAttr (Agraph_t *gp, char *k, char *name) |
static char * | getDfltAttr (Agraph_t *gp, char *k, char *name) |
static Extype_t | getval (Expr_t *pgm, Exnode_t *node, Exid_t *sym, Exref_t *ref, void *env, int elt, Exdisc_t *disc) |
static char * | typeName (long op) |
static int | setval (Expr_t *pgm, Exnode_t *x, Exid_t *sym, Exref_t *ref, void *env, Extype_t v) |
static tctype | typeChk (tctype intype, Exid_t *sym) |
static tctype | typeChkExp (Exref_t *ref, Exid_t *sym) |
static Extype_t | refval (Expr_t *pgm, Exnode_t *node, Exid_t *sym, Exref_t *ref) |
static int | binary (Exnode_t *l, Exnode_t *ex, Exnode_t *r, int arg) |
static int | strToTvtype (char *s) |
static char * | tvtypeToStr (long long v) |
static int | stringOf (Expr_t *prog, Exnode_t *x, int arg) |
static int | convert (Exnode_t *x, long type, int arg) |
static Extype_t | keyval (Extype_t v, long type) |
static Exdisc_t * | initDisc (Gpr_t *state) |
static Exnode_t * | compile (Expr_t *prog, char *src, char *input, int line, const char *lbl, const char *sfx, int kind) |
static void | checkGuard (Exnode_t *gp, char *src, int line) |
static case_stmt * | mkStmts (Expr_t *prog, char *src, case_info *sp, size_t cnt, const char *lbl) |
static int | mkBlock (comp_block *bp, Expr_t *prog, char *src, parse_block *inp, size_t i) |
static const char * | doFlags (int flags) |
comp_prog * | compileProg (parse_prog *inp, Gpr_t *state, int flags) |
void | freeCompileProg (comp_prog *p) |
int | walksGraph (comp_block *p) |
int | usesGraph (comp_prog *p) |
Agraph_t * | readG (FILE *fp) |
Agraph_t * | openG (char *name, Agdesc_t desc) |
Agraph_t * | openSubg (Agraph_t *g, char *name) |
Agnode_t * | openNode (Agraph_t *g, char *name) |
Agedge_t * | openEdge (Agraph_t *g, Agnode_t *t, Agnode_t *h, char *key) |
Variables | |
static Agiodisc_t | gprIoDisc = { iofread, ioputstr, ioflush } |
static Agdisc_t | gprDisc = { &AgIdDisc, &gprIoDisc } |
static int | codePhase |
static int | a2t [] |
|
static |
|
static |
Definition at line 125 of file compile.c.
References exstralloc(), exstring(), and len().
Referenced by getval().
Definition at line 1884 of file compile.c.
References BUILTIN, compare(), Exdata_u::constant, Exnode_s::data, EQ, GE, int2ptr(), EX_STYPE::integer, INTEGRAL, LE, NE, Exnode_s::op, Exnode_s::type, and Exdata_u::value.
Referenced by initDisc().
|
static |
Definition at line 2299 of file compile.c.
References error(), ERROR_WARNING, exisAssign(), exnoncast(), and setErrorFileLine().
Referenced by mkStmts().
|
static |
Definition at line 2262 of file compile.c.
References agxbdisown(), agxbprint(), excomp(), exexpr(), getErrorErrors(), kind, label(), lbl, and NULL.
Referenced by compileProg(), mkBlock(), and mkStmts().
comp_prog * compileProg | ( | parse_prog * | inp, |
Gpr_t * | state, | ||
int | flags | ||
) |
Definition at line 2430 of file compile.c.
References comp_prog::begin_stmt, parse_prog::begin_stmt, BITS_PER_BYTE, comp_prog::blocks, parse_prog::blocks, codePhase, compile(), doFlags(), comp_prog::end_stmt, parse_prog::end_stmt, ENDG, comp_prog::endg_stmt, parse_prog::endg_stmt, error(), ERROR_ERROR, exinit(), exopen(), flags, comp_prog::flags, freeCompileProg(), G, getErrorErrors(), gv_calloc(), initDisc(), parse_prog::l_begin, parse_prog::l_end, parse_prog::l_endg, mkBlock(), comp_prog::n_blocks, parse_prog::n_blocks, _parse_block::next, NULL, comp_prog::prog, setErrorLine(), parse_prog::source, state, symbols, T_graph, TBITS, tchk, Exid_s::type, VOIDTYPE, and Y.
Referenced by gvpr_core().
|
static |
Definition at line 2130 of file compile.c.
References AGNODE, AGRAPH, AGTYPE, BUILTIN, Exdata_u::constant, Exnode_s::data, exerror(), FLOATING, int2ptr(), INTEGER, EX_STYPE::integer, isedge(), STRING, EX_STYPE::string, strToTvtype(), T_edge, T_graph, T_node, tvtypeToStr(), type, Exnode_s::type, validTVT(), and Exdata_u::value.
Referenced by initDisc().
|
static |
Definition at line 278 of file compile.c.
References AGHEAD, AGTAIL, agxbfree(), Exnode_s::data, deparse(), deref(), Exdata_u::dyna, DYNAMIC, exerror(), int2ptr(), EX_STYPE::integer, isedge(), ref(), state, Exdata_u::value, and Exdata_u::variable.
Referenced by deref(), endpoint(), getval(), PQdelete(), setval(), and voronoi().
|
static |
void freeCompileProg | ( | comp_prog * | p | ) |
Definition at line 2515 of file compile.c.
References comp_prog::blocks, comp_block::edge_stmts, exclose(), free(), comp_prog::n_blocks, comp_block::node_stmts, and comp_prog::prog.
Referenced by compileProg(), and gvpr().
|
static |
|
static |
Definition at line 645 of file compile.c.
References agattr(), Agsym_s::defval, error(), ERROR_WARNING, kind, kindToStr(), and toKind().
Referenced by getval().
|
static |
Definition at line 661 of file compile.c.
References addEdge(), addNode(), agattr(), agattrsym(), agcontains(), agdegree(), agfstedge(), agfstin(), agfstnode(), agfstout(), agfstsubg(), aghead, aghtmlstr(), AGINEDGE, agisdirected(), agisstrict(), agnedges(), agnnodes(), AGNODE, agnode(), agnxtedge(), agnxtin(), agnxtnode(), agnxtout(), agnxtsubg(), AGOUTEDGE, AGRAPH, agraphof(), agroot(), agsubg(), agtail, AGTYPE, agxbfree(), agxget(), bbOf(), canon(), cloneG(), cloneO(), closeFile(), colorx(), compOf(), CONSTANT, copy(), copyAttr(), deleteObj(), deparse(), deref(), error(), ERROR_ERROR, ERROR_WARNING, EX_ARRAY, EX_CALL, exerror(), findBinding(), EX_STYPE::floating, gvprbinding::fn, freadFile(), fwriteFile(), getArg(), getDfltAttr(), graphviz_node_induce(), ID, Exid_s::index, indexOf(), int2ptr(), EX_STYPE::integer, isEdge(), key, kind, kindOf(), LAST_V, Exid_s::lex, lockGraph(), lookup(), match(), MAX, MIN, Exid_s::name, nameOf(), NULL, nxtAttr(), openEdge(), openFile(), openG(), openNode(), openSubg(), ptr2int(), readFile(), readLine(), ref(), rindexOf(), setattr(), setDfltAttr(), sfioWrite(), SIZE_MAX, state, EX_STYPE::string, toHtml(), toKind(), toLower(), toUpper(), UNREACHABLE, Exdisc_s::user, writeFile(), xargs(), and xyOf().
Referenced by initDisc().
Definition at line 2225 of file compile.c.
References a2t, binary(), Exdisc_s::binaryf, convert(), Exdisc_s::convertf, error(), ERROR_ERROR, errorf(), Exdisc_s::errorf, EX_CHARSTRING, EX_UNDECLARED, EX_VERSION, Exdisc_s::exitf, Exdisc_s::flags, Exdisc_s::getf, getval(), Exdisc_s::keyf, keyval(), Exdisc_s::reff, refval(), Exdisc_s::setf, setval(), state, stringOf(), Exdisc_s::stringof, Exdisc_s::symbols, symbols, typeName(), Exdisc_s::typename, Exdisc_s::types, Exdisc_s::user, and Exdisc_s::version.
Referenced by compileProg().
|
static |
|
static |
|
static |
|
static |
Definition at line 2207 of file compile.c.
References AGID, int2ptr(), EX_STYPE::integer, and type.
Referenced by initDisc().
|
static |
Definition at line 414 of file compile.c.
References agobjkind(), and kindToStr().
Referenced by getval(), and lookup().
|
static |
Definition at line 423 of file compile.c.
References agattr(), agattrsym(), agdegree(), AGHEAD, agisdirected(), agisstrict(), agnameof(), agnedges(), agnnodes(), AGNODE, agparent(), AGRAPH, agraphof(), agroot(), AGTAIL, AGTYPE, agxbfree(), agxget(), error(), ERROR_WARNING, exerror(), EX_STYPE::floating, ID, Exid_s::index, EX_STYPE::integer, isedge(), kindOf(), Exid_s::lex, Exid_s::name, nameOf(), posOf(), ptr2int(), and EX_STYPE::string.
Referenced by getval().
|
static |
Definition at line 2349 of file compile.c.
References agxbfree(), agxbprint(), agxbuse(), BEGG, comp_block::begg_stmt, _parse_block::begg_stmt, codePhase, compile(), E, comp_block::edge_stmts, _parse_block::edge_stmts, free(), G, getErrorErrors(), _parse_block::l_beging, label(), mkStmts(), comp_block::n_estmts, _parse_block::n_estmts, comp_block::n_nstmts, _parse_block::n_nstmts, comp_block::node_stmts, _parse_block::node_stmts, PRISIZE_T, symbols, T_edge, T_graph, T_node, tchk, Exid_s::type, V, VOIDTYPE, comp_block::walks, WALKSG, and Y.
Referenced by compileProg().
|
static |
Definition at line 2312 of file compile.c.
References case_stmt::action, _case_info::action, agxbfree(), agxbprint(), agxbuse(), _case_info::astart, checkGuard(), cnt(), compile(), getErrorErrors(), _case_info::gstart, case_stmt::guard, _case_info::guard, guard, gv_calloc(), INTEGER, lbl, _case_info::next, and PRISIZE_T.
Referenced by mkBlock().
Definition at line 91 of file compile.c.
References AGHEAD, agisdirected(), AGMKOUT, agnameof(), AGNODE, AGRAPH, agraphof(), AGTAIL, AGTYPE, agxbput(), agxbputc(), agxbuse(), exstring(), and key.
Referenced by getval(), lookup(), and stringOf().
|
static |
Definition at line 621 of file compile.c.
References agattr(), agnxtattr(), exerror(), kind, Agsym_s::name, NULL, and toKind().
Referenced by getval().
Definition at line 2599 of file compile.c.
References agbindrec(), aggetrec(), agnode(), and UDATA.
Referenced by cloneO(), copy(), and getval().
Definition at line 2586 of file compile.c.
References agbindrec(), aggetrec(), agsubg(), and UDATA.
Referenced by cloneO(), compOf(), copy(), getval(), and traverse().
|
static |
|
static |
Agraph_t * readG | ( | FILE * | fp | ) |
Definition at line 2552 of file compile.c.
References AGEDGE, AgIdDisc, aginit(), AGNODE, AGRAPH, agread(), gprDisc, Agdisc_s::id, and UDATA.
Referenced by freadFile(), ing_read(), and readFile().
Definition at line 1814 of file compile.c.
References agxbfree(), CONSTANT, deparse(), exerror(), exzero(), Exid_s::index, EX_STYPE::integer, Exid_s::lex, ref(), TV_bfs, TV_dfs, TV_en, TV_flat, TV_fwd, TV_ne, TV_postdfs, TV_postfwd, TV_postrev, TV_prepostdfs, TV_prepostfwd, TV_prepostrev, TV_rev, and typeChkExp().
Referenced by initDisc().
|
static |
Definition at line 380 of file compile.c.
References agattr(), agattrsym(), agraphof(), agroot(), AGTYPE, and agxset().
Referenced by getval(), and setval().
|
static |
|
static |
Definition at line 1616 of file compile.c.
References agnameof(), agroot(), agxbfree(), assignable(), deparse(), deref(), error(), exerror(), free(), GV_NEXT_SET, Exid_s::index, int2ptr(), EX_STYPE::integer, MAXNAME, Exid_s::name, ref(), setattr(), state, EX_STYPE::string, typeName(), and validTVT().
Referenced by initDisc().
Definition at line 2097 of file compile.c.
References agxbfree(), Exdata_u::constant, Exnode_s::data, exerror(), int2ptr(), EX_STYPE::integer, nameOf(), STRING, EX_STYPE::string, tvtypeToStr(), Exnode_s::type, typeName(), and Exdata_u::value.
Referenced by initDisc().
|
static |
Definition at line 1999 of file compile.c.
References exerror(), startswith(), TV_bfs, TV_dfs, TV_en, TV_flat, TV_fwd, TV_ne, TV_postdfs, TV_postfwd, TV_postrev, TV_prepostdfs, TV_prepostfwd, TV_prepostrev, and TV_rev.
Referenced by convert().
|
static |
|
static |
Definition at line 2041 of file compile.c.
References exerror(), TV_bfs, TV_dfs, TV_en, TV_flat, TV_fwd, TV_ne, TV_postdfs, TV_postfwd, TV_postrev, TV_prepostdfs, TV_prepostfwd, TV_prepostrev, and TV_rev.
Referenced by convert(), and stringOf().
Definition at line 1704 of file compile.c.
References DYNAMIC, E, exerror(), F, FLOATING, G, haveGraph, haveTarget, I, ID, Exid_s::index, INTEGER, Exid_s::lex, MAXNAME, NAME, Exid_s::name, S, STRING, T_edge, T_graph, T_node, tchk, Exid_s::type, V, Y, and YALL.
Referenced by typeChkExp().
|
static |
Definition at line 1606 of file compile.c.
References MINTYPE, and typenames.
Referenced by initDisc(), setval(), and stringOf().
int usesGraph | ( | comp_prog * | p | ) |
Definition at line 2543 of file compile.c.
References comp_prog::flags.
Referenced by gvpr_core().
int walksGraph | ( | comp_block * | p | ) |
Definition at line 2534 of file compile.c.
References comp_block::walks.
Referenced by gvpr_core().
|
static |
Definition at line 231 of file compile.c.
References Agdirected, Agdesc_s::directed, error(), ERROR_WARNING, and Agdesc_s::strict.
Referenced by getval().
|
static |
Definition at line 150 of file compile.c.
References exstralloc(), exstring(), and len().
Referenced by getval().
|
static |
|
static |
Definition at line 1691 of file compile.c.
Referenced by compileProg(), and mkBlock().