Exemplo n.º 1
0
        /// <summary>
        /// Allocates the local variable virtual registers.
        /// </summary>
        /// <param name="locals">The locals.</param>
        public void SetLocalVariables(IList <MosaLocal> locals)
        {
            LocalVariables = new Operand[locals.Count];

            for (int index = 0; index < locals.Count; index++)
            {
                var     local = locals[index];
                Operand operand;

                if (local.Type.IsValueType || local.Type.IsPointer)
                {
                    operand = StackLayout.AddStackLocal(local.Type);
                }
                else
                {
                    var stacktype = local.Type.GetStackType();
                    operand = VirtualRegisters.Allocate(stacktype);
                }

                LocalVariables[index] = operand;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a new virtual register operand.
 /// </summary>
 /// <param name="type">The signature type of the virtual register.</param>
 /// <returns>
 /// An operand, which represents the virtual register.
 /// </returns>
 public Operand CreateVirtualRegister(MosaType type)
 {
     return(VirtualRegisters.Allocate(type));
 }