Esempio n. 1
0
        internal override void Walk(EmitContext ec)
        {
            if (ec.Emitting)
            {
                Label skip_label = ec.DefineLabel();

                nd1st.Walk(ec);
                ec.EmitDup();
                LocalBuilder first = ec.EmitStoreTemp();
                ec.EmitBranchIfTrue(skip_label);

                nd2nd.Walk(ec);
                ec.EmitDup();
                LocalBuilder second = ec.EmitStoreTemp();
                ec.EmitBranchIfTrue(skip_label);

                ec.EmitLoadTemp(second);
                ec.EmitStoreTemp(first);

                ec.MarkLabel(skip_label);
                ec.EmitLoadTemp(first);
            }
            else
            {
                nd1st.Walk(ec);
                nd2nd.Walk(ec);
            }
        }
Esempio n. 2
0
        internal Type block; // Generated type of the block attached to the call

        // ( argsarr -- argsarr )
        internal static void EmitStoreArg(EmitContext ec, int i, RNode val)
        {
            ec.EmitDup();  // arr
            ec.EmitInt(i); // idx
            val.Walk(ec);  // val
            ec.EmitArrayStore();
        }
Esempio n. 3
0
        internal override void Walk(EmitContext ec)
        {
            // Due to the slightly weird RNode inheritance hierarchy
            bool is_load = this is RNLVar || this is RNDVar;

            if (!(is_load || this is RNDAsgn || this is RNLAsgn))
            {
                throw new NotSupportedException("bug: variable type not supported: " + this.GetType().Name);
            }

            if (ec.Resolving)
            {
                v = ec.scope.MarkVariable(vid);
            }

            if (!is_load)
            {
                val.Walk(ec);
            }

            if (ec.Emitting)
            {
                if (is_load)
                {
                    Variable v = ec.scope.GetVariable(vid);
                    ec.EmitLoadVar(v);
                }
                else
                {
                    ec.EmitDup();
                    ec.EmitStoreVar(v);
                }
            }
        }
Esempio n. 4
0
 internal override void Walk(EmitContext ec)
 {
     val.Walk(ec);
     if (ec.Emitting)
     {
         ec.EmitDup();
         ec.EmitSetGlobal(ec.id2name(vid));
     }
 }
Esempio n. 5
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);
                }
            }
        }
Esempio n. 6
0
        internal override void Walk(EmitContext ec)
        {
            // Due to the slightly weird RNode inheritance hierarchy
            bool is_load = this is RNLVar || this is RNDVar;
            
            if(!(is_load || this is RNDAsgn || this is RNLAsgn)) {
                throw new NotSupportedException("bug: variable type not supported: " + this.GetType().Name);
            }

            if(ec.Resolving) {
                v = ec.scope.MarkVariable(vid);
            }

            if(!is_load)
                val.Walk(ec);
            
            if(ec.Emitting) {
                if(is_load) {
                    Variable v = ec.scope.GetVariable(vid);
                    ec.EmitLoadVar(v);
                } else {
                    ec.EmitDup();
                    ec.EmitStoreVar(v);
                }
            }
        }
Esempio n. 7
0
 internal Type block; // Generated type of the block attached to the call
 
 // ( argsarr -- argsarr )
 internal static void EmitStoreArg(EmitContext ec, int i, RNode val) {
     ec.EmitDup(); // arr
     ec.EmitInt(i); // idx
     val.Walk(ec); // val
     ec.EmitArrayStore();
 }
Esempio n. 8
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);
         }
     }
 }
Esempio n. 9
0
 internal override void Walk(EmitContext ec)
 {
     val.Walk(ec);
     if(ec.Emitting) {
         ec.EmitDup();
         ec.EmitSetGlobal(ec.id2name(vid));
     }
 }
Esempio n. 10
0
        internal override void Walk(EmitContext ec)
        {
            if(ec.Emitting) {
                Label skip_label = ec.DefineLabel();

                nd1st.Walk(ec);
                ec.EmitDup();
                LocalBuilder first = ec.EmitStoreTemp();
                ec.EmitBranchIfTrue(skip_label);
                
                nd2nd.Walk(ec);
                ec.EmitDup();
                LocalBuilder second = ec.EmitStoreTemp();
                ec.EmitBranchIfTrue(skip_label);
                
                ec.EmitLoadTemp(second);
                ec.EmitStoreTemp(first);
                
                ec.MarkLabel(skip_label);
                ec.EmitLoadTemp(first);
            } else {
                nd1st.Walk(ec);
                nd2nd.Walk(ec);
            }
        }