2012-02-05 11:35:58 -05:00
|
|
|
/****************************************************************
|
|
|
|
* *
|
2012-03-24 14:06:46 -04:00
|
|
|
* Copyright 2001, 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 "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;
|
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
error_def(ERR_COMMAORRPAREXP);
|
|
|
|
error_def(ERR_JOBACTREF);
|
|
|
|
error_def(ERR_MAXACTARG);
|
|
|
|
error_def(ERR_RTNNAME);
|
|
|
|
|
2012-02-05 11:35:58 -05:00
|
|
|
int m_job(void)
|
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
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;
|
2012-02-05 11:35:58 -05:00
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
SETUP_THREADGBL_ACCESS;
|
2012-02-05 11:35:58 -05:00
|
|
|
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;
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_CIRCUMFLEX != TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
if (!run_time)
|
|
|
|
routine = put_str(routine_name.addr, routine_name.len);
|
|
|
|
else
|
|
|
|
routine = put_tref(newtriple(OC_CURRTN));
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
advancewindow();
|
2012-03-24 14:06:46 -04:00
|
|
|
switch (TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
case TK_IDENT:
|
2012-03-24 14:06:46 -04:00
|
|
|
routine = put_str((TREF(window_ident)).addr, (TREF(window_ident)).len);
|
2012-02-05 11:35:58 -05:00
|
|
|
advancewindow();
|
|
|
|
break;
|
|
|
|
case TK_ATSIGN:
|
|
|
|
if (!indirection(&routine))
|
|
|
|
return FALSE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
stx_error(ERR_RTNNAME);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
argcnt = 0;
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_LPAREN == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
advancewindow();
|
|
|
|
argptr = &arglst;
|
2012-03-24 14:06:46 -04:00
|
|
|
while (TK_RPAREN != TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
if (MAX_ACTUALS < argcnt)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
stx_error(ERR_MAXACTARG);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_PERIOD == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
stx_error(ERR_JOBACTREF);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_COMMA == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
ref = newtriple(OC_NULLEXP);
|
|
|
|
argval = put_tref(ref);
|
2012-03-24 14:06:46 -04:00
|
|
|
} else if (EXPR_FAIL == expr(&argval, MUMPS_EXPR))
|
2012-02-05 11:35:58 -05:00
|
|
|
return FALSE;
|
|
|
|
ref = newtriple(OC_PARAMETER);
|
|
|
|
ref->operand[0] = argval;
|
|
|
|
*argptr = put_tref(ref);
|
|
|
|
argptr = &ref->operand[1];
|
|
|
|
argcnt++;
|
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
|
|
|
else if (TK_RPAREN != TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
stx_error(ERR_COMMAORRPAREXP);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
}
|
2012-02-05 11:35:58 -05:00
|
|
|
advancewindow(); /* jump over close paren */
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_COLON == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
advancewindow();
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_COLON == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
is_timeout = TRUE;
|
|
|
|
plist = put_str((char *)empty_plist,SIZEOF(empty_plist));
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
if (!jobparameters(&plist))
|
|
|
|
return FALSE;
|
2012-03-24 14:06:46 -04:00
|
|
|
is_timeout = (TK_COLON == TREF(window_token));
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|
|
|
|
if (is_timeout)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
} 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;
|
|
|
|
}
|