Subversion Repositories tendra.SVN

Rev

Rev 5 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5 Rev 6
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
-
 
3
 * All rights reserved.
-
 
4
 *
-
 
5
 * Redistribution and use in source and binary forms, with or without
-
 
6
 * modification, are permitted provided that the following conditions are met:
-
 
7
 *
-
 
8
 * 1. Redistributions of source code must retain the above copyright notice,
-
 
9
 *    this list of conditions and the following disclaimer.
-
 
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
-
 
11
 *    this list of conditions and the following disclaimer in the documentation
-
 
12
 *    and/or other materials provided with the distribution.
-
 
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
-
 
14
 *    may be used to endorse or promote products derived from this software
-
 
15
 *    without specific, prior written permission.
-
 
16
 *
-
 
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
-
 
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
-
 
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-
 
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
-
 
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-
 
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-
 
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-
 
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-
 
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-
 
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-
 
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
28
 *
-
 
29
 * $Id$
-
 
30
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 40... Line 70...
40
#include "check.h"
70
#include "check.h"
41
 
71
 
42
 
72
 
43
/* REPORT AN ERROR */
73
/* REPORT AN ERROR */
44
 
74
 
45
static void decode_error
75
static void
46
    PROTO_N ( ( s ) )
-
 
47
    PROTO_T ( char *s )
76
decode_error(char *s)
48
{
77
{
49
    failer ( s ) ;
78
    failer(s);
50
    exit ( EXIT_FAILURE ) ;
79
    exit(EXIT_FAILURE);
51
}
80
}
52
@use all
81
@use all
53
@special exp
82
@special exp
54
@special nat computed_nat
83
@special nat computed_nat
55
@special signed_nat computed_signed_nat
84
@special signed_nat computed_signed_nat
Line 59... Line 88...
59
@if !sort.builtin
88
@if !sort.builtin
60
 
89
 
61
 
90
 
62
/* DECODE %ST */
91
/* DECODE %ST */
63
 
92
 
64
%SN d_%SN
93
%SN
65
    PROTO_Z ()
94
d_%SN(void)
66
{
95
{
67
@if sort.basic
96
@if sort.basic
68
@if sort.extends
97
@if sort.extends
69
    int code = get_big_code ( %SB ) ;
98
    int code = get_big_code(%SB);
70
@else
99
@else
71
    int code = getcode ( %SB ) ;
100
    int code = getcode(%SB);
72
@endif
101
@endif
73
    switch ( code ) {
102
    switch (code) {
74
@loop sort.cons
103
@loop sort.cons
75
	case e_%CN : {
104
	case e_%CN: {
76
@if cons.params
105
@if cons.params
77
@loop cons.param
106
@loop cons.param
78
	    %PSN p%PE ;
107
	    %PSN p%PE;
79
@end
108
@end
80
@loop cons.param
109
@loop cons.param
81
@if param.align
110
@if param.align
82
	    to_boundary () ;
111
	    to_boundary();
83
@endif
112
@endif
84
@if param.break
113
@if param.break
85
@if param.first
114
@if param.first
86
	    start_%CN () ;
115
	    start_%CN();
87
@else
116
@else
88
	    start_%CN (%
117
	    start_%CN(%
89
@loop param.prev
118
@loop param.prev
90
 p%PE,%
119
 p%PE,%
91
@end
120
@end
92
%b ) ;
121
%b);
93
@endif
122
@endif
94
@endif
123
@endif
95
@if param.sort.special
124
@if param.sort.special
96
@if cons.cond
125
@if cons.cond
97
	    p%PE = hold_const_check ( d_%PSN () ) ;
126
	    p%PE = hold_const_check(d_%PSN());
98
@else
127
@else
99
@if cons.special
128
@if cons.special
100
	    p%PE = hold_const_check ( d_%PSN () ) ;
129
	    p%PE = hold_const_check(d_%PSN());
101
@else
130
@else
102
	    p%PE = hold_check ( d_%PSN () ) ;
131
	    p%PE = hold_check(d_%PSN());
103
@endif
132
@endif
104
@endif
133
@endif
105
@else
134
@else
106
	    p%PE = d_%PSN () ;
135
	    p%PE = d_%PSN();
107
@endif
136
@endif
108
@end
137
@end
109
	    return ( f_%CN (%
138
	    return(f_%CN(%
110
@loop cons.param
139
@loop cons.param
111
 p%PE,%
140
 p%PE,%
112
@end
141
@end
113
%b ) ) ;
142
%b));
114
@else
143
@else
115
@if sort.special
144
@if sort.special
116
	    return ( f_%CN () ) ;
145
	    return(f_%CN());
117
@else
146
@else
118
	    return ( f_%CN ) ;
147
	    return(f_%CN);
119
@endif
148
@endif
120
@endif
149
@endif
121
	}
150
	}
122
@end
151
@end
123
    }
152
    }
124
    decode_error ( ILLEGAL_CODE_%SN ) ;
153
    decode_error(ILLEGAL_CODE_%SN);
125
    return ( f_dummy_%SN ) ;
154
    return(f_dummy_%SN);
126
@else
155
@else
127
@if sort.dummy
156
@if sort.dummy
128
@loop sort.cons
157
@loop sort.cons
129
@loop cons.param
158
@loop cons.param
130
    %PSN p%PE ;
159
    %PSN p%PE;
131
@end
160
@end
132
@loop cons.param
161
@loop cons.param
133
@if param.align
162
@if param.align
134
    to_boundary () ;
163
    to_boundary();
135
@endif
164
@endif
136
@if param.break
165
@if param.break
137
    start_%CN (%
166
    start_%CN(%
138
@loop param.prev
167
@loop param.prev
139
 p%PE,%
168
 p%PE,%
140
@end
169
@end
141
%b ) ;
170
%b);
142
@endif
171
@endif
143
@if param.sort.special
172
@if param.sort.special
144
    p%PE = hold_check ( d_%PSN () ) ;
173
    p%PE = hold_check(d_%PSN());
145
@else
174
@else
146
    p%PE = d_%PSN () ;
175
    p%PE = d_%PSN();
147
@endif
176
@endif
148
@end
177
@end
149
    return ( f_%CN (%
178
    return(f_%CN(%
150
@loop cons.param
179
@loop cons.param
151
 p%PE,%
180
 p%PE,%
152
@end
181
@end
153
%b ) ) ;
182
%b));
154
@end
183
@end
155
@else
184
@else
156
@if sort.option
185
@if sort.option
157
    if ( getcode ( 1 ) ) {
186
    if (getcode(1)) {
158
	%SSN e ;
187
	%SSN e;
159
@if sort.sub.special
188
@if sort.sub.special
160
	e = hold_check ( d_%SSN () ) ;
189
	e = hold_check(d_%SSN());
161
@else
190
@else
162
	e = d_%SSN () ;
191
	e = d_%SSN();
163
@endif
192
@endif
164
	return ( yes_%SN ( e ) ) ;
193
	return(yes_%SN(e));
165
    }
194
    }
166
    return ( no_%SN ) ;
195
    return(no_%SN);
167
@else
196
@else
168
    int i, n ;
197
    int i, n;
169
    %SN temp ;
198
    %SN temp;
170
@if sort.list
199
@if sort.list
171
    IGNORE getcode ( 1 ) ;
200
    IGNORE getcode(1);
172
@endif
201
@endif
173
    n = small_dtdfint () ;
202
    n = small_dtdfint();
174
    temp = new_%SN ( n ) ;
203
    temp = new_%SN(n);
175
    for ( i = 0 ; i < n; i++ ) {
204
    for (i = 0; i < n; i++) {
176
	%SSN e ;
205
	%SSN e;
177
@if sort.sub.special
206
@if sort.sub.special
178
	e = hold_check ( d_%SSN () ) ;
207
	e = hold_check(d_%SSN());
179
@else
208
@else
180
	e = d_%SSN () ;
209
	e = d_%SSN();
181
@endif
210
@endif
182
	temp = add_%SN ( temp, e, i ) ;
211
	temp = add_%SN(temp, e, i);
183
    }
212
    }
184
    return ( temp ) ;
213
    return(temp);
185
@endif
214
@endif
186
@endif
215
@endif
187
@endif
216
@endif
188
}
217
}
189
@endif
218
@endif