[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SCM] gawk branch, feature/mdim-restart, created. gawk-4.1.0-4677-g1f4db
From: |
Arnold Robbins |
Subject: |
[SCM] gawk branch, feature/mdim-restart, created. gawk-4.1.0-4677-g1f4dbe80 |
Date: |
Wed, 23 Mar 2022 15:28:16 -0400 (EDT) |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, feature/mdim-restart has been created
at 1f4dbe804b2d5936d10567f44bc6b1bca448e6e1 (commit)
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=1f4dbe804b2d5936d10567f44bc6b1bca448e6e1
commit 1f4dbe804b2d5936d10567f44bc6b1bca448e6e1
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Wed Mar 23 21:27:31 2022 +0200
Continuing progress.
diff --git a/awk.h b/awk.h
index f7a1428d..753d105b 100644
--- a/awk.h
+++ b/awk.h
@@ -1944,6 +1944,13 @@ dupnode(NODE *n)
static inline NODE *
force_string_fmt(NODE *s, const char *fmtstr, int fmtidx)
{
+ if (s->type == Node_elem_new) {
+ *s = *Nnull_string;
+ s->valref = 1;
+ s->flags &= ~(NUMCUR|NUMBER);
+ return s;
+ }
+
if ((s->flags & STRCUR) != 0
&& (s->stfmt == STFMT_UNUSED || (s->stfmt == fmtidx
#ifdef HAVE_MPFR
diff --git a/mpfr.c b/mpfr.c
index ff4fde0b..a6022f9a 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -349,6 +349,13 @@ mpg_force_number(NODE *n)
{
char *cp, *cpend;
+ if (n->type == Node_elem_new) {
+ *n = *Nnull_string;
+ n->flags &= ~(STRING|STRCUR);
+ n->valref = 1;
+ return n;
+ }
+
if ((n->flags & NUMCUR) != 0)
return n;
n->flags |= NUMCUR;
diff --git a/node.c b/node.c
index cbf5c56e..13d41aca 100644
--- a/node.c
+++ b/node.c
@@ -61,6 +61,13 @@ r_force_number(NODE *n)
char save;
char *ptr;
+ if (n->type == Node_elem_new) {
+ *n = *Nnull_string;
+ n->flags &= ~(STRING|STRCUR);
+ n->valref = 1;
+ return n;
+ }
+
if ((n->flags & NUMCUR) != 0)
return n;
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=8e4e61cf09db4c3e93cc9fd92b5f4a0429240d36
commit 8e4e61cf09db4c3e93cc9fd92b5f4a0429240d36
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Wed Mar 23 20:59:02 2022 +0200
Small code cleanup.
diff --git a/eval.c b/eval.c
index 766d3593..e5dd5735 100644
--- a/eval.c
+++ b/eval.c
@@ -1339,12 +1339,7 @@ setup_frame(INSTRUCTION *pc)
r->type = Node_var;
r->var_value = m;
break;
-/*
- case Node_elem_new:
- freenode(r);
- sp[i] = m;
- break;
-*/
+
case Node_func:
case Node_builtin_func:
case Node_ext_func:
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=2b918ad7a76155acbfd19ccf695fe50cd6a1baa7
commit 2b918ad7a76155acbfd19ccf695fe50cd6a1baa7
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Wed Mar 23 20:57:05 2022 +0200
Stage 2 working.
diff --git a/interpret.h b/interpret.h
index b28b5b1e..30a4db4c 100644
--- a/interpret.h
+++ b/interpret.h
@@ -336,6 +336,11 @@ uninitialized_scalar:
t2 = force_string(t2);
r->vname = estrdup(t2->stptr, t2->stlen);
/* the subscript in parent array */
assoc_set(t1, t2, r);
+ } else if (r->type == Node_elem_new) {
+ r = force_array(r, false);
+ r->parent_array = t1;
+ t2 = force_string(t2);
+ r->vname = estrdup(t2->stptr, t2->stlen);
/* the subscript in parent array */
} else if (r->type != Node_var_array) {
t2 = force_string(t2);
fatal(_("attempt to use scalar `%s[\"%.*s\"]'
as an array"),
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=7d30f731653bd0358af43a65384491d526006a8b
commit 7d30f731653bd0358af43a65384491d526006a8b
Author: Arnold D. Robbins <arnold@skeeve.com>
Date: Wed Mar 23 20:50:27 2022 +0200
First stage working.
diff --git a/array.c b/array.c
index cbed1254..748e2b7f 100644
--- a/array.c
+++ b/array.c
@@ -315,7 +315,7 @@ array_vname(const NODE *symbol)
/*
* force_array --- proceed to the actual Node_var_array,
- * change Node_var_new to an array.
+ * change Node_var_new or Node_elem_new to an array.
* If canfatal and type isn't good, die fatally,
* otherwise return the final actual value.
*/
@@ -335,6 +335,7 @@ force_array(NODE *symbol, bool canfatal)
switch (symbol->type) {
case Node_var_new:
+ case Node_elem_new:
symbol->xarray = NULL; /* make sure union is as it should be */
null_array(symbol);
symbol->parent_array = NULL; /* main array has no parent */
@@ -1166,6 +1167,7 @@ do_sort_up_value_type(const void *p1, const void *p2)
Node_func,
Node_ext_func,
Node_var_new,
+ Node_elem_new,
Node_var,
Node_var_array,
Node_val,
@@ -1429,3 +1431,19 @@ assoc_list(NODE *symbol, const char *sort_str,
sort_context_t sort_ctxt)
return list;
}
+
+/* new_array_element --- return a new empty element node */
+
+extern NODE *
+new_array_element(void)
+{
+ NODE *n;
+
+ getnode(n);
+ memset(n, 0, sizeof(NODE));
+
+ n->type = Node_elem_new;
+ n->valref = 1; // may not be needed
+
+ return n;
+}
diff --git a/awk.h b/awk.h
index 732aec04..f7a1428d 100644
--- a/awk.h
+++ b/awk.h
@@ -258,6 +258,7 @@ typedef enum nodevals {
Node_var, /* scalar variable, lnode is value */
Node_var_array, /* array is ptr to elements, table_size num of
eles */
Node_var_new, /* newly created variable, may become an array
*/
+ Node_elem_new, /* newly created array element, may become a
subarray */
Node_param_list, /* lnode is a variable, rnode is more list */
Node_func, /* lnode is param. list, rnode is body */
Node_ext_func, /* extension function, code_ptr is builtin code
*/
@@ -1444,6 +1445,7 @@ extern NODE *do_asorti(int nargs);
extern unsigned long (*hash)(const char *s, size_t len, unsigned long hsize,
size_t *code);
extern void init_env_array(NODE *env_node);
extern void init_argv_array(NODE *argv_node, NODE *shadow_node);
+extern NODE *new_array_element(void);
/* awkgram.c */
extern NODE *variable(int location, char *name, NODETYPE type);
extern int parse_program(INSTRUCTION **pcode, bool from_eval);
@@ -1848,7 +1850,8 @@ POP_ARRAY(bool check_for_untyped)
NODE *t = POP();
static bool warned = false;
- if (do_lint && ! warned && check_for_untyped && t->type ==
Node_var_new) {
+ if (do_lint && ! warned && check_for_untyped
+ && (t->type == Node_var_new || t->type == Node_elem_new)) {
warned = true;
lintwarn(_("behavior of `for' loop on untyped variable is not
defined by POSIX"));
}
diff --git a/builtin.c b/builtin.c
index 0afeb944..02a172bf 100644
--- a/builtin.c
+++ b/builtin.c
@@ -591,7 +591,7 @@ do_length(int nargs)
size = assoc_length(tmp);
return make_number(size);
- } else if (tmp->type == Node_var_new) {
+ } else if (tmp->type == Node_var_new || tmp->type == Node_elem_new) {
// this can happen from an indirect call
DEREF(tmp);
tmp = dupnode(Nnull_string);
@@ -4343,6 +4343,10 @@ do_typeof(int nargs)
res = "untyped";
deref = false;
break;
+ case Node_elem_new:
+ res = "untyped";
+ deref = false;
+ break;
case Node_array_ref:
/*
* function f(x) {
diff --git a/cint_array.c b/cint_array.c
index 91947766..3e0393c9 100644
--- a/cint_array.c
+++ b/cint_array.c
@@ -1068,7 +1068,7 @@ leaf_lookup(NODE *symbol, NODE *array, long k, long size,
long base)
lhs = array->nodes + (k - base); /* leaf element */
if (*lhs == NULL) {
array->table_size++; /* one more element in leaf array */
- *lhs = dupnode(Nnull_string);
+ *lhs = new_array_element();
}
return lhs;
}
diff --git a/debug.c b/debug.c
index 2849a4c1..f602a199 100644
--- a/debug.c
+++ b/debug.c
@@ -967,6 +967,9 @@ print_symbol(NODE *r, bool isparam)
case Node_var_new:
fprintf(out_fp, "untyped variable\n");
break;
+ case Node_elem_new:
+ fprintf(out_fp, "untyped element\n");
+ break;
case Node_var:
if (! isparam && r->var_update)
r->var_update();
@@ -1241,6 +1244,7 @@ do_set_var(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
switch (r->type) {
case Node_var_new:
+ case Node_elem_new:
r->type = Node_var;
r->var_value = dupnode(Nnull_string);
/* fall through */
@@ -1730,6 +1734,7 @@ watchpoint_triggered(struct list_item *w)
t2 = symbol;
break;
case Node_var_new:
+ case Node_elem_new:
break;
default:
cant_happen("unexpected symbol type %s",
nodetype2str(symbol->type));
@@ -1806,7 +1811,7 @@ initialize_watch_item(struct list_item *w)
r = *get_field(field_num, NULL);
w->cur_value = dupnode(r);
} else {
- if (symbol->type == Node_var_new)
+ if (symbol->type == Node_var_new || symbol->type ==
Node_elem_new)
w->cur_value = (NODE *) 0;
else if (symbol->type == Node_var) {
r = symbol->var_value;
@@ -3753,6 +3758,10 @@ print_memory(NODE *m, NODE *func, Func_print print_func,
FILE *fp)
print_func(fp, "%s", m->vname);
break;
+ case Node_elem_new:
+ print_func(fp, "element - %p", m);
+ break;
+
default:
print_func(fp, "?"); /* can't happen */
}
@@ -5109,7 +5118,7 @@ do_print_f(CMDARG *arg, int cmd ATTRIBUTE_UNUSED)
r = find_symbol(name, NULL);
if (r == NULL)
goto done;
- if (r->type == Node_var_new)
+ if (r->type == Node_var_new || r->type == Node_elem_new)
tmp[i] = Nnull_string;
else if (r->type != Node_var) {
d_error(_("`%s' is not a scalar variable"),
name);
diff --git a/eval.c b/eval.c
index c6f8bcb9..766d3593 100644
--- a/eval.c
+++ b/eval.c
@@ -238,6 +238,7 @@ static const char *const nodetypes[] = {
"Node_var",
"Node_var_array",
"Node_var_new",
+ "Node_elem_new",
"Node_param_list",
"Node_func",
"Node_ext_func",
@@ -1163,6 +1164,7 @@ r_get_lhs(NODE *n, bool reference)
}
/* fall through */
case Node_var_new:
+ case Node_elem_new:
n->type = Node_var;
n->var_value = dupnode(Nnull_string);
break;
@@ -1313,6 +1315,7 @@ setup_frame(INSTRUCTION *pc)
switch (m->type) {
case Node_var_new:
case Node_var_array:
+ case Node_elem_new:
r->type = Node_array_ref;
r->orig_array = r->prev_array = m;
break;
@@ -1336,7 +1339,12 @@ setup_frame(INSTRUCTION *pc)
r->type = Node_var;
r->var_value = m;
break;
-
+/*
+ case Node_elem_new:
+ freenode(r);
+ sp[i] = m;
+ break;
+*/
case Node_func:
case Node_builtin_func:
case Node_ext_func:
diff --git a/ext.c b/ext.c
index 30e52aae..3d643c01 100644
--- a/ext.c
+++ b/ext.c
@@ -200,7 +200,7 @@ get_actual_argument(NODE *t, int i, bool want_array)
pc = TOP()->code_ptr; /* Op_ext_builtin instruction */
fname = (pc + 1)->func_name;
- if (t->type == Node_var_new) {
+ if (t->type == Node_var_new || t->type == Node_elem_new) {
if (want_array)
return force_array(t, false);
else {
diff --git a/gawkapi.c b/gawkapi.c
index 90f328f8..055b6792 100644
--- a/gawkapi.c
+++ b/gawkapi.c
@@ -69,7 +69,7 @@ api_get_argument(awk_ext_id_t id, size_t count,
return awk_false;
/* if type is undefined */
- if (arg->type == Node_var_new) {
+ if (arg->type == Node_var_new || arg->type == Node_elem_new) {
if (wanted == AWK_UNDEFINED)
return awk_true;
else if (wanted == AWK_ARRAY) {
@@ -124,7 +124,7 @@ api_set_argument(awk_ext_id_t id,
return awk_false;
if ( (arg = get_argument(count)) == NULL
- || arg->type != Node_var_new)
+ || (arg->type != Node_var_new && arg->type != Node_elem_new))
return awk_false;
arg = get_array_argument(arg, count);
@@ -564,6 +564,7 @@ node_to_awk_value(NODE *node, awk_value_t *val,
awk_valtype_t wanted)
switch (node->type) {
case Node_var_new: /* undefined variable */
+ case Node_elem_new: /* undefined element */
val->val_type = AWK_UNDEFINED;
if (wanted == AWK_UNDEFINED) {
ret = awk_true;
@@ -896,10 +897,13 @@ api_sym_update(awk_ext_id_t id,
efree((void *) full_name);
- if ((node->type == Node_var && value->val_type != AWK_ARRAY) ||
node->type == Node_var_new) {
+ if ((node->type == Node_var && value->val_type != AWK_ARRAY)
+ || node->type == Node_var_new
+ || node->type == Node_elem_new) {
unref(node->var_value);
node->var_value = awk_value_to_node(value);
- if (node->type == Node_var_new && value->val_type !=
AWK_UNDEFINED)
+ if ((node->type == Node_var_new || node->type == Node_elem_new)
+ && value->val_type != AWK_UNDEFINED)
node->type = Node_var;
return awk_true;
diff --git a/int_array.c b/int_array.c
index 382aa799..8752413e 100644
--- a/int_array.c
+++ b/int_array.c
@@ -792,7 +792,7 @@ int_insert(NODE *symbol, long k, uint32_t hash1)
}
b->ainum[i] = k;
- b->aivalue[i] = dupnode(Nnull_string);
+ b->aivalue[i] = new_array_element();
b->aicount++;
return & b->aivalue[i];
}
diff --git a/interpret.h b/interpret.h
index ca67e966..b28b5b1e 100644
--- a/interpret.h
+++ b/interpret.h
@@ -211,6 +211,7 @@ top:
break;
case Node_var_new:
+ case Node_elem_new:
uninitialized_scalar:
if (op != Op_push_arg_untyped) {
/* convert untyped to scalar */
@@ -826,6 +827,9 @@ mod:
lhs = POP_ADDRESS();
r = TOP_SCALAR();
unref(*lhs);
+ if (r->type == Node_elem_new) {
+ r = Nnull_string;
+ }
UPREF(r);
UNFIELD(*lhs, r);
REPLACE(r);
diff --git a/str_array.c b/str_array.c
index 08704312..101ad0b9 100644
--- a/str_array.c
+++ b/str_array.c
@@ -217,7 +217,7 @@ str_lookup(NODE *symbol, NODE *subs)
b->ahname = subs;
b->ahname_str = subs->stptr;
b->ahname_len = subs->stlen;
- b->ahvalue = dupnode(Nnull_string);
+ b->ahvalue = new_array_element();
b->ahcode = code1;
return & (b->ahvalue);
}
diff --git a/symbol.c b/symbol.c
index 78b29bba..3488359e 100644
--- a/symbol.c
+++ b/symbol.c
@@ -477,6 +477,8 @@ print_vars(NODE **table, int (*print_func)(FILE *, const
char *, ...), FILE *fp)
print_func(fp, "array, %ld elements\n",
assoc_length(r));
else if (r->type == Node_var_new)
print_func(fp, "untyped variable\n");
+ else if (r->type == Node_elem_new)
+ print_func(fp, "untyped element\n");
else if (r->type == Node_var)
valinfo(r->var_value, print_func, fp);
}
-----------------------------------------------------------------------
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [SCM] gawk branch, feature/mdim-restart, created. gawk-4.1.0-4677-g1f4dbe80,
Arnold Robbins <=