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 "gtm_string.h"
|
|
|
|
|
|
|
|
#include "compiler.h"
|
|
|
|
#include "opcode.h"
|
|
|
|
#include "toktyp.h"
|
|
|
|
#include "subscript.h"
|
|
|
|
#include "advancewindow.h"
|
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
error_def(ERR_COMMA);
|
|
|
|
error_def(ERR_EXTGBLDEL);
|
|
|
|
error_def(ERR_LKNAMEXPECTED);
|
|
|
|
error_def(ERR_MAXNRSUBSCRIPTS);
|
2012-02-05 11:35:58 -05:00
|
|
|
|
2012-03-24 14:06:46 -04:00
|
|
|
int lkglvn(boolean_t gblvn)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
boolean_t vbar;
|
|
|
|
char *lknam, lkname_buf[MAX_MIDENT_LEN + 1], x;
|
2012-02-05 11:35:58 -05:00
|
|
|
opctype ox;
|
2012-03-24 14:06:46 -04:00
|
|
|
oprtype *sb1, *sb2, subscripts[MAX_LVSUBSCRIPTS];
|
|
|
|
triple *ref, *t1;
|
|
|
|
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
|
|
|
ox = OC_LKNAME;
|
|
|
|
sb1 = sb2 = subscripts;
|
|
|
|
lknam = lkname_buf;
|
|
|
|
if (gblvn)
|
|
|
|
*lknam++ = '^';
|
2012-03-24 14:06:46 -04:00
|
|
|
if ((TK_LBRACKET == TREF(window_token)) || (TK_VBAR == TREF(window_token)))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
vbar = (TK_VBAR == TREF(window_token));
|
2012-02-05 11:35:58 -05:00
|
|
|
advancewindow();
|
2012-03-24 14:06:46 -04:00
|
|
|
if (EXPR_FAIL == (vbar ? expr(sb1++, MUMPS_EXPR) : expratom(sb1++)))
|
2012-02-05 11:35:58 -05:00
|
|
|
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 == (vbar ? expr(sb1++, MUMPS_EXPR) : expratom(sb1++)))
|
2012-02-05 11:35:58 -05:00
|
|
|
return FALSE;
|
|
|
|
} else
|
2012-03-24 14:06:46 -04:00
|
|
|
*sb1++ = put_str(0, 0);
|
|
|
|
if ((!vbar && (TK_RBRACKET != TREF(window_token))) || (vbar && (TK_VBAR != TREF(window_token))))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
stx_error(ERR_EXTGBLDEL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
advancewindow();
|
|
|
|
ox = OC_LKEXTNAME;
|
|
|
|
} else
|
|
|
|
*sb1++ = put_ilit(0);
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_IDENT != TREF(window_token))
|
|
|
|
{
|
|
|
|
stx_error(ERR_LKNAMEXPECTED);
|
2012-02-05 11:35:58 -05:00
|
|
|
return FALSE;
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
assert(MAX_MIDENT_LEN >= (TREF(window_ident)).len);
|
|
|
|
memcpy(lknam, (TREF(window_ident)).addr, (TREF(window_ident)).len);
|
|
|
|
lknam += (TREF(window_ident)).len;
|
2012-02-05 11:35:58 -05:00
|
|
|
*sb1++ = put_str(lkname_buf,(mstr_len_t)(lknam - lkname_buf));
|
|
|
|
advancewindow();
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_LPAREN == TREF(window_token))
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
for (;;)
|
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
if (ARRAYTOP(subscripts) <= sb1)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
stx_error(ERR_MAXNRSUBSCRIPTS);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
advancewindow();
|
2012-03-24 14:06:46 -04:00
|
|
|
if (EXPR_FAIL == expr(sb1, MUMPS_EXPR))
|
2012-02-05 11:35:58 -05:00
|
|
|
return FALSE;
|
|
|
|
sb1++;
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_RPAREN == (x = TREF(window_token))) /* NOTE assignment */
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
advancewindow();
|
|
|
|
break;
|
|
|
|
}
|
2012-03-24 14:06:46 -04:00
|
|
|
if (TK_COMMA != x)
|
2012-02-05 11:35:58 -05:00
|
|
|
{
|
|
|
|
stx_error(ERR_COMMA);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ref = newtriple(ox);
|
|
|
|
ref->operand[0] = put_ilit((mint)(sb1 - sb2));
|
|
|
|
for ( ; sb2 < sb1 ; sb2++)
|
|
|
|
{
|
|
|
|
t1 = newtriple(OC_PARAMETER);
|
|
|
|
ref->operand[1] = put_tref(t1);
|
|
|
|
ref = t1;
|
|
|
|
ref->operand[0] = *sb2;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|