/// <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];

            int index = 0;

            foreach (var local in locals)
            {
                var operand = StackLayout.AddStackLocal(local.Type, local.IsPinned);

                LocalVariables[index++] = operand;
            }
        }
示例#2
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;
            }
        }