예제 #1
0
        internal void AllocVariables(CompilerContext cc)
        {
            int i;
            int count = _functionPrototype.Arguments.Length;
            if (count == 0)
                return;

            for (i = 0; i < count; i++)
            {
                CompilerVar vdata = _argumentVariables[i];

                if (vdata.FirstItem != null ||
                    vdata.IsRegArgument ||
                    vdata.IsMemArgument)
                {
                    // Variable is used.
                    if (vdata.RegisterIndex != RegIndex.Invalid)
                    {
                        vdata.State = VariableState.Register;
                        // If variable is in register -> mark it as changed so it will not be
                        // lost by first spill.
                        vdata.Changed = true;
                        cc.AllocatedVariable(vdata);
                    }
                    else if (vdata.IsMemArgument)
                    {
                        vdata.State = VariableState.Memory;
                    }
                }
                else
                {
                    // Variable is not used.
                    vdata.RegisterIndex = RegIndex.Invalid;
                }
            }
        }