[INTERPRETER]

* BUG: Correctly drop arguments when using the new '...' symbol syntax.

[COMPILER]
* BUG: Correctly drop arguments when using the new '...' symbol syntax.


git-svn-id: svn://localhost/gambas/trunk@6252 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2014-05-05 20:16:41 +00:00
parent cbd63b46a8
commit 3f9d37a858
7 changed files with 43 additions and 4 deletions

View File

@ -39,6 +39,8 @@
//static bool _accept_statement = FALSE;
static bool _must_drop_vargs = FALSE;
static short get_nparam(PATTERN *tree, int count, int *pindex, uint64_t *byref)
{
PATTERN pattern;
@ -325,6 +327,12 @@ static void trans_call(short nparam, uint64_t byref)
}
CODE_call_byref(nparam, byref);
if (_must_drop_vargs)
{
CODE_drop_vargs();
_must_drop_vargs = FALSE;
}
}
static void trans_expr_from_tree(TRANS_TREE *tree, int count)
@ -426,6 +434,7 @@ static void trans_expr_from_tree(TRANS_TREE *tree, int count)
}
else if (PATTERN_is(pattern, RS_3PTS))
{
_must_drop_vargs = TRUE;
CODE_push_vargs();
}
else

View File

@ -2031,3 +2031,13 @@ void EXEC_push_vargs(void)
PUSH();
}
}
void EXEC_drop_vargs(void)
{
int nargs = (FP && FP->vararg) ? BP - PP : 0;
if (nargs == 0)
return;
RELEASE_MANY(SP, nargs);
}

View File

@ -230,6 +230,7 @@ void RELEASE_many(VALUE *val, int n);
void EXEC_push_complex(void);
void EXEC_push_vargs(void);
void EXEC_drop_vargs(void);
#define BORROW(_value) \
do { \

View File

@ -786,7 +786,8 @@ _PUSH_MISC:
{
static const void *_jump[] =
{ &&__PUSH_NULL, &&__PUSH_VOID, &&__PUSH_FALSE, &&__PUSH_TRUE, &&__PUSH_LAST, &&__PUSH_STRING, &&__PUSH_PINF, &&__PUSH_MINF, &&__PUSH_COMPLEX, &&__PUSH_VARGS };
{ &&__PUSH_NULL, &&__PUSH_VOID, &&__PUSH_FALSE, &&__PUSH_TRUE, &&__PUSH_LAST, &&__PUSH_STRING, &&__PUSH_PINF, &&__PUSH_MINF, &&__PUSH_COMPLEX,
&&__PUSH_VARGS, &&__PUSH_DROP_VARGS };
//, &&__POP_LAST };
goto *_jump[GET_UX()];
@ -854,9 +855,15 @@ _PUSH_MISC:
goto _NEXT;
__PUSH_VARGS:
EXEC_push_vargs();
goto _NEXT;
__PUSH_DROP_VARGS:
EXEC_drop_vargs();
goto _NEXT;
/*__POP_LAST:
VALUE_conv(&SP[-1], T_OBJECT);

View File

@ -125,7 +125,9 @@ void CODE_push_void_string();
void CODE_push_boolean(bool value);
void CODE_push_inf(bool neg);
void CODE_push_complex();
void CODE_push_vargs();
void CODE_drop_vargs();
void CODE_dup(void);

View File

@ -1358,8 +1358,6 @@ void CODE_push_vargs(void)
{
LAST_CODE;
use_stack(0);
#ifdef DEBUG
printf("PUSH VARGS\n");
#endif
@ -1367,6 +1365,17 @@ void CODE_push_vargs(void)
write_ZZxx(C_PUSH_MISC, CPM_VARGS);
}
void CODE_drop_vargs(void)
{
LAST_CODE;
#ifdef DEBUG
printf("DROP VARGS\n");
#endif
write_ZZxx(C_PUSH_MISC, CPM_DROP_VARGS);
}
#ifdef CODE_DUMP
void CODE_dump(PCODE *code, int count)

View File

@ -78,6 +78,7 @@
#define CPM_MINF 7
#define CPM_COMPLEX 8
#define CPM_VARGS 9
#define CPM_DROP_VARGS 10
#define C_TRY 0x1600
#define C_END_TRY 0x1700