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 "indir_enum.h"
|
|
|
|
#include "mdq.h"
|
|
|
|
#include "mmemory.h"
|
|
|
|
#include "advancewindow.h"
|
2012-03-24 14:06:46 -04:00
|
|
|
#include "fullbool.h"
|
2012-02-05 11:35:58 -05:00
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
error_def(ERR_VAREXPECTED);
|
2012-02-05 11:35:58 -05:00
|
|
|
|
|
|
|
int f_get(oprtype *a, opctype op)
|
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
triple *oldchain, *r, tmpchain, *triptr;
|
2012-02-05 11:35:58 -05:00
|
|
|
oprtype result, *result_ptr;
|
|
|
|
DCL_THREADGBL_ACCESS;
|
|
|
|
|
|
|
|
SETUP_THREADGBL_ACCESS;
|
|
|
|
result_ptr = (oprtype *)mcalloc(SIZEOF(oprtype));
|
|
|
|
result = put_indr(result_ptr);
|
|
|
|
r = maketriple(op);
|
2012-03-24 14:06:46 -04:00
|
|
|
switch (TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
case TK_IDENT:
|
|
|
|
if (!lvn(&r->operand[0], OC_SRCHINDX, 0))
|
|
|
|
return FALSE;
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_COMMA != TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
ins_triple(r);
|
|
|
|
*a = put_tref(r);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
r->opcode = OC_FNGET2;
|
|
|
|
r->operand[1] = result;
|
|
|
|
break;
|
|
|
|
case TK_CIRCUMFLEX:
|
|
|
|
if (!gvn())
|
|
|
|
return FALSE;
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_COMMA == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{ /* 2-argument $GET with global-variable as first argument. In this case generate the following
|
|
|
|
* sequence of opcodes. OC_FNGVGET1, opcodes-to-evaluate-second-argument-expression, OC_FNGVGET2
|
|
|
|
*/
|
|
|
|
r->opcode = OC_FNGVGET1;
|
|
|
|
ins_triple(r);
|
|
|
|
triptr = r;
|
|
|
|
/* Prepare triple for OC_FNGVGET2 */
|
|
|
|
r = maketriple(op);
|
|
|
|
r->opcode = OC_FNGVGET2;
|
|
|
|
r->operand[0] = put_tref(triptr);
|
|
|
|
r->operand[1] = result;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
r->opcode = OC_FNGVGET;
|
|
|
|
r->operand[0] = result;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TK_ATSIGN:
|
|
|
|
r->opcode = OC_INDGET;
|
2012-03-24 14:06:46 -04:00
|
|
|
TREF(saw_side_effect) = TREF(shift_side_effects);
|
|
|
|
if (TREF(shift_side_effects) && (GTM_BOOL == TREF(gtm_fullbool)))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
dqinit(&tmpchain, exorder);
|
|
|
|
oldchain = setcurtchain(&tmpchain);
|
|
|
|
if (!indirection(&r->operand[0]))
|
|
|
|
{
|
|
|
|
setcurtchain(oldchain);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
r->operand[1] = result;
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_COMMA == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
advancewindow();
|
2012-03-24 14:06:46 -04:00
|
|
|
if (EXPR_FAIL == expr(result_ptr, MUMPS_EXPR))
|
2012-02-05 11:35:58 -05:00
|
|
|
return FALSE;
|
|
|
|
} else
|
|
|
|
*result_ptr = put_str(0, 0);
|
|
|
|
ins_triple(r);
|
|
|
|
newtriple(OC_GVSAVTARG);
|
|
|
|
setcurtchain(oldchain);
|
|
|
|
dqadd(TREF(expr_start), &tmpchain, exorder);
|
|
|
|
TREF(expr_start) = tmpchain.exorder.bl;
|
|
|
|
triptr = newtriple(OC_GVRECTARG);
|
|
|
|
triptr->operand[0] = put_tref(TREF(expr_start));
|
|
|
|
*a = put_tref(r);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
if (!indirection(&r->operand[0]))
|
|
|
|
return FALSE;
|
|
|
|
r->operand[1] = result;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stx_error(ERR_VAREXPECTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_COMMA == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
advancewindow();
|
2012-03-24 14:06:46 -04:00
|
|
|
if (EXPR_FAIL == expr(result_ptr, MUMPS_EXPR))
|
2012-02-05 11:35:58 -05:00
|
|
|
return FALSE;
|
|
|
|
} else
|
|
|
|
*result_ptr = put_str(0, 0);
|
|
|
|
ins_triple(r);
|
|
|
|
*a = put_tref(r);
|
|
|
|
return TRUE;
|
|
|
|
}
|