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 "indir_enum.h"
|
|
|
|
#include "toktyp.h"
|
|
|
|
#include "iotimer.h"
|
|
|
|
#include "mdq.h"
|
|
|
|
#include "advancewindow.h"
|
|
|
|
#include "cmd.h"
|
|
|
|
#include "rwformat.h"
|
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
error_def(ERR_RWARG);
|
2012-02-05 11:35:58 -05:00
|
|
|
|
|
|
|
int m_read(void)
|
|
|
|
{
|
|
|
|
boolean_t local;
|
2012-03-24 14:06:46 -04:00
|
|
|
opctype put_oc, read_oc;
|
|
|
|
oprtype *timeout, x;
|
|
|
|
triple *put, *ref, *s1, *sub, tmpchain;
|
2012-02-05 11:35:58 -05:00
|
|
|
DCL_THREADGBL_ACCESS;
|
|
|
|
|
|
|
|
SETUP_THREADGBL_ACCESS;
|
|
|
|
TREF(temp_subs) = FALSE;
|
|
|
|
local = TRUE;
|
|
|
|
dqinit(&tmpchain, exorder);
|
2012-03-24 14:06:46 -04:00
|
|
|
switch (TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
case TK_ASTERISK:
|
|
|
|
advancewindow();
|
2012-03-24 14:06:46 -04:00
|
|
|
switch (TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
default:
|
|
|
|
case TK_IDENT:
|
|
|
|
if (!lvn(&x, OC_PUTINDX, 0))
|
|
|
|
return FALSE;
|
|
|
|
if (OC_PUTINDX == x.oprval.tref->opcode)
|
|
|
|
{
|
|
|
|
dqdel(x.oprval.tref, exorder);
|
|
|
|
dqins(tmpchain.exorder.bl, exorder, x.oprval.tref);
|
|
|
|
sub = x.oprval.tref;
|
|
|
|
put_oc = OC_PUTINDX;
|
|
|
|
}
|
|
|
|
put = maketriple(OC_STO);
|
|
|
|
put->operand[0] = x;
|
|
|
|
dqins(tmpchain.exorder.bl, exorder, put);
|
|
|
|
break;
|
|
|
|
case TK_CIRCUMFLEX:
|
|
|
|
local = FALSE;
|
2012-03-24 14:06:46 -04:00
|
|
|
s1 = (TREF(curtchain))->exorder.bl;
|
2012-02-05 11:35:58 -05:00
|
|
|
if (!gvn())
|
|
|
|
return FALSE;
|
2012-03-24 14:06:46 -04:00
|
|
|
for (sub = (TREF(curtchain))->exorder.bl; sub != s1; sub = sub->exorder.bl)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
put_oc = sub->opcode;
|
|
|
|
if ((OC_GVNAME == put_oc) || (OC_GVNAKED == put_oc) || (OC_GVEXTNAM == put_oc))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
assert((OC_GVNAME == put_oc) || (OC_GVNAKED == put_oc) || (OC_GVEXTNAM == put_oc));
|
|
|
|
dqdel(sub, exorder);
|
|
|
|
dqins(tmpchain.exorder.bl, exorder, sub);
|
|
|
|
put = maketriple(OC_GVPUT);
|
|
|
|
dqins(tmpchain.exorder.bl, exorder, put);
|
|
|
|
break;
|
|
|
|
case TK_ATSIGN:
|
|
|
|
if (!indirection(&x))
|
|
|
|
return FALSE;
|
|
|
|
put = maketriple(OC_INDSET);
|
|
|
|
put->operand[0] = x;
|
|
|
|
dqins(tmpchain.exorder.bl, exorder, put);
|
|
|
|
break;
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_HASH == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
stx_error(ERR_RWARG);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
read_oc = OC_RDONE;
|
|
|
|
break;
|
|
|
|
case TK_QUESTION:
|
|
|
|
case TK_EXCLAIMATION:
|
|
|
|
case TK_HASH:
|
|
|
|
case TK_SLASH:
|
|
|
|
return rwformat();
|
|
|
|
case TK_STRLIT:
|
2012-03-24 14:06:46 -04:00
|
|
|
x = put_lit(&(TREF(window_mval)));
|
2012-02-05 11:35:58 -05:00
|
|
|
advancewindow();
|
|
|
|
ref = newtriple(OC_WRITE);
|
|
|
|
ref->operand[0] = x;
|
|
|
|
return TRUE;
|
|
|
|
case TK_IDENT:
|
|
|
|
if (!lvn(&x, OC_PUTINDX, 0))
|
|
|
|
return FALSE;
|
|
|
|
read_oc = OC_READ;
|
|
|
|
if (OC_PUTINDX == x.oprval.tref->opcode)
|
|
|
|
{
|
|
|
|
dqdel(x.oprval.tref, exorder);
|
|
|
|
dqins(tmpchain.exorder.bl, exorder, x.oprval.tref);
|
|
|
|
sub = x.oprval.tref;
|
|
|
|
put_oc = OC_PUTINDX;
|
|
|
|
}
|
|
|
|
put = maketriple(OC_STO);
|
|
|
|
put->operand[0] = x;
|
|
|
|
dqins(tmpchain.exorder.bl, exorder, put);
|
|
|
|
break;
|
|
|
|
case TK_CIRCUMFLEX:
|
|
|
|
local = FALSE;
|
|
|
|
read_oc = OC_READ;
|
2012-03-24 14:06:46 -04:00
|
|
|
s1 = (TREF(curtchain))->exorder.bl;
|
2012-02-05 11:35:58 -05:00
|
|
|
if (!gvn())
|
|
|
|
return FALSE;
|
2012-03-24 14:06:46 -04:00
|
|
|
for (sub = (TREF(curtchain))->exorder.bl; sub != s1; sub = sub->exorder.bl)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
put_oc = sub->opcode;
|
|
|
|
if ((OC_GVNAME == put_oc) || (OC_GVNAKED == put_oc) || (OC_GVEXTNAM == put_oc))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
assert((OC_GVNAME == put_oc) || (OC_GVNAKED == put_oc) || (OC_GVEXTNAM == put_oc));
|
|
|
|
dqdel(sub, exorder);
|
|
|
|
dqins(tmpchain.exorder.bl, exorder, sub);
|
|
|
|
put = maketriple(OC_GVPUT);
|
|
|
|
dqins(tmpchain.exorder.bl, exorder, put);
|
|
|
|
break;
|
|
|
|
case TK_ATSIGN:
|
|
|
|
if (!indirection(&x))
|
|
|
|
return FALSE;
|
2012-03-24 14:06:46 -04:00
|
|
|
if ((TK_COLON != TREF(window_token)) && (TK_HASH != TREF(window_token)))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
ref = maketriple(OC_COMMARG);
|
|
|
|
ref->operand[0] = x;
|
|
|
|
ref->operand[1] = put_ilit(indir_read);
|
|
|
|
ins_triple(ref);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
put = maketriple(OC_INDSET);
|
|
|
|
put->operand[0] = x;
|
|
|
|
dqins(tmpchain.exorder.bl, exorder, put);
|
|
|
|
read_oc = OC_READ;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stx_error(ERR_RWARG);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_HASH == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
advancewindow();
|
|
|
|
ref = maketriple(OC_READFL);
|
2012-03-24 14:06:46 -04:00
|
|
|
if (EXPR_FAIL == expr(&ref->operand[0], MUMPS_INT))
|
2012-02-05 11:35:58 -05:00
|
|
|
return FALSE;
|
|
|
|
timeout = &ref->operand[1];
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
ref = maketriple(read_oc);
|
|
|
|
timeout = &ref->operand[0];
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_COLON != TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
*timeout = put_ilit(NO_M_TIMEOUT);
|
|
|
|
ins_triple(ref);
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
advancewindow();
|
2012-03-24 14:06:46 -04:00
|
|
|
if (EXPR_FAIL == expr(timeout, MUMPS_INT))
|
2012-02-05 11:35:58 -05:00
|
|
|
return FALSE;
|
|
|
|
ins_triple(ref);
|
|
|
|
newtriple(OC_TIMTRU);
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
put->operand[local ? 1 : 0] = put_tref(ref);
|
|
|
|
ref = (TREF(curtchain))->exorder.bl;
|
2012-02-05 11:35:58 -05:00
|
|
|
dqadd(ref, &tmpchain, exorder); /*this is a violation of info hiding*/
|
|
|
|
return TRUE;
|
|
|
|
}
|