Exemplo n.º 1
0
        public bool TryOptEmitSubroutineCall()
        {
            if (CurrBlock.Next == null)
            {
                return(false);
            }

            if (CurrOp.Emitter != AInstEmit.Bl)
            {
                return(false);
            }

            if (!Cache.TryGetSubroutine(((AOpCodeBImmAl)CurrOp).Imm, out ATranslatedSub Subroutine))
            {
                return(false);
            }

            for (int Index = 0; Index < ATranslatedSub.FixedArgTypes.Length; Index++)
            {
                EmitLdarg(Index);
            }

            foreach (ARegister Reg in Subroutine.Params)
            {
                switch (Reg.Type)
                {
                case ARegisterType.Flag:   Ldloc(Reg.Index, AIoType.Flag);   break;

                case ARegisterType.Int:    Ldloc(Reg.Index, AIoType.Int);    break;

                case ARegisterType.Vector: Ldloc(Reg.Index, AIoType.Vector); break;
                }
            }

            EmitCall(Subroutine.Method);

            Subroutine.AddCaller(Root.Position);

            return(true);
        }