From 323ada012d3bed0c6f7a6d5d0ee14b409b7457c7 Mon Sep 17 00:00:00 2001
From: Charles Krinke
Date: Wed, 13 Aug 2008 14:13:49 +0000
Subject: Mantis#1931. Thank you kindly, Kinoc for a patch that: * Yield Prolog
1.0.1 Released : it passes all but 9 of the 421 tests in the ISO Prolog test
suite (97.8%) . * support dynamic predicates and rules. * support 'import' to
use external static functions improves connection to C# functions * Matches
Yield Prolog r831
---
.../Shared/Api/Runtime/YieldProlog/Variable.cs | 32 ++++++++++++++++++----
1 file changed, 27 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs')
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs
index f68a941..a606465 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Variable.cs
@@ -43,6 +43,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
bool ground();
}
+ ///
+ /// A Variable is passed to a function so that it can be unified with
+ /// value or another Variable. See getValue and unify for details.
+ ///
public class Variable : IUnifiable
{
// Use _isBound separate from _value so that it can be bound to any value,
@@ -50,6 +54,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
private bool _isBound = false;
private object _value;
+ ///
+ /// If this Variable is unbound, then just return this Variable.
+ /// Otherwise, if this has been bound to a value with unify, return the value.
+ /// If the bound value is another Variable, this follows the "variable chain"
+ /// to the end and returns the final value, or the final Variable if it is unbound.
+ /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html
+ ///
+ ///
public object getValue()
{
if (!_isBound)
@@ -68,6 +80,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
return result;
}
+ ///
+ /// If this Variable is bound, then just call YP.unify to unify this with arg.
+ /// (Note that if arg is an unbound Variable, then YP.unify will bind it to
+ /// this Variable's value.)
+ /// Otherwise, bind this Variable to YP.getValue(arg) and yield once. After the
+ /// yield, return this Variable to the unbound state.
+ /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html
+ ///
+ ///
+ ///
public IEnumerable unify(object arg)
{
if (!_isBound)
@@ -92,12 +114,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
}
else
{
-// disable warning: don't see how we can code this differently short
-// of rewriting the whole thing
-#pragma warning disable 0168
+ // disable warning on l1, don't see how we can
+ // code this differently
+ #pragma warning disable 0168
foreach (bool l1 in YP.unify(this, arg))
yield return false;
-#pragma warning restore 0168
+ #pragma warning restore 0168
}
}
@@ -105,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.YieldProlog
{
object value = getValue();
if (value == this)
- return "Variable";
+ return "_Variable";
else
return getValue().ToString();
}
--
cgit v1.1