2012-02-05 11:35:58 -05:00
|
|
|
/****************************************************************
|
|
|
|
* *
|
2012-03-24 14:06:46 -04:00
|
|
|
* Copyright 2001, 2011 Fidelity Information Services, Inc *
|
2012-02-05 11:35:58 -05:00
|
|
|
* *
|
|
|
|
* This source code contains the intellectual property *
|
|
|
|
* of its copyright holder(s), and is made available *
|
|
|
|
* under a license. If you do not know the terms of *
|
|
|
|
* the license, please stop and do not read further. *
|
|
|
|
* *
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include "mdef.h"
|
|
|
|
#include "compiler.h"
|
|
|
|
#include "opcode.h"
|
|
|
|
#include "toktyp.h"
|
|
|
|
#include "subscript.h"
|
|
|
|
#include "advancewindow.h"
|
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
error_def(ERR_LPARENMISSING);
|
|
|
|
error_def(ERR_MAXNRSUBSCRIPTS);
|
|
|
|
error_def(ERR_RPARENMISSING);
|
2012-02-05 11:35:58 -05:00
|
|
|
|
|
|
|
int indirection(oprtype *a)
|
|
|
|
{
|
|
|
|
char c;
|
2012-03-24 14:06:46 -04:00
|
|
|
oprtype *sb1, *sb2, subs[MAX_INDSUBSCRIPTS], x;
|
|
|
|
triple *next, *ref;
|
2012-02-05 11:35:58 -05:00
|
|
|
DCL_THREADGBL_ACCESS;
|
|
|
|
|
|
|
|
SETUP_THREADGBL_ACCESS;
|
2012-03-24 14:06:46 -04:00
|
|
|
assert(TK_ATSIGN == TREF(window_token));
|
2012-02-05 11:35:58 -05:00
|
|
|
if (!(TREF(expr_depth))++)
|
|
|
|
TREF(expr_start) = TREF(expr_start_orig) = NULL;
|
|
|
|
advancewindow();
|
|
|
|
if (!expratom(a))
|
|
|
|
{
|
|
|
|
TREF(expr_depth) = 0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
coerce(a, OCT_MVAL);
|
2012-02-05 11:35:58 -05:00
|
|
|
ex_tail(a);
|
|
|
|
if (!(--(TREF(expr_depth))))
|
|
|
|
TREF(shift_side_effects) = FALSE;
|
2012-03-24 14:06:46 -04:00
|
|
|
TREF(saw_side_effect) = TREF(shift_side_effects); /* TRUE or FALSE, at this point they're the same */
|
|
|
|
if (TK_ATSIGN == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
advancewindow();
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_LPAREN != TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
stx_error(ERR_LPARENMISSING);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ref = maketriple(OC_INDNAME);
|
|
|
|
sb1 = sb2 = subs;
|
|
|
|
for (;;)
|
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
if (ARRAYTOP(subs) <= sb1)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
stx_error(ERR_MAXNRSUBSCRIPTS);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
advancewindow();
|
2012-03-24 14:06:46 -04:00
|
|
|
if (EXPR_FAIL == expr(sb1++, MUMPS_EXPR))
|
2012-02-05 11:35:58 -05:00
|
|
|
return FALSE;
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_RPAREN == (c = TREF(window_token))) /* NOTE assignment */
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
advancewindow();
|
|
|
|
break;
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_COMMA != c)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
stx_error(ERR_RPARENMISSING);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* store argument count...n args plus the name plus the dst*/
|
|
|
|
ref->operand[0] = put_ilit((mint)(sb1 - sb2) + 2);
|
|
|
|
ins_triple(ref);
|
|
|
|
next = newtriple(OC_PARAMETER);
|
|
|
|
next->operand[0] = *a;
|
|
|
|
ref->operand[1] = put_tref(next);
|
|
|
|
*a = put_tref(ref);
|
|
|
|
while (sb2 < sb1)
|
|
|
|
{
|
|
|
|
ref = newtriple(OC_PARAMETER);
|
|
|
|
next->operand[1] = put_tref(ref);
|
|
|
|
ref->operand[0] = *sb2++;
|
|
|
|
next = ref;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|