1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
/****************************************************************
* *
* Copyright 2001, 2012 Fidelity Information Services, Inc *
* *
* 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 "job.h"
#include "advancewindow.h"
#include "cmd.h"
GBLREF boolean_t run_time;
GBLREF mident routine_name;
LITREF mident zero_ident;
error_def(ERR_COMMAORRPAREXP);
error_def(ERR_JOBACTREF);
error_def(ERR_MAXACTARG);
error_def(ERR_RTNNAME);
int m_job(void)
{
boolean_t is_timeout, dummybool;
static readonly unsigned char empty_plist[1] = { jp_eol };
int argcnt;
oprtype arglst, *argptr, argval, label, offset, routine, plist, timeout;
triple *next, *ref;
DCL_THREADGBL_ACCESS;
SETUP_THREADGBL_ACCESS;
label = put_str(zero_ident.addr, zero_ident.len);
offset = put_ilit((mint)0);
if (!lref(&label, &offset, FALSE, indir_job, TRUE, &dummybool))
return FALSE;
if ((TRIP_REF == label.oprclass) && (OC_COMMARG == label.oprval.tref->opcode))
return TRUE;
if (TK_CIRCUMFLEX != TREF(window_token))
{
if (!run_time)
routine = put_str(routine_name.addr, routine_name.len);
else
routine = put_tref(newtriple(OC_CURRTN));
} else
{
advancewindow();
switch (TREF(window_token))
{
case TK_IDENT:
routine = put_str((TREF(window_ident)).addr, (TREF(window_ident)).len);
advancewindow();
break;
case TK_ATSIGN:
if (!indirection(&routine))
return FALSE;
break;
default:
stx_error(ERR_RTNNAME);
return FALSE;
}
}
argcnt = 0;
if (TK_LPAREN == TREF(window_token))
{
advancewindow();
argptr = &arglst;
while (TK_RPAREN != TREF(window_token))
{
if (MAX_ACTUALS < argcnt)
{
stx_error(ERR_MAXACTARG);
return FALSE;
}
if (TK_PERIOD == TREF(window_token))
{
stx_error(ERR_JOBACTREF);
return FALSE;
}
if (TK_COMMA == TREF(window_token))
{
ref = newtriple(OC_NULLEXP);
argval = put_tref(ref);
} else if (EXPR_FAIL == expr(&argval, MUMPS_EXPR))
return FALSE;
ref = newtriple(OC_PARAMETER);
ref->operand[0] = argval;
*argptr = put_tref(ref);
argptr = &ref->operand[1];
argcnt++;
if (TK_COMMA == TREF(window_token))
advancewindow();
else if (TK_RPAREN != TREF(window_token))
{
stx_error(ERR_COMMAORRPAREXP);
return FALSE;
}
}
advancewindow(); /* jump over close paren */
}
if (TK_COLON == TREF(window_token))
{
advancewindow();
if (TK_COLON == TREF(window_token))
{
is_timeout = TRUE;
plist = put_str((char *)empty_plist,SIZEOF(empty_plist));
} else
{
if (!jobparameters(&plist))
return FALSE;
is_timeout = (TK_COLON == TREF(window_token));
}
if (is_timeout)
{
advancewindow();
if (EXPR_FAIL == expr(&timeout, MUMPS_INT))
return FALSE;
} else
timeout = put_ilit(NO_M_TIMEOUT);
} else
{
is_timeout = FALSE;
plist = put_str((char *)empty_plist,SIZEOF(empty_plist));
timeout = put_ilit(NO_M_TIMEOUT);
}
ref = newtriple(OC_JOB);
ref->operand[0] = put_ilit(argcnt + 5); /* parameter list + five fixed arguments */
next = newtriple(OC_PARAMETER);
ref->operand[1] = put_tref(next);
next->operand[0] = label;
ref = newtriple(OC_PARAMETER);
next->operand[1] = put_tref(ref);
ref->operand[0] = offset;
next = newtriple(OC_PARAMETER);
ref->operand[1] = put_tref(next);
next->operand[0] = routine;
ref = newtriple(OC_PARAMETER);
next->operand[1] = put_tref(ref);
ref->operand[0] = plist;
next = newtriple(OC_PARAMETER);
ref->operand[1] = put_tref(next);
next->operand[0] = timeout;
if (argcnt)
next->operand[1] = arglst;
if (is_timeout)
newtriple(OC_TIMTRU);
return TRUE;
}
|