Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/* 80x86/tv_callees.c */
32
 
33
/**********************************************************************
34
$Author: release $
35
$Date: 1998/01/17 15:55:52 $
36
$Revision: 1.1.1.1 $
37
$Log: tv_callees.c,v $
38
 * Revision 1.1.1.1  1998/01/17  15:55:52  release
39
 * First version to be checked into rolling release.
40
 *
41
 * Revision 1.5  1995/10/18  11:24:35  pwe
42
 * diag struct
43
 *
44
 * Revision 1.4  1995/10/16  17:45:55  pwe
45
 * frame alignments
46
 *
47
 * Revision 1.3  1995/08/30  16:06:57  pwe
48
 * prepare exception trapping
49
 *
50
 * Revision 1.2  1995/08/14  13:54:08  pwe
51
 * several corrections, tail calls and error jumps
52
 *
53
 * Revision 1.1  1995/08/04  08:29:50  pwe
54
 * 4.0 general procs implemented
55
 *
56
**********************************************************************/
57
 
58
#include "config.h"
59
#include "common_types.h"
60
#include "installglob.h"
61
#include "externs.h"
62
#include "flags.h"
63
#include "install_fns.h"
64
#include "tags.h"
65
#include "expmacs.h"
66
#include "exp.h"
67
#include "tv_callees.h"
68
 
69
 
70
void transform_var_callees
71
    PROTO_Z ()
72
				/* Transforms caller arguments of general
73
				   procs with variable callees, to appear
74
				   like a structure whose address is
75
				   another callee. This enables consistent
76
				   coding without demanding a separate
77
				   register for caller argument addressing.
78
					Also, record need for env_size.
79
				*/
80
{
81
  dec * my_def = top_def;
82
  while (my_def != (dec *) 0) {
83
    exp tg = my_def -> dec_u.dec_val.dec_exp;
84
    if (son(tg) != nilexp && name(son(tg)) == general_proc_tag
85
		&& proc_has_vcallees(son(tg))) {
86
      shape pc_sh = f_pointer(f_callers_alignment(0));
87
      int param_offset = 0;
88
      exp gp_body = son(son(tg));
89
      exp newdec = getexp (sh(gp_body), nilexp, 1, nilexp, nilexp, 0, 0, ident_tag);
90
      exp newlist = nilexp;
91
      son(newdec) = getexp (pc_sh, nilexp, 0, nilexp, nilexp, 0, 0, formal_callee_tag);
92
 
93
      while (name(gp_body) == ident_tag && isparam(gp_body)
94
		&& name(son(gp_body)) != formal_callee_tag) {
95
	exp arg_id = gp_body;
96
	exp oldlist = pt(arg_id);
97
	gp_body = bro(son(gp_body));
98
	while (oldlist != nilexp) {
99
	  exp this_n = oldlist;
100
	  exp new_n = getexp (pc_sh, this_n, 1, newdec, newlist, 0, 0, name_tag);
101
	  oldlist = pt(oldlist);
102
	  newlist = new_n;
103
	  no(newdec) ++;
104
	  if (isvar(arg_id)) {
105
	    name(this_n) = reff_tag;
106
	    son(this_n) = new_n;
107
	    no(this_n) += param_offset;
108
	  }
109
	  else {
110
	    exp r = getexp (f_pointer(f_alignment(sh(son(arg_id)))),
111
		 this_n, 1, new_n, nilexp, 0, no(this_n)+param_offset, reff_tag);
112
	    bro(new_n) = r;
113
	    name(this_n) = cont_tag;
114
	    son(this_n) = r;
115
	  }
116
	  pt(this_n) = nilexp;
117
	}
118
 
119
	name(arg_id) = 0;	/* This may still be accessed by env_offset.
120
				   We need to distinguish the special case.
121
				*/
122
	no(arg_id) = param_offset;
123
	bro(arg_id) = nilexp;
124
	pt(arg_id) = nilexp;
125
        param_offset = rounder(param_offset + shape_size(sh(son(arg_id))), param_align);
126
	retcell(son(arg_id));
127
	son(arg_id) = nilexp;
128
      }
129
      {
130
	setparam (newdec);	/* not var */
131
	setcaonly (newdec);
132
	bro(son(newdec)) = gp_body;
133
	setfather(newdec, gp_body);
134
	gp_body = newdec;
135
      }
136
      son(son(tg)) = gp_body;
137
      setfather(son(tg),gp_body);
138
    }
139
 
140
    if (son(tg) != nilexp &&
141
	(name(son(tg)) == proc_tag || name(son(tg)) == general_proc_tag)) {
142
      exp nlist = pt(tg);
143
      while (nlist != nilexp) {
144
	if (name(nlist) == name_tag && last(nlist) && bro(nlist) != nilexp &&
145
		name(bro(nlist)) == env_size_tag)
146
	  set_proc_needs_envsize(son(tg));
147
	nlist = pt(nlist);
148
      }
149
    }
150
 
151
    my_def = my_def -> def_next;
152
  }
153
  return;
154
}