Ejemplo n.º 1
0
        private string GetTokenFromVault(TokenTypes tokenType)
        {
            var token = vault.RetrieveAll().FirstOrDefault((x) => x.Resource == tokenType.ToString());

            if (token != null)
            {
                token.RetrievePassword();
                return(token.Password);
            }

            return(string.Empty);
        }
Ejemplo n.º 2
0
        public static string ToString(TokenTypes type)
        {
            switch (type)
            {
            case TokenTypes.oParen: return("'('");

            case TokenTypes.cParen: return("')'");

            case TokenTypes.oCurly: return("'{'");

            case TokenTypes.cCurly: return("'}'");
            }
            return(type.ToString());
        }
        public Result CheckToken(TokenTypes expectToken, Token currentToken)
        {
            if (expectToken == currentToken.Type)
            {
                return new Result()
                       {
                           Succes = true, Excpetion = null
                       }
            }
            ;

            return(new Result {
                Succes = false, Excpetion = new SyntacticException($"Expected a {expectToken.ToString()} Token ", currentToken.Row, currentToken.Column)
            });
        }
Ejemplo n.º 4
0
        public LexerToken MatchGet(TokenTypes expected)
        {
            LexerToken t = buffer.ElementAt(consumeOffset);

            if (!t.IsType(expected))
            {
                throw new Exceptions.ParsingException(string.Format(
                                                          Config.UserCulture, Properties.Resources.ex_Parsing_Failed_TokenMismatch, expected.ToString(), t.Text, CurrentTokenNeighbourhood()));
            }
            Consume();
            return(t);
        }
Ejemplo n.º 5
0
 public void Match(TokenTypes expected, string content)
 {
     if (!buffer.ElementAt(consumeOffset).IsType(expected) || !buffer.ElementAt(consumeOffset).Text.Equals(content))
     {
         throw new Exceptions.ParsingException(string.Format(
                                                   Config.UserCulture, Properties.Resources.ex_Parsing_Failed_TokenMismatchEx, expected.ToString(), buffer.ElementAt(consumeOffset).Text, CurrentTokenNeighbourhood(), content));
     }
     Consume();
 }
Ejemplo n.º 6
0
 public LexerToken MatchGet(TokenTypes expected)
 {
     LexerToken t = buffer.ElementAt(consumeOffset);
     if(!t.IsType(expected))
         throw new Exceptions.ParsingException(string.Format(
             Config.UserCulture, Properties.Resources.ex_Parsing_Failed_TokenMismatch, expected.ToString(), t.Text, CurrentTokenNeighbourhood()));
     Consume();
     return t;
 }
Ejemplo n.º 7
0
 public void Match(TokenTypes expected, string content)
 {
     if(!buffer.ElementAt(consumeOffset).IsType(expected) || !buffer.ElementAt(consumeOffset).Text.Equals(content))
         throw new Exceptions.ParsingException(string.Format(
             Config.UserCulture, Properties.Resources.ex_Parsing_Failed_TokenMismatchEx, expected.ToString(), buffer.ElementAt(consumeOffset).Text, CurrentTokenNeighbourhood(), content));
     Consume();
 }
        /// <summary>
        /// Retrieves the method definition identified by the given token in the scope.
        /// </summary>
        /// <param name="token">The token of the method to retrieve.</param>
        /// <returns></returns>
        RuntimeMethod IModuleTypeSystem.GetMethod(TokenTypes token)
        {
            switch (TokenTypes.TableMask & token)
            {
                case TokenTypes.MethodDef:
                    return methods[(int)(TokenTypes.RowIndexMask & token) - 1];

                case TokenTypes.MemberRef:
                    MemberRefRow row = metadata.ReadMemberRefRow(token);
                    string nameString = metadata.ReadString(row.NameStringIdx);
                    RuntimeType type = ((IModuleTypeSystem)this).GetType(row.ClassTableIdx);

                    MethodSignature sig = (MethodSignature)Signature.FromMemberRefSignatureToken(metadata, row.SignatureBlobIdx);

                    CilGenericType genericType = type as CilGenericType;
                    if (genericType != null)
                    {
                        sig.ApplyGenericType(genericType.GenericArguments);
                    }

                    foreach (RuntimeMethod method in type.Methods)
                    {
                        if (method.Name != nameString)
                            continue;
                        if (!method.Signature.Matches(sig))
                            continue;

                        return method;
                    }

                    throw new MissingMethodException(type.Name, nameString);

                case TokenTypes.MethodSpec:
                    return DecodeMethodSpec(token);

                default:
                    throw new NotSupportedException(@"Can't get method for token " + token.ToString("x"));
            }
        }
        /// <summary>
        /// Retrieves the field definition identified by the given token in the scope.
        /// </summary>
        /// <param name="token">The token of the field to retrieve.</param>
        /// <returns></returns>
        RuntimeField IModuleTypeSystem.GetField(TokenTypes token)
        {
            switch (TokenTypes.TableMask & token)
            {
                case TokenTypes.Field:
                    return fields[(int)(token & TokenTypes.RowIndexMask) - 1];

                case TokenTypes.MemberRef:
                    return GetFieldForMemberReference(token);

                default:
                    throw new NotSupportedException(@"Can't get method for token " + token.ToString("x"));
            }
        }
Ejemplo n.º 10
0
 public virtual BaseType GetBaseType()
 {
     return(TypesTable.Instance.GetType(Type.ToString().ToLower()));
 }
Ejemplo n.º 11
0
 public void Match(TokenTypes expected)
 {
     if(!buffer.ElementAt(consumeOffset).IsType(expected))
         throw new ParsingException(string.Format(MathNet.Symbolics.Properties.Resources.ex_Parsing_Failed_TokenMismatch, expected.ToString(), buffer.ElementAt(consumeOffset).Text, CurrentTokenNeighbourhood()));
     Consume();
 }
Ejemplo n.º 12
0
 public override string ToString()
 {
     return("Token '" + text + "' - " + types.ToString());
 }
Ejemplo n.º 13
0
 public void Match(TokenTypes expected)
 {
     if (!buffer.ElementAt(consumeOffset).IsType(expected))
     {
         throw new ParsingException(string.Format(MathNet.Symbolics.Properties.Resources.ex_Parsing_Failed_TokenMismatch, expected.ToString(), buffer.ElementAt(consumeOffset).Text, CurrentTokenNeighbourhood()));
     }
     Consume();
 }
Ejemplo n.º 14
0
        private static string GetHeaderValue(string tokenValue, TokenTypes tokenType)
        {
            var tokenTypeName = tokenType.ToString();

            return($"{tokenTypeName} {tokenValue}");
        }
Ejemplo n.º 15
0
 public string toString()
 {
     return(text + "[" + type.ToString() + "]");
 }