This commit is contained in:
parent
7bf0d7867b
commit
98e72b6711
@ -5491,7 +5491,7 @@ static int deparse (ase_awk_t* awk)
|
||||
else
|
||||
{
|
||||
len = ase_awk_longtostr ((ase_long_t)i,
|
||||
10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp));
|
||||
10, ASE_T("__g"), tmp, ASE_COUNTOF(tmp));
|
||||
ASE_ASSERT (len != (ase_size_t)-1);
|
||||
if (ase_awk_putsrcstrx (awk, tmp, len) == -1)
|
||||
{
|
||||
@ -5516,7 +5516,7 @@ static int deparse (ase_awk_t* awk)
|
||||
else
|
||||
{
|
||||
len = ase_awk_longtostr ((ase_long_t)i,
|
||||
10, ASE_T("__global"), tmp, ASE_COUNTOF(tmp));
|
||||
10, ASE_T("__g"), tmp, ASE_COUNTOF(tmp));
|
||||
ASE_ASSERT (len != (ase_size_t)-1);
|
||||
if (ase_awk_putsrcstrx (awk, tmp, len) == -1)
|
||||
{
|
||||
@ -5658,7 +5658,7 @@ static int deparse_func (ase_awk_pair_t* pair, void* arg)
|
||||
for (i = 0; i < afn->nargs; )
|
||||
{
|
||||
n = ase_awk_longtostr (i++, 10,
|
||||
ASE_T("__param"), df->tmp, df->tmp_len);
|
||||
ASE_T("__p"), df->tmp, df->tmp_len);
|
||||
ASE_ASSERT (n != (ase_size_t)-1);
|
||||
if (ase_awk_putsrcstrx (df->awk, df->tmp, n) == -1) return -1;
|
||||
if (i >= afn->nargs) break;
|
||||
|
@ -334,7 +334,7 @@ static int print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
||||
n = ase_awk_longtostr (
|
||||
px->id.idxa, 10, ASE_NULL, tmp, ASE_COUNTOF(tmp));
|
||||
|
||||
PUT_SRCSTR (awk, ASE_T("__param"));
|
||||
PUT_SRCSTR (awk, ASE_T("__p"));
|
||||
PUT_SRCSTRX (awk, tmp, n);
|
||||
|
||||
ASE_ASSERT (px->idx == ASE_NULL);
|
||||
@ -348,7 +348,7 @@ static int print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
||||
ASE_ASSERT (px->id.idxa != (ase_size_t)-1);
|
||||
ASE_ASSERT (px->idx != ASE_NULL);
|
||||
|
||||
PUT_SRCSTR (awk, ASE_T("__param"));
|
||||
PUT_SRCSTR (awk, ASE_T("__p"));
|
||||
n = ase_awk_longtostr (
|
||||
px->id.idxa, 10, ASE_NULL,
|
||||
awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt));
|
||||
@ -406,7 +406,7 @@ static int print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
||||
ase_char_t tmp[ASE_SIZEOF(ase_long_t)*8+2];
|
||||
ase_size_t n;
|
||||
|
||||
PUT_SRCSTR (awk, ASE_T("__global"));
|
||||
PUT_SRCSTR (awk, ASE_T("__g"));
|
||||
n = ase_awk_longtostr (
|
||||
px->id.idxa, 10,
|
||||
ASE_NULL, tmp, ASE_COUNTOF(tmp));
|
||||
@ -444,7 +444,7 @@ static int print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
||||
ase_char_t tmp[ASE_SIZEOF(ase_long_t)*8+2];
|
||||
ase_size_t n;
|
||||
|
||||
PUT_SRCSTR (awk, ASE_T("__global"));
|
||||
PUT_SRCSTR (awk, ASE_T("__g"));
|
||||
n = ase_awk_longtostr (
|
||||
px->id.idxa, 10,
|
||||
ASE_NULL, tmp, ASE_COUNTOF(tmp));
|
||||
@ -470,7 +470,7 @@ static int print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
||||
|
||||
if (px->id.idxa != (ase_size_t)-1)
|
||||
{
|
||||
PUT_SRCSTR (awk, ASE_T("__local"));
|
||||
PUT_SRCSTR (awk, ASE_T("__l"));
|
||||
n = ase_awk_longtostr (
|
||||
px->id.idxa, 10, ASE_NULL,
|
||||
awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt));
|
||||
@ -491,7 +491,7 @@ static int print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
|
||||
|
||||
if (px->id.idxa != (ase_size_t)-1)
|
||||
{
|
||||
PUT_SRCSTR (awk, ASE_T("__local"));
|
||||
PUT_SRCSTR (awk, ASE_T("__l"));
|
||||
n = ase_awk_longtostr (
|
||||
px->id.idxa, 10, ASE_NULL,
|
||||
awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt));
|
||||
@ -623,7 +623,7 @@ static int print_statement (ase_awk_t* awk, ase_awk_nde_t* p, int depth)
|
||||
|
||||
for (i = 0; i < px->nlocals - 1; i++)
|
||||
{
|
||||
PUT_SRCSTR (awk, ASE_T("__local"));
|
||||
PUT_SRCSTR (awk, ASE_T("__l"));
|
||||
n = ase_awk_longtostr (
|
||||
i, 10, ASE_NULL,
|
||||
awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt));
|
||||
@ -631,7 +631,7 @@ static int print_statement (ase_awk_t* awk, ase_awk_nde_t* p, int depth)
|
||||
PUT_SRCSTR (awk, ASE_T(", "));
|
||||
}
|
||||
|
||||
PUT_SRCSTR (awk, ASE_T("__local"));
|
||||
PUT_SRCSTR (awk, ASE_T("__l"));
|
||||
n = ase_awk_longtostr (
|
||||
i, 10, ASE_NULL,
|
||||
awk->tmp.fmt, ASE_COUNTOF(awk->tmp.fmt));
|
||||
|
@ -39,8 +39,8 @@ BEGIN {
|
||||
{
|
||||
}
|
||||
BEGIN {
|
||||
local __local0;
|
||||
__local0 = 20;
|
||||
local __l0;
|
||||
__l0 = 20;
|
||||
}
|
||||
|
||||
Local variable declaration requires ASE_AWK_EXPLICIT, though.
|
||||
@ -67,16 +67,16 @@ BEGIN {
|
||||
|
||||
| A global variable is visible after it is declared to the remaining part of the program. x inside fn is x named variable while x in BEGIN is a global variable.
|
||||
|
||||
global __global17;
|
||||
global __g17;
|
||||
function fn ()
|
||||
{
|
||||
x = 20;
|
||||
return x;
|
||||
}
|
||||
BEGIN {
|
||||
__global17 = 30;
|
||||
__g17 = 30;
|
||||
print fn ();
|
||||
print __global17;
|
||||
print __g17;
|
||||
}
|
||||
|-
|
||||
| global x;
|
||||
@ -96,20 +96,20 @@ BEGIN {
|
||||
}
|
||||
| A local variable can shade a global variable and a local variable at outer scope.
|
||||
|
||||
global __global17;
|
||||
global __g17;
|
||||
|
||||
BEGIN {
|
||||
local __local0, __local1;
|
||||
__global17 = 1;
|
||||
local __l0, __l1;
|
||||
__g17 = 1;
|
||||
{
|
||||
__local0 = 2;
|
||||
__l0 = 2;
|
||||
{
|
||||
__local1 = 3;
|
||||
print __local1;
|
||||
__l1 = 3;
|
||||
print __l1;
|
||||
}
|
||||
print __local0;
|
||||
print __l0;
|
||||
}
|
||||
print __global17;
|
||||
print __g17;
|
||||
}
|
||||
|}}
|
||||
|
||||
@ -138,9 +138,9 @@ A parameter name can shade a enclosing function name. The following table shows
|
||||
}
|
||||
| 50 is printed. The parameter f in fn doesn't affect the named variable f in BEGIN. The deparsed output shows this clearly.
|
||||
|
||||
function fn (__param0)
|
||||
function fn (__p0)
|
||||
{
|
||||
__param0 = 20;
|
||||
__p0 = 20;
|
||||
}
|
||||
BEGIN {
|
||||
f = 50;
|
||||
|
@ -3,4 +3,4 @@ BEGIN {
|
||||
abc = 10;
|
||||
}
|
||||
|
||||
RUN ERROR: CODE [98] LINE [3] map 'abc' not assignable with a scalar
|
||||
RUN ERROR: CODE [99] LINE [3] map 'abc' not assignable with a scalar
|
||||
|
@ -2,4 +2,4 @@ BEGIN {
|
||||
delete ARGC;
|
||||
}
|
||||
|
||||
RUN ERROR: CODE [90] LINE [2] variable 'ARGC' not deletable
|
||||
RUN ERROR: CODE [91] LINE [2] variable 'ARGC' not deletable
|
||||
|
@ -3,4 +3,4 @@ BEGIN {
|
||||
delete iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix;
|
||||
}
|
||||
|
||||
RUN ERROR: CODE [90] LINE [3] variable 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii...' not deletable
|
||||
RUN ERROR: CODE [91] LINE [3] variable 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii...' not deletable
|
||||
|
@ -2,4 +2,4 @@ BEGIN {
|
||||
helpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhelphelp ();
|
||||
}
|
||||
|
||||
RUN ERROR: CODE [88] LINE [2] function 'helpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhel...' not found
|
||||
RUN ERROR: CODE [89] LINE [2] function 'helpxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhel...' not found
|
||||
|
@ -1 +1 @@
|
||||
PARSE ERROR: CODE [59] LINE [9] function 'abc' redefined
|
||||
PARSE ERROR: CODE [53] LINE [13] 'abc' not a valid function name
|
||||
|
@ -1,3 +1,4 @@
|
||||
function abc (abc)
|
||||
{
|
||||
abc (); # invalid as abc is the parameter in this context
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
PARSE ERROR: CODE [59] LINE [1] function 'abc' redefined
|
||||
PARSE ERROR: CODE [53] LINE [3] 'abc' not a valid function name
|
||||
|
@ -1 +1 @@
|
||||
PARSE ERROR: CODE [65] LINE [1] '+' not a valid parameter name
|
||||
PARSE ERROR: CODE [66] LINE [1] '+' not a valid parameter name
|
||||
|
@ -1 +1 @@
|
||||
PARSE ERROR: CODE [66] LINE [1] '+' not a valid variable name
|
||||
PARSE ERROR: CODE [67] LINE [1] '+' not a valid variable name
|
||||
|
@ -1 +1 @@
|
||||
PARSE ERROR: CODE [66] LINE [3] '+' not a valid variable name
|
||||
PARSE ERROR: CODE [67] LINE [3] '+' not a valid variable name
|
||||
|
@ -2,4 +2,4 @@ BEGIN {
|
||||
print abc > "123\0abc";
|
||||
}
|
||||
|
||||
RUN ERROR: CODE [114] LINE [2] i/o name containing a null character
|
||||
RUN ERROR: CODE [115] LINE [2] i/o name containing a null character
|
||||
|
@ -3,4 +3,4 @@ BEGIN {
|
||||
split ("a b c",xx);
|
||||
}
|
||||
|
||||
RUN ERROR: CODE [99] LINE [3] cannot change a scalar value to a map
|
||||
RUN ERROR: CODE [100] LINE [3] cannot change a scalar value to a map
|
||||
|
@ -1 +1 @@
|
||||
PARSE ERROR: CODE [63] LINE [1] duplicate global variable 'ARGV'
|
||||
PARSE ERROR: CODE [64] LINE [1] duplicate global variable 'ARGV'
|
||||
|
Loading…
Reference in New Issue
Block a user