ilcclib.Converter.CIL.CILConverter.FieldAccessExpression C# (CSharp) 메소드

FieldAccessExpression() 개인적인 메소드

private FieldAccessExpression ( CParser FieldAccessExpression ) : void
FieldAccessExpression CParser
리턴 void
        public void FieldAccessExpression(CParser.FieldAccessExpression FieldAccessExpression)
        {
            var FieldName = FieldAccessExpression.FieldName;
            var LeftExpression = FieldAccessExpression.LeftExpression;
            var LeftCType = LeftExpression.GetCachedCType(this);
            var LeftType = ConvertCTypeToType(LeftCType);

            var CUnionStructType = LeftCType.GetCUnionStructType();

            CType FieldCType;

            if (CUnionStructType != null)
            {
                FieldCType = CUnionStructType.GetFieldByName(FieldName).CType;
            }
            else
            {
                throw (new NotImplementedException(String.Format("Unknown CTYpe {0}", LeftCType)));
            }

            //Console.WriteLine(LeftCType.GetType());
            //= LeftCType.GetFieldByName(FieldName).CType;
            FieldInfo FieldInfo;
            MethodInfo MethodInfo;
            Type FinalStructType;

            if (LeftType.IsPointer)
            {
                if (FieldAccessExpression.Operator != "->") throw (new InvalidOperationException("A pointer structure should be accesses with the '->' operator"));
                FinalStructType = LeftType.GetElementType();
            }
            else
            {
                if (FieldAccessExpression.Operator != ".") throw (new InvalidOperationException("A non-pointer structure should be accesses with the '.' operator"));
                FinalStructType = LeftType;
            }

            FieldInfo = FinalStructType.GetField(FieldName);
            MethodInfo = FinalStructType.GetMethod("get_" + FieldName);

            if (FieldInfo == null && MethodInfo == null)
            {
                throw (new Exception(String.Format("Can't find field name {0}.{1}", LeftType, FieldName)));
            }

            if (MethodInfo != null && GenerateAddress)
            {
                throw(new InvalidOperationException("Can't generate address for a property"));
            }

            //Console.WriteLine(FieldInfo);

            DoGenerateAddress(true, () =>
            {
                Traverse(FieldAccessExpression.LeftExpression);
            });

            //Console.WriteLine(FieldCType);

            // For fixed array types, get always the address?
            if (GenerateAddress || FieldCType is CArrayType)
            {
                if (FieldInfo != null)
                {
                    SafeILGenerator.LoadFieldAddress(FieldInfo, UseLoadFieldAddress: false);
                }
                else
                {
                    throw(new InvalidOperationException());
                }
            }
            else
            {
                if (FieldInfo != null)
                {
                    SafeILGenerator.LoadField(FieldInfo);
                }
                else if (MethodInfo != null)
                {
                    SafeILGenerator.Call(MethodInfo);
                }
                else
                {
                    throw (new InvalidOperationException());
                }
            }
            //SafeILGenerator.LoadField
            //throw(new NotImplementedException());
        }