aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs222
1 files changed, 111 insertions, 111 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs
index 33e2a32..582cd20 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Functor1.cs
@@ -1,111 +1,111 @@
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
31using System; 31using System;
32using System.Collections.Generic; 32using System.Collections.Generic;
33 33
34namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog 34namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
35{ 35{
36 public class Functor1 : IUnifiable 36 public class Functor1 : IUnifiable
37 { 37 {
38 public readonly Atom _name; 38 public readonly Atom _name;
39 public readonly object _arg1; 39 public readonly object _arg1;
40 40
41 public Functor1(Atom name, object arg1) 41 public Functor1(Atom name, object arg1)
42 { 42 {
43 _name = name; 43 _name = name;
44 _arg1 = arg1; 44 _arg1 = arg1;
45 } 45 }
46 46
47 public Functor1(string name, object arg1) 47 public Functor1(string name, object arg1)
48 : this(Atom.a(name), arg1) 48 : this(Atom.a(name), arg1)
49 { 49 {
50 } 50 }
51 51
52 public IEnumerable<bool> unify(object arg) 52 public IEnumerable<bool> unify(object arg)
53 { 53 {
54 arg = YP.getValue(arg); 54 arg = YP.getValue(arg);
55 if (arg is Functor1) 55 if (arg is Functor1)
56 { 56 {
57 Functor1 argFunctor = (Functor1)arg; 57 Functor1 argFunctor = (Functor1)arg;
58 if (_name.Equals(argFunctor._name)) 58 if (_name.Equals(argFunctor._name))
59 { 59 {
60 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1)) 60 foreach (bool l1 in YP.unify(_arg1, argFunctor._arg1))
61 yield return false; 61 yield return false;
62 } 62 }
63 } 63 }
64 else if (arg is Variable) 64 else if (arg is Variable)
65 { 65 {
66 foreach (bool l1 in ((Variable)arg).unify(this)) 66 foreach (bool l1 in ((Variable)arg).unify(this))
67 yield return false; 67 yield return false;
68 } 68 }
69 } 69 }
70 70
71 public override string ToString() 71 public override string ToString()
72 { 72 {
73 return _name + "(" + YP.getValue(_arg1) + ")"; 73 return _name + "(" + YP.getValue(_arg1) + ")";
74 } 74 }
75 75
76 public bool termEqual(object term) 76 public bool termEqual(object term)
77 { 77 {
78 term = YP.getValue(term); 78 term = YP.getValue(term);
79 if (term is Functor1) 79 if (term is Functor1)
80 { 80 {
81 Functor1 termFunctor = (Functor1)term; 81 Functor1 termFunctor = (Functor1)term;
82 return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1); 82 return _name.Equals(termFunctor._name) && YP.termEqual(_arg1, termFunctor._arg1);
83 } 83 }
84 return false; 84 return false;
85 } 85 }
86 86
87 public bool lessThan(Functor1 functor) 87 public bool lessThan(Functor1 functor)
88 { 88 {
89 // Do the equal check first since it is faster. 89 // Do the equal check first since it is faster.
90 if (!_name.Equals(functor._name)) 90 if (!_name.Equals(functor._name))
91 return _name.lessThan(functor._name); 91 return _name.lessThan(functor._name);
92 92
93 return YP.termLessThan(_arg1, functor._arg1); 93 return YP.termLessThan(_arg1, functor._arg1);
94 } 94 }
95 95
96 public bool ground() 96 public bool ground()
97 { 97 {
98 return YP.ground(_arg1); 98 return YP.ground(_arg1);
99 } 99 }
100 100
101 public void addUniqueVariables(List<Variable> variableSet) 101 public void addUniqueVariables(List<Variable> variableSet)
102 { 102 {
103 YP.addUniqueVariables(_arg1, variableSet); 103 YP.addUniqueVariables(_arg1, variableSet);
104 } 104 }
105 105
106 public object makeCopy(Variable.CopyStore copyStore) 106 public object makeCopy(Variable.CopyStore copyStore)
107 { 107 {
108 return new Functor1(_name, YP.makeCopy(_arg1, copyStore)); 108 return new Functor1(_name, YP.makeCopy(_arg1, copyStore));
109 } 109 }
110 } 110 }
111} 111}