Subversion Repositories tendra.SVN

Rev

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

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
2
 * Copyright (c) 2002-2006 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
Line 51... Line 81...
51
#include "tags.h"
81
#include "tags.h"
52
#include "expmacs.h"
82
#include "expmacs.h"
53
#include "shapemacs.h"
83
#include "shapemacs.h"
54
#include "exp.h"
84
#include "exp.h"
55
#include "complex_eq.h"
85
#include "complex_eq.h"
56
 
86
 
57
 
87
 
58
static int complex_eq_explist
88
static int
59
    PROTO_N ( (a, b, laba, labb) )
-
 
60
    PROTO_T ( exp a X exp b X exp laba X exp labb )
89
complex_eq_explist(exp a, exp b, exp laba, exp labb)
61
{
90
{
62
	if (a==nilexp) return (b==nilexp);
91
	if (a == nilexp) return(b == nilexp);
63
	if (b==nilexp || !complex_eq_exp(a,b,laba,labb) ) return 0;
92
	if (b == nilexp || !complex_eq_exp(a,b,laba,labb)) return 0;
64
	if (last(a)) return (last(b));
93
	if (last(a)) return(last(b));
65
	if (last(b)) return 0;
94
	if (last(b)) return 0;
66
	return complex_eq_explist(bro(a), bro(b), laba, labb);
95
	return complex_eq_explist(bro(a), bro(b), laba, labb);
67
}
96
}
68
 
97
 
69
 
98
 
70
int complex_eq_exp
99
int
71
    PROTO_N ( (a, b, laba, labb) )
-
 
72
    PROTO_T ( exp a X exp b X exp laba X exp labb )
100
complex_eq_exp(exp a, exp b, exp laba, exp labb)
73
{
101
{
74
	if (name(a) != name(b) || !eq_shape(sh(a), sh(b))) return 0;
102
	if (name(a) != name(b) || !eq_shape(sh(a), sh(b))) {
-
 
103
		return 0;
-
 
104
	}
75
	if (name(a) == seq_tag) {
105
	if (name(a) == seq_tag) {
76
		return (complex_eq_explist(son(son(a)), son(son(b)), laba, labb) &&
106
		return(complex_eq_explist(son(son(a)), son(son(b)), laba,
-
 
107
					  labb) &&
77
			complex_eq_exp(bro(son(a)), bro(son(b)),laba,labb) );
108
		       complex_eq_exp(bro(son(a)), bro(son(b)),laba,labb));
78
	}
109
	}
79
	if (name(a) == cond_tag) {
110
	if (name(a) == cond_tag) {
80
		exp fa = son(a);
111
		exp fa = son(a);
81
		exp fb = son(b);
112
		exp fb = son(b);
82
	 	return (complex_eq_exp(fa,fb, bro(fa), bro(fb)) &&
113
		return(complex_eq_exp(fa,fb, bro(fa), bro(fb)) &&
83
	 		  complex_eq_exp(bro(son(bro(fa))), bro(son(bro(fb))), laba, labb) );
114
		       complex_eq_exp(bro(son(bro(fa))), bro(son(bro(fb))),
-
 
115
				      laba, labb));
84
	}
116
	}
85
	if (name(a)==test_tag) {
117
	if (name(a) ==test_tag) {
86
		return(pt(a)==laba && pt(b)==labb && props(a)==props(b) &&
118
		return(pt(a) ==laba && pt(b) ==labb && props(a) ==props(b) &&
87
			complex_eq_explist(son(a),son(b), laba, labb) );
119
		       complex_eq_explist(son(a),son(b), laba, labb));
88
	}
120
	}
89
	if (name(a)==name_tag) {
121
	if (name(a) ==name_tag) {
90
		return (son(a)==son(b) && no(a)==no(b));
122
		return(son(a) ==son(b) && no(a) ==no(b));
91
	}
123
	}
92
 
124
 
93
	return (is_a(name(a)) && no(a)==no(b) &&
125
	return(is_a(name(a)) && no(a) ==no(b) &&
94
		 complex_eq_explist(son(a), son(b), laba, labb) );
126
	       complex_eq_explist(son(a), son(b), laba, labb));
95
}
127
}