aboutsummaryrefslogtreecommitdiffstats
path: root/awkgram.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2019-01-09 10:51:28 -0500
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2019-01-09 10:51:28 -0500
commit56f4a4139ad7e81064e25887f959a4a6e5e54a58 (patch)
tree01645ae916a19e911d2111763beead9faa1ba7ab /awkgram.c
parent0e1fd064f13b220a129fc720607d3f62b55b3b19 (diff)
downloadegawk-56f4a4139ad7e81064e25887f959a4a6e5e54a58.tar.gz
egawk-56f4a4139ad7e81064e25887f959a4a6e5e54a58.tar.bz2
egawk-56f4a4139ad7e81064e25887f959a4a6e5e54a58.zip
Implement optional second array arg to type of returning info on variable internals.
Diffstat (limited to 'awkgram.c')
-rw-r--r--awkgram.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/awkgram.c b/awkgram.c
index 36955071..993dfc4c 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -4745,7 +4745,7 @@ static const struct token tokentab[] = {
{"systime", Op_builtin, LEX_BUILTIN, GAWKX|A(0), do_systime, 0},
{"tolower", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_tolower, 0},
{"toupper", Op_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_toupper, 0},
-{"typeof", Op_builtin, LEX_BUILTIN, GAWKX|A(1), do_typeof, 0},
+{"typeof", Op_builtin, LEX_BUILTIN, GAWKX|A(1)|A(2), do_typeof, 0},
{"while", Op_K_while, LEX_WHILE, BREAK|CONTINUE, 0, 0},
{"xor", Op_builtin, LEX_BUILTIN, GAWKX, do_xor, MPF(xor)},
};
@@ -7034,10 +7034,20 @@ snode(INSTRUCTION *subn, INSTRUCTION *r)
if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push)
arg->nexti->opcode = Op_push_arg; /* argument may be array */
}
- } else if (r->builtin == do_isarray || r->builtin == do_typeof) {
+ } else if (r->builtin == do_isarray) {
arg = subn->nexti;
if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push)
arg->nexti->opcode = Op_push_arg_untyped; /* argument may be untyped */
+ } else if (r->builtin == do_typeof) {
+ arg = subn->nexti;
+ if (arg->nexti == arg->lasti && arg->nexti->opcode == Op_push)
+ arg->nexti->opcode = Op_push_arg_untyped; /* argument may be untyped */
+ if (nexp == 2) { /* 2nd argument there */
+ arg = subn->nexti->lasti->nexti; /* 2nd arg list */
+ ip = arg->lasti;
+ if (ip->opcode == Op_push)
+ ip->opcode = Op_push_array;
+ }
#ifdef SUPPLY_INTDIV
} else if (r->builtin == do_intdiv
#ifdef HAVE_MPFR