示例#1
0
        private Result OnFetchFunction()
        {
            _variableContext.Begin();

            for (int i = 0, argCount = _functionDeclaration.ArgumentCount; i < argCount; i++)
            {
                var arg = _functionDeclaration.GetArgument(i);
                var vd  = _functionNode.GetArgument(i);

                if (vd == null)
                {
                    continue;
                }

                // Overlapped function arguments.
                if (vd.Attributes != null)
                {
                    throw new ArgumentException("Overlapped function arguments");
                }
                var va = _variableContext.Add(vd, 0, 0);

                var aType = arg.VariableType;
                var vType = vd.Type;

                if (arg.RegisterIndex != RegisterIndex.Invalid)
                {
                    if (aType.GetRegisterClass() == vd.Info.RegisterClass)
                    {
                        va.Flags      |= VariableFlags.WReg;
                        va.OutRegIndex = arg.RegisterIndex;
                    }
                    else
                    {
                        va.Flags |= VariableFlags.WConv;
                    }
                }
                else
                {
                    if ((aType.GetRegisterClass() == vd.Info.RegisterClass) || (vType == VariableType.XmmSs && aType == VariableType.Fp32) || (vType == VariableType.XmmSd && aType == VariableType.Fp64))
                    {
                        va.Flags |= VariableFlags.WMem;
                    }
                    else
                    {
                        // TODO: [COMPILER] Not implemented.
                    }
                }
            }

            _variableContext.End(_node);
            return(Result.Break);
        }