2012-02-05 11:35:58 -05:00
|
|
|
/****************************************************************
|
|
|
|
* *
|
2024-07-19 11:43:27 -04:00
|
|
|
* Copyright 2004, 2012 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 "toktyp.h"
|
|
|
|
#include "compiler.h"
|
|
|
|
#include "opcode.h"
|
|
|
|
#include "indir_enum.h"
|
|
|
|
#include "mdq.h"
|
|
|
|
#include "cache.h"
|
|
|
|
#include "hashtab_objcode.h"
|
|
|
|
#include "op.h"
|
|
|
|
#include "mvalconv.h" /* for i2mval prototype for the MV_FORCE_MVAL macro */
|
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
|
|
|
|
|
|
|
void op_indincr(mval *dst, mval *increment, mval *target)
|
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
icode_str indir_src;
|
|
|
|
int rval;
|
|
|
|
mstr *obj, object;
|
2024-07-19 11:43:27 -04:00
|
|
|
oprtype v, getdst;
|
2012-02-05 11:35:58 -05:00
|
|
|
triple *s, *src, *oldchain, tmpchain, *triptr;
|
|
|
|
DCL_THREADGBL_ACCESS;
|
|
|
|
|
|
|
|
SETUP_THREADGBL_ACCESS;
|
|
|
|
MV_FORCE_STR(target);
|
|
|
|
indir_src.str = target->str;
|
|
|
|
indir_src.code = indir_increment;
|
|
|
|
if (NULL == (obj = cache_get(&indir_src)))
|
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
obj = &object;
|
2024-07-19 11:43:27 -04:00
|
|
|
comp_init(&target->str, &getdst);
|
2012-02-05 11:35:58 -05:00
|
|
|
src = newtriple(OC_IGETSRC);
|
2012-03-24 14:06:46 -04:00
|
|
|
switch (TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
case TK_IDENT:
|
|
|
|
if (EXPR_FAIL != (rval = lvn(&v, OC_PUTINDX, 0))) /* NOTE assignment */
|
|
|
|
{
|
|
|
|
s = newtriple(OC_FNINCR);
|
|
|
|
s->operand[0] = v;
|
|
|
|
s->operand[1] = put_tref(src);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TK_CIRCUMFLEX:
|
|
|
|
if (EXPR_FAIL != (rval = gvn())) /* NOTE assignment */
|
|
|
|
{
|
|
|
|
s = newtriple(OC_GVINCR);
|
|
|
|
/* dummy fill below since emit_code does not like empty operand[0] */
|
|
|
|
s->operand[0] = put_ilit(0);
|
|
|
|
s->operand[1] = put_tref(src);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TK_ATSIGN:
|
|
|
|
TREF(saw_side_effect) = TREF(shift_side_effects);
|
|
|
|
if (TREF(shift_side_effects) && (GTM_BOOL == TREF(gtm_fullbool)))
|
|
|
|
{
|
|
|
|
dqinit(&tmpchain, exorder);
|
|
|
|
oldchain = setcurtchain(&tmpchain);
|
|
|
|
if (EXPR_FAIL != (rval = indirection(&v))) /* NOTE assignment */
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
s = newtriple(OC_INDINCR);
|
2012-02-05 11:35:58 -05:00
|
|
|
s->operand[0] = v;
|
|
|
|
s->operand[1] = put_tref(src);
|
2012-03-24 14:06:46 -04:00
|
|
|
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));
|
2012-02-05 11:35:58 -05:00
|
|
|
} else
|
2012-03-24 14:06:46 -04:00
|
|
|
setcurtchain(oldchain);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
if (EXPR_FAIL != (rval = indirection(&v))) /* NOTE assignment */
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
s = newtriple(OC_INDINCR);
|
|
|
|
s->operand[0] = v;
|
|
|
|
s->operand[1] = put_tref(src);
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stx_error(ERR_VAREXPECTED);
|
|
|
|
rval = EXPR_FAIL;
|
|
|
|
break;
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|
|
|
|
v = put_tref(s);
|
2024-07-19 11:43:27 -04:00
|
|
|
if (EXPR_FAIL == comp_fini(rval, obj, OC_IRETMVAL, &v, &getdst, target->str.len))
|
2012-03-24 14:06:46 -04:00
|
|
|
return;
|
|
|
|
indir_src.str.addr = target->str.addr;
|
|
|
|
cache_put(&indir_src, obj);
|
|
|
|
/* Fall into code activation below */
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|
2024-07-19 11:43:27 -04:00
|
|
|
TREF(ind_result) = dst;
|
|
|
|
TREF(ind_source) = increment;
|
2012-03-24 14:06:46 -04:00
|
|
|
comp_indr(obj);
|
|
|
|
return;
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|