File: m_zwatch.c

package info (click to toggle)
fis-gtm 6.3-014-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 36,680 kB
  • sloc: ansic: 333,039; asm: 5,180; csh: 4,956; sh: 1,924; awk: 291; makefile: 66; sed: 13
file content (125 lines) | stat: -rwxr-xr-x 2,789 bytes parent folder | download | duplicates (5)
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
/****************************************************************
 *								*
 *	Copyright 2001, 2011 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 "advancewindow.h"
#include "cmd.h"

#define CANCEL_ONE -1
#define CANCEL_ALL -2

LITREF mident 	zero_ident;

error_def(ERR_VAREXPECTED);

int m_zwatch(void)
{
	boolean_t	is_count;
	opctype		op;
	oprtype		count, name,action;
	triple		*next, *ref;
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	if (TK_MINUS == TREF(window_token))
	{
		advancewindow();
		switch (TREF(window_token))
		{
		case TK_ASTERISK:
			name = put_str(zero_ident.addr, zero_ident.len);
			count = put_ilit(CANCEL_ALL);
			advancewindow();
			break;
		case TK_IDENT:
			name = put_str((TREF(window_ident)).addr, (TREF(window_ident)).len);
			count = put_ilit(CANCEL_ONE);
			advancewindow();
			break;
		case TK_ATSIGN:
			if (!indirection(&name))
				return FALSE;
			count = put_ilit(CANCEL_ONE);
			break;
		default:
			stx_error(ERR_VAREXPECTED);
			return FALSE;
		}
		action = put_str("",0);
		op = OC_WATCHREF;
	} else
	{
		if (TK_EQUAL == TREF(window_token))
		{
			advancewindow();
			op = OC_WATCHMOD;
		} else
			op = OC_WATCHREF;
		switch (TREF(window_token))
		{
		case TK_IDENT:
			name = put_str((TREF(window_ident)).addr, (TREF(window_ident)).len);
			advancewindow();
			break;
		case TK_ATSIGN:
			if (!indirection(&name))
				return FALSE;
			if ((OC_WATCHREF == op) && (TK_COLON != TREF(window_token)))
			{
				ref = maketriple(OC_COMMARG);
				ref->operand[0] = name;
				ref->operand[1] = put_ilit((mint) indir_zwatch);
				ins_triple(ref);
				return TRUE;
			}
			break;
		default:
			stx_error(ERR_VAREXPECTED);
			return FALSE;
		}
		if (TK_COLON != TREF(window_token))
		{
			action = put_str("",0);
			count = put_ilit(0);
		} else
		{
			advancewindow();
			if (TK_COLON == TREF(window_token))
			{
				is_count = TRUE;
				action = put_str("", 0);
			} else
			{
				if (EXPR_FAIL == expr(&action, MUMPS_STR))
					return FALSE;
				is_count = (TK_COLON == TREF(window_token));
			}
			if (is_count)
			{
				advancewindow();
				if (EXPR_FAIL == expr(&count, MUMPS_INT))
					return FALSE;
			} else
				count = put_ilit(0);
		}
	}
	ref = newtriple(op);
	ref->operand[0] = name;
	next = newtriple(OC_PARAMETER);
	ref->operand[1] = put_tref(next);
	next->operand[0] = action;
	next->operand[1] = count;
	return TRUE;
}