diff options
Update svn properties.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs | 266 |
1 files changed, 133 insertions, 133 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs index 74418c4..b52fdf3 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor3.cs | |||
@@ -1,133 +1,133 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007-2008, Jeff Thompson | 2 | * Copyright (C) 2007-2008, Jeff Thompson |
3 | * | 3 | * |
4 | * All rights reserved. | 4 | * All rights reserved. |
5 | * | 5 | * |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
7 | * modification, are permitted provided that the following conditions are met: | 7 | * modification, are permitted provided that the following conditions are met: |
8 | * | 8 | * |
9 | * * Redistributions of source code must retain the above copyright | 9 | * * Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. |
11 | * * Redistributions in binary form must reproduce the above copyright | 11 | * * Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. |
14 | * * Neither the name of the copyright holder nor the names of its contributors | 14 | * * Neither the name of the copyright holder nor the names of its contributors |
15 | * may be used to endorse or promote products derived from this software | 15 | * may be used to endorse or promote products derived from this software |
16 | * without specific prior written permission. | 16 | * without specific prior written permission. |
17 | * | 17 | * |
18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | 21 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 22 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 23 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 24 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | 25 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | 26 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 27 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | 33 | ||
34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | 34 | namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog |
35 | { | 35 | { |
36 | public class Functor3 : IUnifiable | 36 | public class Functor3 : IUnifiable |
37 | { | 37 | { |
38 | public readonly Atom _name; | 38 | public readonly Atom _name; |
39 | public readonly object _arg1; | 39 | public readonly object _arg1; |
40 | public readonly object _arg2; | 40 | public readonly object _arg2; |
41 | public readonly object _arg3; | 41 | public readonly object _arg3; |
42 | 42 | ||
43 | public Functor3(Atom name, object arg1, object arg2, object arg3) | 43 | public Functor3(Atom name, object arg1, object arg2, object arg3) |
44 | { | 44 | { |
45 | _name = name; | 45 | _name = name; |
46 | _arg1 = arg1; | 46 | _arg1 = arg1; |
47 | _arg2 = arg2; | 47 | _arg2 = arg2; |
48 | _arg3 = arg3; | 48 | _arg3 = arg3; |
49 | } | 49 | } |
50 | 50 | ||
51 | public Functor3(string name, object arg1, object arg2, object arg3) | 51 | public Functor3(string name, object arg1, object arg2, object arg3) |
52 | : this(Atom.a(name), arg1, arg2, arg3) | 52 | : this(Atom.a(name), arg1, arg2, arg3) |
53 | { | 53 | { |
54 | } | 54 | } |
55 | 55 | ||
56 | public IEnumerable<bool> unify(object arg) | 56 | public IEnumerable<bool> unify(object arg) |
57 | { | 57 | { |
58 | arg = YP.getValue(arg); | 58 | arg = YP.getValue(arg); |
59 | if (arg is Functor3) | 59 | if (arg is Functor3) |
60 | { | 60 | { |
61 | Functor3 argFunctor = (Functor3)arg; | 61 | Functor3 argFunctor = (Functor3)arg; |
62 | if (_name.Equals(argFunctor._name)) | 62 | if (_name.Equals(argFunctor._name)) |
63 | { | 63 | { |
64 | foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) | 64 | foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) |
65 | { | 65 | { |
66 | foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2)) | 66 | foreach (bool l2 in YP.unify(_arg2, argFunctor._arg2)) |
67 | { | 67 | { |
68 | foreach (bool l3 in YP.unify(_arg3, argFunctor._arg3)) | 68 | foreach (bool l3 in YP.unify(_arg3, argFunctor._arg3)) |
69 | yield return false; | 69 | yield return false; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | } | 72 | } |
73 | } | 73 | } |
74 | else if (arg is Variable) | 74 | else if (arg is Variable) |
75 | { | 75 | { |
76 | foreach (bool l1 in ((Variable)arg).unify(this)) | 76 | foreach (bool l1 in ((Variable)arg).unify(this)) |
77 | yield return false; | 77 | yield return false; |
78 | } | 78 | } |
79 | } | 79 | } |
80 | 80 | ||
81 | public override string ToString() | 81 | public override string ToString() |
82 | { | 82 | { |
83 | return _name + "(" + YP.getValue(_arg1) + ", " + YP.getValue(_arg2) + ", " + | 83 | return _name + "(" + YP.getValue(_arg1) + ", " + YP.getValue(_arg2) + ", " + |
84 | YP.getValue(_arg3) + ")"; | 84 | YP.getValue(_arg3) + ")"; |
85 | } | 85 | } |
86 | 86 | ||
87 | public bool termEqual(object term) | 87 | public bool termEqual(object term) |
88 | { | 88 | { |
89 | term = YP.getValue(term); | 89 | term = YP.getValue(term); |
90 | if (term is Functor3) | 90 | if (term is Functor3) |
91 | { | 91 | { |
92 | Functor3 termFunctor = (Functor3)term; | 92 | Functor3 termFunctor = (Functor3)term; |
93 | return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1) | 93 | return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1) |
94 | && YP.termEqual(_arg2, termFunctor._arg2) | 94 | && YP.termEqual(_arg2, termFunctor._arg2) |
95 | && YP.termEqual(_arg3, termFunctor._arg3); | 95 | && YP.termEqual(_arg3, termFunctor._arg3); |
96 | } | 96 | } |
97 | return false; | 97 | return false; |
98 | } | 98 | } |
99 | 99 | ||
100 | public bool lessThan(Functor3 functor) | 100 | public bool lessThan(Functor3 functor) |
101 | { | 101 | { |
102 | // Do the equal check first since it is faster. | 102 | // Do the equal check first since it is faster. |
103 | if (!_name.Equals(functor._name)) | 103 | if (!_name.Equals(functor._name)) |
104 | return _name.lessThan(functor._name); | 104 | return _name.lessThan(functor._name); |
105 | 105 | ||
106 | if (!YP.termEqual(_arg1, functor._arg1)) | 106 | if (!YP.termEqual(_arg1, functor._arg1)) |
107 | return YP.termLessThan(_arg1, functor._arg1); | 107 | return YP.termLessThan(_arg1, functor._arg1); |
108 | 108 | ||
109 | if (!YP.termEqual(_arg2, functor._arg2)) | 109 | if (!YP.termEqual(_arg2, functor._arg2)) |
110 | return YP.termLessThan(_arg2, functor._arg2); | 110 | return YP.termLessThan(_arg2, functor._arg2); |
111 | 111 | ||
112 | return YP.termLessThan(_arg3, functor._arg3); | 112 | return YP.termLessThan(_arg3, functor._arg3); |
113 | } | 113 | } |
114 | 114 | ||
115 | public bool ground() | 115 | public bool ground() |
116 | { | 116 | { |
117 | return YP.ground(_arg1) && YP.ground(_arg2) && YP.ground(_arg3); | 117 | return YP.ground(_arg1) && YP.ground(_arg2) && YP.ground(_arg3); |
118 | } | 118 | } |
119 | 119 | ||
120 | public void addUniqueVariables(List<Variable> variableSet) | 120 | public void addUniqueVariables(List<Variable> variableSet) |
121 | { | 121 | { |
122 | YP.addUniqueVariables(_arg1, variableSet); | 122 | YP.addUniqueVariables(_arg1, variableSet); |
123 | YP.addUniqueVariables(_arg2, variableSet); | 123 | YP.addUniqueVariables(_arg2, variableSet); |
124 | YP.addUniqueVariables(_arg3, variableSet); | 124 | YP.addUniqueVariables(_arg3, variableSet); |
125 | } | 125 | } |
126 | 126 | ||
127 | public object makeCopy(Variable.CopyStore copyStore) | 127 | public object makeCopy(Variable.CopyStore copyStore) |
128 | { | 128 | { |
129 | return new Functor3(_name, YP.makeCopy(_arg1, copyStore), | 129 | return new Functor3(_name, YP.makeCopy(_arg1, copyStore), |
130 | YP.makeCopy(_arg2, copyStore), YP.makeCopy(_arg3, copyStore)); | 130 | YP.makeCopy(_arg2, copyStore), YP.makeCopy(_arg3, copyStore)); |
131 | } | 131 | } |
132 | } | 132 | } |
133 | } | 133 | } |