diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs index 281fb42..a9bd563 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/YieldProlog/Variable.cs | |||
@@ -43,6 +43,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
43 | bool ground(); | 43 | bool ground(); |
44 | } | 44 | } |
45 | 45 | ||
46 | /// <summary> | ||
47 | /// A Variable is passed to a function so that it can be unified with | ||
48 | /// value or another Variable. See getValue and unify for details. | ||
49 | /// </summary> | ||
46 | public class Variable : IUnifiable | 50 | public class Variable : IUnifiable |
47 | { | 51 | { |
48 | // Use _isBound separate from _value so that it can be bound to any value, | 52 | // Use _isBound separate from _value so that it can be bound to any value, |
@@ -50,6 +54,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
50 | private bool _isBound = false; | 54 | private bool _isBound = false; |
51 | private object _value; | 55 | private object _value; |
52 | 56 | ||
57 | /// <summary> | ||
58 | /// If this Variable is unbound, then just return this Variable. | ||
59 | /// Otherwise, if this has been bound to a value with unify, return the value. | ||
60 | /// If the bound value is another Variable, this follows the "variable chain" | ||
61 | /// to the end and returns the final value, or the final Variable if it is unbound. | ||
62 | /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html | ||
63 | /// </summary> | ||
64 | /// <returns></returns> | ||
53 | public object getValue() | 65 | public object getValue() |
54 | { | 66 | { |
55 | if (!_isBound) | 67 | if (!_isBound) |
@@ -68,6 +80,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
68 | return result; | 80 | return result; |
69 | } | 81 | } |
70 | 82 | ||
83 | /// <summary> | ||
84 | /// If this Variable is bound, then just call YP.unify to unify this with arg. | ||
85 | /// (Note that if arg is an unbound Variable, then YP.unify will bind it to | ||
86 | /// this Variable's value.) | ||
87 | /// Otherwise, bind this Variable to YP.getValue(arg) and yield once. After the | ||
88 | /// yield, return this Variable to the unbound state. | ||
89 | /// For more details, see http://yieldprolog.sourceforge.net/tutorial1.html | ||
90 | /// </summary> | ||
91 | /// <param name="arg"></param> | ||
92 | /// <returns></returns> | ||
71 | public IEnumerable<bool> unify(object arg) | 93 | public IEnumerable<bool> unify(object arg) |
72 | { | 94 | { |
73 | if (!_isBound) | 95 | if (!_isBound) |
@@ -105,7 +127,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.YieldProlog | |||
105 | { | 127 | { |
106 | object value = getValue(); | 128 | object value = getValue(); |
107 | if (value == this) | 129 | if (value == this) |
108 | return "Variable"; | 130 | return "_Variable"; |
109 | else | 131 | else |
110 | return getValue().ToString(); | 132 | return getValue().ToString(); |
111 | } | 133 | } |