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

            if (!Translator.TryGetCachedSub(CurrOp, out ATranslatedSub Sub))
            {
                return(false);
            }

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

            foreach (ARegister Reg in Sub.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(Sub.Method);

            Sub.AddCaller(Root.Position);

            return(true);
        }