MetaMetaUnify() public method

Merge the information from two Metastructures into one new metastructure.
public MetaMetaUnify ( Metastructure value, IEnumerable &filter ) : Metastructure
value Metastructure The Metastructure to merge with.
filter IEnumerable Test for whether the merging succeeded. Generally a woken goal.
return Metastructure
Exemplo n.º 1
0
        internal IEnumerable <CutState> MetaUnify(Metastructure m)
        {
            if (IsBound)
            {
                throw new InvalidOperationException("Cannot meta-unify a bound variable");
            }
            Metastructure          old    = MetaBinding;
            IEnumerable <CutState> filter = null;

            mValue = old != null?old.MetaMetaUnify(m, out filter) : m;

            try
            {
                if (filter != null)
#pragma warning disable 414, 168, 219
                {
                    // ReSharper disable UnusedVariable
                    foreach (var ignore in filter)
                    // ReSharper restore UnusedVariable
#pragma warning restore 414, 168, 219
                    {
                        yield return(CutState.Continue);
                    }
                }
                else
                {
                    yield return(CutState.Continue);
                }
            }
            finally
            {
                mValue = old;
            }
        }
Exemplo n.º 2
0
        internal IEnumerable <CutState> MetaUnify(Metastructure m)
        {
            if (IsBound)
            {
                throw new InvalidOperationException("Cannot meta-unify a bound variable");
            }
            Metastructure          old    = MetaBinding;
            IEnumerable <CutState> filter = null;

            if (old != null)
            {
                var merged = old.MetaMetaUnify(m, out filter);
                if (merged != null)
                {
                    mValue = merged;
                }
                else
                {
                    // All we have a suspended goal, which is now in the filter
                    // there's no frozen goal, so we just unbind the variable
                    // and see what the filter does.
                    mValue = this;
                }
            }
            else
            {
                mValue = m;
            }

            try
            {
                if (filter != null)
#pragma warning disable 414, 168, 219
                {
                    // ReSharper disable UnusedVariable
                    foreach (var ignore in filter)
                    // ReSharper restore UnusedVariable
#pragma warning restore 414, 168, 219
                    {
                        yield return(CutState.Continue);
                    }
                }
                else
                {
                    yield return(CutState.Continue);
                }
            }
            finally
            {
                mValue = old;
            }
        }
Exemplo n.º 3
0
        IEnumerable <bool> UnifyMetaMeta(Metastructure myMetaStructure, Metastructure theirMetaStructure, LogicVariable them)
        {
            IEnumerable <CutState> filter;

            mValue     = myMetaStructure.MetaMetaUnify(theirMetaStructure, out filter);
            them.Value = this;
#pragma warning disable 414, 168, 219
            // ReSharper disable UnusedVariable
            foreach (var ignore in filter)
            // ReSharper restore UnusedVariable
#pragma warning restore 414, 168, 219
            {
                yield return(false);
            }
            mValue      = myMetaStructure;
            them.mValue = theirMetaStructure; //null;
            //them.IsBound = false;
        }
Exemplo n.º 4
0
 IEnumerable<bool> UnifyMetaMeta(Metastructure myMetaStructure, Metastructure theirMetaStructure, LogicVariable them)
 {
     IEnumerable<CutState> filter;
     object mergedMetaValue = myMetaStructure.MetaMetaUnify(theirMetaStructure, out filter);
     mValue = mergedMetaValue??this;
     them.Value = this;
     #pragma warning disable 414, 168, 219
     // ReSharper disable UnusedVariable
     foreach (var ignore in filter)
         // ReSharper restore UnusedVariable
     #pragma warning restore 414, 168, 219
         yield return false;
     mValue = myMetaStructure;
     them.mValue = theirMetaStructure; //null;
     //them.IsBound = false;
 }
Exemplo n.º 5
0
 /// <summary>
 /// This is an attributed variable with attribute myMetaStructure, unify it with attributed variable them, with attribute theirMetaStructure.
 /// </summary>
 /// <param name="myMetaStructure">This variable's metavalue</param>
 /// <param name="theirMetaStructure">The meta-value of the variable we're unifying with</param>
 /// <param name="them">The variable to unify with</param>
 /// <param name="context">Prolog context</param>
 void UnifyMetaMeta(Metastructure myMetaStructure, Metastructure theirMetaStructure, LogicVariable them, PrologContext context)
 {
     SaveAndUpdate(myMetaStructure.MetaMetaUnify(theirMetaStructure, context), context);
     them.SaveAndUpdate(this, context);
 }
Exemplo n.º 6
0
 /// <summary>
 /// This is an attributed variable with attribute myMetaStructure, unify it with attributed variable them, with attribute theirMetaStructure.
 /// </summary>
 /// <param name="myMetaStructure">This variable's metavalue</param>
 /// <param name="theirMetaStructure">The meta-value of the variable we're unifying with</param>
 /// <param name="them">The variable to unify with</param>
 /// <param name="context">Prolog context</param>
 void UnifyMetaMeta(Metastructure myMetaStructure, Metastructure theirMetaStructure, LogicVariable them, PrologContext context)
 {
     SaveAndUpdate(myMetaStructure.MetaMetaUnify(theirMetaStructure, context), context);
     them.SaveAndUpdate(this, context);
 }