示例#1
0
        //### bob: for some reason, the binder doesn't work here. once that's fixed,
        // get rid of the explicit bound arg
        /// <summary>
        /// Binds this expression using the given binder to convert the unbound
        /// form to the bound one.
        /// </summary>
        /// <param name="binder">A binder to convert from unbound to bound form.</param>
        public void Bind(BindingContext context, IUnboundExprVisitor <IBoundExpr> binder)
        {
            if (binder == null)
            {
                throw new ArgumentNullException("binder");
            }
            if (Unbound == null)
            {
                throw new InvalidOperationException("Cannot bind an Expr that is already bound.");
            }

            //### bob: doing this here is a hack. need to find a clean location for the
            // multi-pass compiling. if we get away from a separate bound and unbound expr and
            // just use more mutability, this whole class will go away.
            // desugar
            var letTransformer = new LetTransformer(context.NameGenerator);
            var unbound        = Unbound.AcceptTransformer(letTransformer);

            var loopTransformer = new LoopTransformer(context.NameGenerator);

            unbound = unbound.AcceptTransformer(loopTransformer);

            var expandTuple = new ExpandTupleAssignment(context.NameGenerator);

            unbound = unbound.AcceptTransformer(expandTuple);

            Bound = unbound.Accept(binder);

            // discard the unbound one now. makes sure we're clear on what state we expect
            // the expression to be in.
            Unbound = null;
        }
示例#2
0
 public override string ToString()
 {
     if (IsBound)
     {
         return(Bound.ToString());
     }
     return(Unbound.ToString());
 }
示例#3
0
        /// <summary>
        /// バインディングを解除します。
        /// </summary>
        public void Unbind()
        {
            Unbound.SafeRaiseEvent(this, EventArgs.Empty);
            Unbound = null;

            var component = Binding.BindableTarget as Component;

            if (component != null)
            {
                component.Disposed -= OnUnbind;
            }

            Binding.Control.Disposed -= OnUnbind;
            Binding.IsBinding         = false;
        }
示例#4
0
 void UnbindRoot()
 {
     _root = new Unbound(this);
     ++_rev;
 }
示例#5
0
 /// <summary>
 /// Construct a var in a given namespace with a given name.
 /// </summary>
 /// <param name="ns">The namespace.</param>
 /// <param name="sym">The var.</param>
 internal Var(Namespace ns, Symbol sym)
 {
     _ns = ns;
     _sym = sym;
     _threadBound = new AtomicBoolean(false);
     _root = new Unbound(this);
     setMeta(PersistentHashMap.EMPTY);
 }