Exemplo n.º 1
0
        public override bool Try(TextBuffer output, BindingEnvironment e, Continuation k,
                                 MethodCallFrame predecessor)
        {
            if (!e.TryCopyGround(Value.Eval(e), out var expValue))
            {
                // You can't set a variable to a non-ground value
                throw new ArgumentInstantiationException("set", e,
                                                         new[] { (object)GlobalVariable, Value });
            }

            if (LocalVariable == null)
            {
                return(Continue(output,
                                new BindingEnvironment(e,
                                                       e.Unifications,
                                                       e.State.Bind(GlobalVariable, expValue)),
                                k, predecessor));
            }

            if (e.Unify(LocalVariable, expValue, out var result))
            {
                return(Continue(output,
                                new BindingEnvironment(e, result, e.State),
                                k, predecessor));
            }

            return(false);
        }
Exemplo n.º 2
0
 public override object Eval(BindingEnvironment e) => Operator.Implementation(Arg.Eval(e));