Exemplo n.º 1
0
        internal override void Walk(EmitContext ec)
        {
            if (ec.Emitting)
            {
                ec.EmitRArray(alen);
            }

            int i = 0;

            for (RNode n = this; n != null;)
            {
                if (n is RNArray)
                {
                    if (n.head != null)
                    {
                        if (ec.Emitting)
                        {
                            ec.EmitDup();
                            ec.EmitInt(i);
                        }
                        n.head.Walk(ec);
                        if (ec.Emitting)
                        {
                            ec.EmitRArraySet();
                        }
                    }
                    n = n.next;
                    i++;
                }
                else
                {
                    // n.Walk(ec);
                    // break;
                    throw new NotSupportedException("bug: array has tail of type " + n.GetType().Name);
                }
            }
        }
Exemplo n.º 2
0
 internal override void Walk(EmitContext ec)
 {
     // Linear scan of linked list for O(1) stack space
     for (RNode n = this; n != null;)
     {
         if (n is RNBlock)
         {
             RNode current = n.head;
             current.Walk(ec);
             n = n.next;
             if (ec.Emitting && n != null)
             {
                 // Discard previous result, block returns last value generated
                 ec.EmitDiscard();
             }
         }
         else
         {
             throw new NotSupportedException("bug: not supported block tail: " + n.GetType().Name);
         }
     }
 }