File: op_glvnslot.c

package info (click to toggle)
fis-gtm 6.3-007-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 36,284 kB
  • sloc: ansic: 328,861; asm: 5,182; csh: 5,102; sh: 1,918; awk: 291; makefile: 69; sed: 13
file content (68 lines) | stat: -rw-r--r-- 2,314 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
/****************************************************************
 *								*
 *	Copyright 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 "lv_val.h"
#include "toktyp.h"
#include "compiler.h"
#include "opcode.h"
#include "indir_enum.h"
#include "cache.h"
#include "op.h"
#include <rtnhdr.h>
#include "valid_mname.h"
#include "gtm_string.h"
#include "cachectl.h"
#include "gtm_text_alloc.h"
#include "callg.h"
#include "mdq.h"
#include "stack_frame.h"
#include "stringpool.h"
#include "mv_stent.h"
#include "min_max.h"
#include "glvn_pool.h"

GBLREF	stack_frame	*frame_pointer;

/* Finds a slot in the glvn pool for saving a variable name. Used by SET and FOR */
uint4 op_glvnslot(uint4 recycle)
{
	glvn_pool_entry		*slot;
	uint4			indx, findx;
	DCL_THREADGBL_ACCESS;

	SETUP_THREADGBL_ACCESS;
	GLVN_POOL_EXPAND_IF_NEEDED;
	indx = (TREF(glvn_pool_ptr))->top;
	if (GLVN_POOL_UNTOUCHED == GLVN_INDX(frame_pointer))
		/* low water mark - drain back to here when frame is unwound */
		SET_GLVN_INDX(frame_pointer, (indx) ? indx : GLVN_POOL_EMPTY);
	slot = &(TREF(glvn_pool_ptr))->slot[indx];
	slot->sav_opcode = OC_NOOP;			/* flag the slot as not filled out in case something goes wrong */
	if (ANY_SLOT != recycle)
	{	/* attempt to reuse slot (for FOR control) */
		assert((0 < recycle) && (recycle <= MAX_FOR_STACK));
		findx = (TREF(glvn_pool_ptr))->for_slot[recycle];
		if (((GLVN_INDX(frame_pointer) <= findx) || (GLVN_POOL_EMPTY == GLVN_INDX(frame_pointer))) && (findx < indx))
		{	/* reuse and pop anything beyond it */
			slot = &(TREF(glvn_pool_ptr))->slot[findx];
			(TREF(glvn_pool_ptr))->top = findx + 1;
			(TREF(glvn_pool_ptr))->mval_top = slot->mval_top;
			return findx;
		}
		/* point new slot's precursor field at indx, which corresponds an earlier frame */
		(TREF(glvn_pool_ptr))->for_slot[recycle] = indx;
		slot->precursor = (findx < indx) ? findx : GLVN_POOL_EMPTY;
	}
	slot->mval_top = (TREF(glvn_pool_ptr))->mval_top;
	return (TREF(glvn_pool_ptr))->top++;
}