aboutsummaryrefslogtreecommitdiff
path: root/sys/qpoe/qpexdel.x
blob: ce4da432dacc57143203c9f6bcf6778e3e2159ba (plain) (blame)
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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<mach.h>
include	"qpex.h"

# QPEX_DELETE -- Delete any previously compiled expression terms for the
# event attribute with the given offset and datatype.  Only terms up to and
# including ET_LAST are affected (allowing deletion while compiling additional
# terms).

procedure qpex_delete (ex, et_last, offset, dtype)

pointer	ex			#I QPEX descriptor
pointer	et_last			#I last expression term to be edited
int	offset			#I typed offset of attribute in event struct
int	dtype			#I datatype of attribute

pointer	et, ip
int	ninstr, i

begin
	if (et_last == NULL)
	    return

	for (et=EX_ETHEAD(ex);  et != NULL;  et=ET_NEXT(et)) {
	    # Skip over already deleted terms or terms for other attributes.
	    if (ET_DELETED(et) == YES)
		next
	    else if (ET_ATTOFF(et) != offset || ET_ATTTYPE(et) != dtype)
		next

	    # Physically and logically delete the term.  Edit the program
	    # buffer and replace the compiled sequence of instructions by
	    # a GOTO followed by a series of NO-OPs.

	    ip = ET_PROGPTR(et)
	    ninstr = ET_NINSTR(et)

	    OPCODE(ip) = GOTO
	    IARG1(ip)  = ip + ninstr * LEN_INSTRUCTION
	    IARG2(ip)  = NULL
	    IARG3(ip)  = NULL

	    do i = 2, ninstr {
		ip = ET_PROGPTR(et) + (i-1) * LEN_INSTRUCTION
		OPCODE(ip) = NOP
		IARG1(ip)  = NULL
		IARG2(ip)  = NULL
		IARG3(ip)  = NULL
	    }

	    # Flag the eterm as deleted.
	    ET_DELETED(et) = YES

	    if (et == et_last)
		break
	}
end