コード例 #1
0
ファイル: VsExpression.cs プロジェクト: googlestadia/vsi-lldb
        /// <summary>
        /// Create a VsExpresion from a string representation of an expression
        /// </summary>
        public async Task <VsExpression> CreateAsync(string expression,
                                                     Func <string, Task <uint> > evaluate)
        {
            expression = Preprocess(expression);

            if (!TrySplitSizeSpecifierPrefix(expression, out string expressionWithSize,
                                             out string validSuffix))
            {
                // If we have not found a right bracket that can be part of an expresssion
                // size specifier, just try to split around the last comma.
                return(ParseWithSimpleFormatter(expression));
            }

            // We have a candidate for the expression-with-size and a valid suffix.
            // For example, for "var,[len]!x", the expression-with-size would be "var,[len]"
            // and the suffix is "!x".

            // Now try to split the expression and the size. We use our clever splitter that
            // can handle the situation when the size specifier contains brackets or commas.
            VsExpression parsedExpressionAndSize = ParseWithExpressionFormatter(expressionWithSize);

            if (string.IsNullOrEmpty(parsedExpressionAndSize.FormatSpecifier.Expression))
            {
                return(new VsExpression(expression, FormatSpecifier.EMPTY));
            }

            var sizeExpression = parsedExpressionAndSize.FormatSpecifier.Expression;

            // Remove the starting '[' and ending ']'.
            sizeExpression = sizeExpression.Substring(1, sizeExpression.Length - 2);

            var formatSpecifier = new FormatSpecifier(
                parsedExpressionAndSize.FormatSpecifier.Expression + validSuffix);

            try
            {
                uint size = await evaluate(sizeExpression);

                formatSpecifier = new FormatSpecifier(
                    parsedExpressionAndSize.FormatSpecifier.Expression + validSuffix, size);
            }
            catch (ExpressionEvaluationFailed e)
            {
                Trace.WriteLine(
                    $"ERROR: Failed to resolve size format expression: {sizeExpression}." +
                    $" Reason: {e.Message}.");
            }

            return(new VsExpression(parsedExpressionAndSize.Value, formatSpecifier));
        }
コード例 #2
0
 /// <summary>
 /// Create an IVariableInformation instance from an expression. The expression may or
 /// may not contain a format specifier.
 /// </summary>
 /// <param name="remoteValue">The remote value associated with the expression.</param>
 /// <param name="displayName">
 /// The display name of the expression. Uses the value's name if not specified.
 /// </param>
 /// <param name="formatSpecifier">Value format specifier.</param>
 /// <returns></returns>
 public IVariableInformation Create(RemoteValue remoteValue, string displayName = null,
                                    FormatSpecifier formatSpecifier             = null)
 {
     return(varInfoFactory.Create(remoteValue, displayName, formatSpecifier));
 }
コード例 #3
0
ファイル: VsExpression.cs プロジェクト: googlestadia/vsi-lldb
 public VsExpression(string value, FormatSpecifier formatSpecifier)
 {
     Value           = value;
     FormatSpecifier = formatSpecifier;
 }