Example #1
0
 /// <summary>
 /// Equivalent to luaK_setoneret. </summary>
 internal void kSetoneret(Expdesc e)
 {
     if (e.kind() == Expdesc.VCALL)     // expression is an open function call?
     {
         e.nonreloc(Lua.ARGA(getcode(e)));
     }
     else if (e.kind() == Expdesc.VVARARG)
     {
         setargb(e, 2);
         e.Kind = Expdesc.VRELOCABLE;
     }
 }
Example #2
0
 /// <summary>
 /// Equivalent to luaK_setreturns. </summary>
 internal void kSetreturns(Expdesc e, int nresults)
 {
     if (e.kind() == Expdesc.VCALL)     // expression is an open function call?
     {
         setargc(e, nresults + 1);
     }
     else if (e.kind() == Expdesc.VVARARG)
     {
         setargb(e, nresults + 1);
         setarga(e, freereg_Renamed);
         kReserveregs(1);
     }
 }
Example #3
0
 private void freeexp(Expdesc e)
 {
     if (e.kind() == Expdesc.VNONRELOC)
     {
         freereg(e.info_Renamed);
     }
 }
Example #4
0
        /// <summary>
        /// Equivalent to luaK_prefix. </summary>
        internal void kPrefix(int op, Expdesc e)
        {
            Expdesc e2 = new Expdesc(Expdesc.VKNUM, 0);

            switch (op)
            {
            case Syntax.OPR_MINUS:
                if (e.kind() == Expdesc.VK)
                {
                    kExp2anyreg(e);
                }
                codearith(Lua.OP_UNM, e, e2);
                break;

            case Syntax.OPR_NOT:
                codenot(e);
                break;

            case Syntax.OPR_LEN:
                kExp2anyreg(e);
                codearith(Lua.OP_LEN, e, e2);
                break;

            default:
                throw new System.ArgumentException();
            }
        }
Example #5
0
        /// <summary>
        /// Equivalent to luaK_dischargevars. </summary>
        internal void kDischargevars(Expdesc e)
        {
            switch (e.kind())
            {
            case Expdesc.VLOCAL:
                e.Kind = Expdesc.VNONRELOC;
                break;

            case Expdesc.VUPVAL:
                e.reloc(kCodeABC(Lua.OP_GETUPVAL, 0, e.info_Renamed, 0));
                break;

            case Expdesc.VGLOBAL:
                e.reloc(kCodeABx(Lua.OP_GETGLOBAL, 0, e.info_Renamed));
                break;

            case Expdesc.VINDEXED:
                freereg(e.aux());
                freereg(e.info());
                e.reloc(kCodeABC(Lua.OP_GETTABLE, 0, e.info_Renamed, e.aux_Renamed));
                break;

            case Expdesc.VVARARG:
            case Expdesc.VCALL:
                kSetoneret(e);
                break;

            default:
                break;         // there is one value available (somewhere)
            }
        }