diff --git a/main/gbc/gbc_trans_subr.c b/main/gbc/gbc_trans_subr.c index 577e42568..32438363e 100644 --- a/main/gbc/gbc_trans_subr.c +++ b/main/gbc/gbc_trans_subr.c @@ -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); diff --git a/main/gbc/gbc_trans_tree.c b/main/gbc/gbc_trans_tree.c index a7432d141..b9a696557 100644 --- a/main/gbc/gbc_trans_tree.c +++ b/main/gbc/gbc_trans_tree.c @@ -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; } } diff --git a/main/gbx/gbx_subr.c b/main/gbx/gbx_subr.c index bd92c51bd..6396f8833 100644 --- a/main/gbx/gbx_subr.c +++ b/main/gbx/gbx_subr.c @@ -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)) diff --git a/main/gbx/gbx_subr_misc.c b/main/gbx/gbx_subr_misc.c index 5c57b40cf..6e2841795 100644 --- a/main/gbx/gbx_subr_misc.c +++ b/main/gbx/gbx_subr_misc.c @@ -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); diff --git a/main/lib/eval/eval_trans_expr.c b/main/lib/eval/eval_trans_expr.c index 355115357..72f880e71 100644 --- a/main/lib/eval/eval_trans_expr.c +++ b/main/lib/eval/eval_trans_expr.c @@ -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: diff --git a/main/lib/eval/eval_trans_tree.c b/main/lib/eval/eval_trans_tree.c index 3ca666c75..f0a390cb7 100644 --- a/main/lib/eval/eval_trans_tree.c +++ b/main/lib/eval/eval_trans_tree.c @@ -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; } }