/// <inheritdoc/>
 public override IReadOnlyList <string> CheckConformance(Instruction instance, MethodBody body)
 {
     return(CallPrototype.CheckArgumentTypes(
                GetArgumentList(instance),
                Constructor.Parameters,
                body));
 }
示例#2
0
        /// <inheritdoc/>
        public override IReadOnlyList <string> CheckConformance(
            Instruction instance,
            MethodBody body)
        {
            var errors = new List <string>();

            var thisPtrType = body.Implementation
                              .GetValueType(GetThisArgument(instance))
                              as PointerType;

            if (thisPtrType == null || thisPtrType.Kind != PointerKind.Reference)
            {
                errors.Add("Type of the 'this' argument must be a reference pointer type.");
            }

            var parameters = Callee.Parameters;
            var argList    = GetArgumentList(instance);
            int paramCount = parameters.Count;

            for (int i = 0; i < paramCount; i++)
            {
                var paramType = parameters[i].Type;
                var argType   = body.Implementation.GetValueType(argList[i]);

                if (!paramType.Equals(argType))
                {
                    errors.Add(
                        string.Format(
                            "Argument of type '{0}' was provided where an " +
                            "argument of type '{1}' was expected.",
                            paramType.FullName,
                            argType.FullName));
                }
            }

            errors.AddRange(
                CallPrototype.CheckArgumentTypes(argList, Callee.Parameters, body));

            return(errors);
        }