Example #1
0
        private IEnumerable <VerificationResult> VerifyType(EcmaModule module, TypeDefinitionHandle typeHandle)
        {
            var builder = new ArrayBuilder <VerificationResult>();

            try
            {
                TypeVerifier typeVerifier = new TypeVerifier(module, typeHandle, _typeSystemContext, _verifierOptions);

                typeVerifier.ReportVerificationError = (code, args) =>
                {
                    builder.Add(new VerificationResult()
                    {
                        Code    = code,
                        Message = $"[MD]: Error: {_stringResourceManager.Value.GetString(code.ToString(), CultureInfo.InvariantCulture)}",
                        Args    = args
                    });
                };

                typeVerifier.Verify();
            }
            catch (BadImageFormatException)
            {
                builder.Add(new VerificationResult()
                {
                    Type    = typeHandle,
                    Message = "Unable to resolve token"
                });
            }
            catch (NotImplementedException e)
            {
                reportException(e);
            }
            catch (InvalidProgramException e)
            {
                reportException(e);
            }
            catch (PlatformNotSupportedException e)
            {
                reportException(e);
            }
            catch (VerifierException e)
            {
                reportException(e);
            }
            catch (TypeSystemException e)
            {
                reportException(e);
            }

            return(builder.ToArray());

            void reportException(Exception e)
            {
                builder.Add(new VerificationResult()
                {
                    Type    = typeHandle,
                    Message = e.Message
                });
            }
        }
Example #2
0
        private DeclareExpression(IParser parser, IEnumerable <IToken> tokens, ref IParseError parseError)
        {
            this.tokens = tokens;
            IToken keyword, var_name, var_type, end;
            int    count = F.count <IToken>(tokens);

            if (count == 4)   // declare name type end
            {
                keyword = F.first <IToken>(tokens);
                IEnumerable <IToken> rest = F.rest <IToken>(tokens);
                var_name = F.first <IToken>(rest);
                rest     = F.rest <IToken>(rest);
                var_type = F.first <IToken>(rest);
                rest     = F.rest <IToken>(rest);
                end      = F.first <IToken>(rest);
                Collision collision = Collision._none;
                if (VariableVerifier.Verify(var_name.Info, parser.Keywords, parser.Types, parser.Variables, ref collision))
                {
                    if (TypeVerifier.Verify(var_type.Info, parser.Keywords, parser.Types, parser.Variables, ref collision))
                    {
                    }
                    else
                    {
                        tokenError("type", ref parseError, collision);
                    }
                }
                else
                {
                    tokenError("variable", ref parseError, collision);
                }
            }
        }