Пример #1
0
        public void Visit(LenExpressionReference reference, ExpressionBuildState state)
        {
            var leftState = new ExpressionBuildState
            {
                Resolve = state.Resolve
            };

            reference.LeftOperand.Visit(this, leftState);

            var target = leftState.Result;

            var targetType = typeData[leftState.ExpressionType];

            var memberMappings = targetType.Members
                                 .Where(x => x.Dimensions != null)
                                 .ToDictionary(x => ((LenExpressionToken)x.Dimensions[0].Value).Value);

            var member = targetType.Members.Single(x => x.VkName == reference.RightOperand.Value);

            string memberName;

            bool takeLength = false;

            if (memberMappings.ContainsKey(member.VkName))
            {
                memberName = memberMappings[member.VkName].Name;

                takeLength = true;
            }
            else
            {
                memberName = member.Name;
            }

            bool isDecomposed = targetType.Name.EndsWith("Info");

            if (isDecomposed)
            {
                state.Result = Variable(memberName.FirstToLower());
            }
            else
            {
                state.Result = Member(target, memberName);
            }

            if (takeLength)
            {
                state.Result = StaticCall("Interop.HeapUtil", "GetLength", state.Result);
            }

            state.ExpressionType = member.Type.VkName;
        }
 public void Visit(LenExpressionReference reference, TokenCheckResult state)
 {
     reference.LeftOperand.Visit(this, state);
     reference.RightOperand.Visit(this, state);
 }
 public void Visit(LenExpressionReference reference, EqualityCheckResult state)
 {
     state.AreEqual = state.Other is LenExpressionReference otherReference &&
                      Check(reference.LeftOperand, otherReference.LeftOperand) &&
                      Check(reference.RightOperand, otherReference.RightOperand);
 }