Debian Codegraph @

lib/expr/exexpr.c

raw
1 /*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11 /*
12 * Glenn Fowler
13 * AT&T Research
14 *
15 * expression library
16 */
17
18 #include "config.h"
19
20 #include <expr/exlib.h>
21 #include <stddef.h>
22
23 /*
24 * return the expression for name or sym coerced to type
25 */
26
27 Exnode_t*
28 exexpr(Expr_t* ex, const char* name, Exid_t* sym, int type)
29 {
30 if (ex)
31 {
32 if (!sym)
33 sym = name ? dtmatch(ex->symbols, name) : &ex->main;
34 if (sym && sym->lex == PROCEDURE && sym->value)
35 {
36 if (type != DELETE_T)
37 return excast(ex, sym->value->data.procedure.body, type, NULL, 0);
38 exfreenode(ex, sym->value);
39 sym->lex = NAME;
40 sym->value = 0;
41 }
42 }
43 return 0;
44 }
45
46 /**
47 * @dir lib/expr
48 * @brief expression library for lib/gvpr/, API expr.h
49 */