Exemplo n.º 1
0
Arquivo: Var.cs Projeto: ryrency/Misc
        /// <summary>
        /// Push a new frame of bindings onto the binding stack.
        /// </summary>
        /// <param name="bindings">The new bindings.</param>
        /// <remarks>Lowercase name for core.clj compatability.</remarks>
        public static void pushThreadBindings(Associative bindings)
        {
            Frame       f    = CurrentFrame;
            Associative bmap = f.Bindings;

            for (ISeq bs = bindings.seq(); bs != null; bs = bs.next())
            {
                IMapEntry e = (IMapEntry)bs.first();
                Var       v = (Var)e.key();
                v.Validate(e.val());
                v._count.incrementAndGet();
                bmap = bmap.assoc(v, new Box(e.val()));
            }
            CurrentFrame = new Frame(bindings, bmap, f);
        }
Exemplo n.º 2
0
        public static void pushThreadBindings(Associative bindings)
        {
            Frame       f    = CurrentFrame;
            Associative bmap = f.Bindings;

            for (ISeq bs = bindings.seq(); bs != null; bs = bs.next())
            {
                IMapEntry e = (IMapEntry)bs.first();
                Var       v = (Var)e.key();
                if (!v._dynamic)
                {
                    throw new InvalidOperationException(String.Format("Can't dynamically bind non-dynamic var: {0}/{1}", v.Namespace, v.Symbol));
                }
                v.Validate(e.val());
                v._threadBound.set(true);
                bmap = bmap.assoc(v, new TBox(Thread.CurrentThread, e.val()));
            }
            CurrentFrame = new Frame(bmap, f);
        }