Skip to content

Commit

Permalink
Merge branch 'symtab'
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoldrobbins committed Oct 5, 2012
2 parents 5caf242 + 81896b4 commit bcb0224
Show file tree
Hide file tree
Showing 34 changed files with 1,259 additions and 649 deletions.
48 changes: 48 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,54 @@
extension/Makefile.in, extension/aclocal.m4, test/Makefile.in:
Regenerated.

* interpret.h (Op_Subscript): Added lint warnings for FUNCTAB
and SYMTAB.

2012-10-02 Arnold D. Robbins <arnold@skeeve.com>

* awk.h (func_table): Declare.
* awkgram.y: If do_posix or do_traditional, then check for
delete on SYMTAB. Add check for delete on FUNCTAB, also.
* interpret.h (Op_Subscript): For FUNCTAB, return the element name
as its value too. Avoids lots of weirdness and allows indirect calls
after assignment from FUNCTAB["foo"] to work.
(Op_store_sub): Disallow assignment to elements of FUNCTAB.
(Op_indirect_func_all): Turn assert into check and fatal error.
* symbol.c (func_table): No longer static.
(lookup): If do_posix or do_traditional, skip the global table.
(release_all_vars): Clear func_table too.

2012-09-25 Arnold D. Robbins <arnold@skeeve.com>

First cut at SYMTAB and FUNCTAB. This does the following:
- Change symbol table handling to use gawk arrays.
- Store symbols in SYMTAB array and allow indirect access
through SYMTAB to variables, both getting and setting.
- List function names in FUNCTAB indexes; Values cannot be
used at the moment.
- No documentation yet.

* awk.h (Node_hashnode, hnext, hname, hlength, hcode, hvalue):
Removed, not needed any more.
(init_symbol_table, symbol_table): Add declarations.
* awkgram.y: Disallow delete on SYMTAB, fix warning for tawk
extension if traditional.
* eval.c (nodetypes): Remove Node_hashnode element.
* interpret.h (Op_subscript, Op_store_sub): Handle SYMTAB and go
through to the actual value.
* main.c (main): Init Nnull_string earlier. Add call to
init_symbol_table().
* profile.c (pp_str, pp_len): Change definitions.
(pp_next): New macro.
(pp_push, pp_pop): Adjust uses.
* symbol.c (variables): Removed.
(global_table, param_table, func_table, symbol_table,
installing_specials): New variables.
(lookup, make_params, install_params, remove_params, remove_symbol,
make_symbol, install, get_symbols, release_all_vars, append_symbol,
release_symbols, load_symbols): Rework logic considerably.
(init_symbol_table): New function.

2012-09-23 Arnold D. Robbins <arnold@skeeve.com>

`delete array' and `nextfile' are now in POSIX.
Expand Down
32 changes: 14 additions & 18 deletions awk.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ typedef enum nodevals {
Node_func, /* lnode is param. list, rnode is body */
Node_ext_func, /* extension function, code_ptr is builtin code */

Node_hashnode, /* an identifier in the symbol table */
Node_array_ref, /* array passed by ref as parameter */
Node_array_tree, /* Hashed array tree (HAT) */
Node_array_leaf, /* Linear 1-D array */
Expand Down Expand Up @@ -462,17 +461,11 @@ typedef struct exp_node {
#define nextp sub.nodep.l.lptr
#define rnode sub.nodep.r.rptr

/* Node_hashnode, Node_param_list */
#define hnext sub.nodep.r.rptr
#define hname vname
#define hlength sub.nodep.reserved
#define hcode sub.nodep.cnt
#define hvalue sub.nodep.x.extra
/* Node_param_list */
#define param vname

/* Node_param_list, Node_func */
#define param_cnt sub.nodep.l.ll
/* Node_param_list */
#define param vname

/* Node_func */
#define fparms sub.nodep.rn
Expand Down Expand Up @@ -1372,15 +1365,15 @@ if (--val) \
/* array.c */
typedef enum sort_context { SORTED_IN = 1, ASORT, ASORTI } SORT_CTXT;
enum assoc_list_flags {
AINDEX = 0x01, /* list of indices */
AVALUE = 0x02, /* list of values */
AINUM = 0x04, /* numeric index */
AISTR = 0x08, /* string index */
AVNUM = 0x10, /* numeric scalar value */
AVSTR = 0x20, /* string scalar value */
AASC = 0x40, /* ascending order */
ADESC = 0x80, /* descending order */
ADELETE = 0x100, /* need a single index; for use in do_delete_loop */
AINDEX = 0x01, /* list of indices */
AVALUE = 0x02, /* list of values */
AINUM = 0x04, /* numeric index */
AISTR = 0x08, /* string index */
AVNUM = 0x10, /* numeric scalar value */
AVSTR = 0x20, /* string scalar value */
AASC = 0x40, /* ascending order */
ADESC = 0x80, /* descending order */
ADELETE = 0x100, /* need a single index; for use in do_delete_loop */
};

extern NODE *make_array(void);
Expand Down Expand Up @@ -1670,6 +1663,9 @@ extern int get_numbase(const char *str, bool use_locale);

/* symbol.c */
extern void load_symbols();
extern void init_symbol_table();
extern NODE *symbol_table;
extern NODE *func_table;
extern NODE *install_symbol(char *name, NODETYPE type);
extern NODE *remove_symbol(NODE *r);
extern void destroy_symbol(NODE *r);
Expand Down
Loading

0 comments on commit bcb0224

Please sign in to comment.