aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs16
1 files changed, 13 insertions, 3 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs
index 83ace2d..daac0ba 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/ListPair.cs
@@ -132,6 +132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
132 /// <summary> 132 /// <summary>
133 /// Return an array of the elements in list or null if it is not 133 /// Return an array of the elements in list or null if it is not
134 /// a proper list. If list is Atom.NIL, return an array of zero elements. 134 /// a proper list. If list is Atom.NIL, return an array of zero elements.
135 /// If the list or one of the tails of the list is Variable, raise an instantiation_error.
135 /// This does not call YP.getValue on each element. 136 /// This does not call YP.getValue on each element.
136 /// </summary> 137 /// </summary>
137 /// <param name="list"></param> 138 /// <param name="list"></param>
@@ -143,10 +144,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
143 return new object[0]; 144 return new object[0];
144 145
145 List<object> result = new List<object>(); 146 List<object> result = new List<object>();
146 for (object element = list; 147 object element = list;
147 element is Functor2 && ((Functor2)element)._name == Atom.DOT; 148 while (true) {
148 element = YP.getValue(((Functor2)element)._arg2)) 149 if (element == Atom.NIL)
150 break;
151 if (element is Variable)
152 throw new PrologException(Atom.a("instantiation_error"),
153 "List tail is an unbound variable");
154 if (!(element is Functor2 && ((Functor2)element)._name == Atom.DOT))
155 // Not a proper list.
156 return null;
149 result.Add(((Functor2)element)._arg1); 157 result.Add(((Functor2)element)._arg1);
158 element = YP.getValue(((Functor2)element)._arg2);
159 }
150 160
151 if (result.Count <= 0) 161 if (result.Count <= 0)
152 return null; 162 return null;