[COMPILER]

* BUG: Fix array creation operator when it has no arguments.

[INTERPRETER]
* BUG: Fix array creation operator when it has no arguments.


git-svn-id: svn://localhost/gambas/trunk@6114 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2014-01-28 16:17:40 +00:00
parent 412d19069c
commit a2c9e25e00
6 changed files with 20 additions and 30 deletions

View file

@ -68,10 +68,10 @@ static void trans_subr(int subr, int nparam)
ERROR_panic("Unknown intern subroutine: %s", tsi->name);
}
if (subr == TS_SUBR_ARRAY && nparam == 0)
CODE_subr(tsi->info->opcode, MAX_PARAM_OP + 1, 0, TRUE);
else if (subr == TS_SUBR_COLLECTION && nparam == 0)
CODE_subr(tsi->info->opcode, MAX_PARAM_OP, 0, TRUE);
if (subr == TS_SUBR_ARRAY && nparam > MAX_PARAM_OP)
CODE_subr(tsi->info->opcode, MAX_PARAM_OP + 1, CODE_CALL_VARIANT + MAX_PARAM_OP, FALSE);
else if (subr == TS_SUBR_COLLECTION && nparam > MAX_PARAM_OP)
CODE_subr(tsi->info->opcode, MAX_PARAM_OP, CODE_CALL_VARIANT + MAX_PARAM_OP - 1, FALSE);
else
CODE_subr(tsi->info->opcode, nparam, tsi->info->optype, tsi->info->min_param == tsi->info->max_param);

View file

@ -267,13 +267,14 @@ static void analyze_make_array()
if (!PATTERN_is(*current, RS_COMMA))
break;
current++;
if (collection)
{
if (n == (MAX_PARAM_OP - 1))
{
add_operator(RS_COLON, 0);
add_operator(RS_COLON, MAX_PARAM_OP + 1);
n = 0;
}
}
@ -281,7 +282,7 @@ static void analyze_make_array()
{
if (n == MAX_PARAM_OP)
{
add_operator(RS_RSQR, 0);
add_operator(RS_RSQR, MAX_PARAM_OP + 1);
n = 0;
}
}

View file

@ -189,6 +189,9 @@ TYPE SUBR_check_good_type(VALUE *param, int count)
int i;
TYPE type, type2;
if (count == 0)
goto __VARIANT;
type = conv_type(param[0].type);
if (TYPE_is_value(type))

View file

@ -299,14 +299,7 @@ void SUBR_array(ushort code)
SUBR_ENTER();
if (NPARAM == 0)
{
NPARAM = MAX_PARAM_OP;
PARAM -= NPARAM;
next_reuse = TRUE;
}
else
next_reuse = FALSE;
next_reuse = code & CODE_CALL_VARIANT;
if (reuse)
{
@ -369,14 +362,7 @@ void SUBR_collection(ushort code)
SUBR_ENTER();
if (NPARAM == 0)
{
NPARAM = MAX_PARAM_OP - 1;
PARAM -= NPARAM;
next_reuse = TRUE;
}
else
next_reuse = FALSE;
next_reuse = code & CODE_CALL_VARIANT;
if (reuse)
col = (GB_COLLECTION)(PARAM[-1]._object.object);

View file

@ -221,18 +221,18 @@ void TRANS_operation(short op, short nparam, PATTERN previous)
case OP_RSQR:
find_subr(&subr_array_index, ".Array");
if (nparam)
trans_subr(subr_array_index, nparam);
if (nparam > MAX_PARAM_OP)
CODE_subr(COMP_subr_info[subr_array_index].opcode, MAX_PARAM_OP + 1, CODE_CALL_VARIANT + MAX_PARAM_OP, FALSE);
else
CODE_subr(COMP_subr_info[subr_array_index].opcode, MAX_PARAM_OP + 1, 0, TRUE);
trans_subr(subr_array_index, nparam);
break;
case OP_COLON:
find_subr(&subr_collection_index, ".Collection");
if (nparam)
trans_subr(subr_collection_index, nparam);
if (nparam > MAX_PARAM_OP)
CODE_subr(COMP_subr_info[subr_collection_index].opcode, MAX_PARAM_OP, CODE_CALL_VARIANT + MAX_PARAM_OP - 1, FALSE);
else
CODE_subr(COMP_subr_info[subr_collection_index].opcode, MAX_PARAM_OP, 0, TRUE);
trans_subr(subr_collection_index, nparam);
break;
case OP_LBRA:

View file

@ -217,7 +217,7 @@ static void analyze_make_array()
{
if (n == (MAX_PARAM_OP - 1))
{
add_operator(RS_COLON, 0);
add_operator(RS_COLON, MAX_PARAM_OP + 1);
n = 0;
}
}
@ -225,7 +225,7 @@ static void analyze_make_array()
{
if (n == MAX_PARAM_OP)
{
add_operator(RS_RSQR, 0);
add_operator(RS_RSQR, MAX_PARAM_OP + 1);
n = 0;
}
}