aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs
diff options
context:
space:
mode:
authorJeff Ames2008-06-01 03:01:33 +0000
committerJeff Ames2008-06-01 03:01:33 +0000
commitd22a54a19568f8d5e9b6dab1f76f9c5c58682aa5 (patch)
tree2311b4c6ad2617cc71b975460c48e723a7e027ee /OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs
parent* Committing some stuff I'm working to make it so I can commit an upcoming pa... (diff)
downloadopensim-SC-d22a54a19568f8d5e9b6dab1f76f9c5c58682aa5.zip
opensim-SC-d22a54a19568f8d5e9b6dab1f76f9c5c58682aa5.tar.gz
opensim-SC-d22a54a19568f8d5e9b6dab1f76f9c5c58682aa5.tar.bz2
opensim-SC-d22a54a19568f8d5e9b6dab1f76f9c5c58682aa5.tar.xz
Update svn properties.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs206
1 files changed, 103 insertions, 103 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs
index 2978cee..dcd4250 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/FindallAnswers.cs
@@ -1,103 +1,103 @@
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; 32using System.Collections;
33using System.Collections.Generic; 33using System.Collections.Generic;
34 34
35namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog 35namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog
36{ 36{
37 /// <summary> 37 /// <summary>
38 /// A FindallAnswers holds answers for findall. 38 /// A FindallAnswers holds answers for findall.
39 /// </summary> 39 /// </summary>
40 public class FindallAnswers 40 public class FindallAnswers
41 { 41 {
42 private object _template; 42 private object _template;
43 private List<object> _bagArray; 43 private List<object> _bagArray;
44 44
45 public FindallAnswers(object Template) 45 public FindallAnswers(object Template)
46 { 46 {
47 _template = Template; 47 _template = Template;
48 _bagArray = new List<object>(); 48 _bagArray = new List<object>();
49 } 49 }
50 50
51 public void add() 51 public void add()
52 { 52 {
53 _bagArray.Add(YP.makeCopy(_template, new Variable.CopyStore())); 53 _bagArray.Add(YP.makeCopy(_template, new Variable.CopyStore()));
54 } 54 }
55 55
56 public List<object> resultArray() 56 public List<object> resultArray()
57 { 57 {
58 return _bagArray; 58 return _bagArray;
59 } 59 }
60 60
61 /// <summary> 61 /// <summary>
62 /// Unify Bag with the result. This frees the internal answers, so you can only call this once. 62 /// Unify Bag with the result. This frees the internal answers, so you can only call this once.
63 /// </summary> 63 /// </summary>
64 /// <param name="Bag"></param> 64 /// <param name="Bag"></param>
65 /// <returns></returns> 65 /// <returns></returns>
66 public IEnumerable<bool> result(object Bag) 66 public IEnumerable<bool> result(object Bag)
67 { 67 {
68 object result = ListPair.make(_bagArray); 68 object result = ListPair.make(_bagArray);
69 // Try to free the memory. 69 // Try to free the memory.
70 _bagArray = null; 70 _bagArray = null;
71 return YP.unify(Bag, result); 71 return YP.unify(Bag, result);
72 } 72 }
73 73
74 /// <summary> 74 /// <summary>
75 /// This is a simplified findall when the goal is a single call. 75 /// This is a simplified findall when the goal is a single call.
76 /// </summary> 76 /// </summary>
77 /// <param name="Template"></param> 77 /// <param name="Template"></param>
78 /// <param name="goal"></param> 78 /// <param name="goal"></param>
79 /// <param name="Bag"></param> 79 /// <param name="Bag"></param>
80 /// <returns></returns> 80 /// <returns></returns>
81 public static IEnumerable<bool> findall(object Template, IEnumerable<bool> goal, object Bag) 81 public static IEnumerable<bool> findall(object Template, IEnumerable<bool> goal, object Bag)
82 { 82 {
83 FindallAnswers findallAnswers = new FindallAnswers(Template); 83 FindallAnswers findallAnswers = new FindallAnswers(Template);
84 foreach (bool l1 in goal) 84 foreach (bool l1 in goal)
85 findallAnswers.add(); 85 findallAnswers.add();
86 return findallAnswers.result(Bag); 86 return findallAnswers.result(Bag);
87 } 87 }
88 88
89 /// <summary> 89 /// <summary>
90 /// Like findall, except return an array of the results. 90 /// Like findall, except return an array of the results.
91 /// </summary> 91 /// </summary>
92 /// <param name="template"></param> 92 /// <param name="template"></param>
93 /// <param name="goal"></param> 93 /// <param name="goal"></param>
94 /// <returns></returns> 94 /// <returns></returns>
95 public static List<object> findallArray(object Template, IEnumerable<bool> goal) 95 public static List<object> findallArray(object Template, IEnumerable<bool> goal)
96 { 96 {
97 FindallAnswers findallAnswers = new FindallAnswers(Template); 97 FindallAnswers findallAnswers = new FindallAnswers(Template);
98 foreach (bool l1 in goal) 98 foreach (bool l1 in goal)
99 findallAnswers.add(); 99 findallAnswers.add();
100 return findallAnswers.resultArray(); 100 return findallAnswers.resultArray();
101 } 101 }
102 } 102 }
103} 103}