protected IrisType ParseType(ref SubRange subRange, bool expectSubRange)
        {
            IrisType type;

            if (Accept(Token.KwArray))
            {
                subRange = null;
                FilePosition dimensionPosition = _lexer.TokenStartPosition;
                if (Accept(Token.ChrOpenBracket))
                {
                    Expect(Token.Number);
                    int from = _lastIntegerLexeme;
                    Expect(Token.ChrDotDot);
                    Expect(Token.Number);
                    int to = _lastIntegerLexeme;
                    Expect(Token.ChrCloseBracket);

                    subRange = new SubRange(from, to);
                }

                if (expectSubRange)
                {
                    // Expecting array subrange (local/global var declarations)
                    if (subRange == null)
                    {
                        AddError(dimensionPosition, "Expecting array subrange.");
                    }
                    else if (subRange.From != 0)
                    {
                        AddError(dimensionPosition, "Iris only support arrays that start at index zero.");
                    }
                }
                else if (subRange != null)
                {
                    // Not expecting array dimension (parameter list)
                    AddError(dimensionPosition, "Not expecting array subrange here.");
                }

                Expect(Token.KwOf);
                type = ParsePrimitiveType();
                if (type == IrisType.Invalid)
                {
                    AddErrorAtTokenStart("Expecting  'integer', 'string', or 'boolean'");
                }
                else
                {
                    type = type.MakeArrayType();
                }

                return(type);
            }

            type = ParsePrimitiveType();
            if (type == IrisType.Invalid)
            {
                AddErrorAtTokenStart("Expecting  'integer', 'string', 'boolean', or 'array'");
            }

            return(type);
        }
示例#2
0
 public void InitArray(Symbol arraySymbol, SubRange subRange)
 {
     if (_outputEnabled)
     {
         EmitDeferredInstructions();
         _emitter.InitArray(arraySymbol, subRange);
     }
 }
示例#3
0
 static bool Contains(string input, SubRange inputSub, char ch)
 {
     for (int i = 0; i < inputSub.length; i++)
     {
         if (input[inputSub.offset + i] == ch)
         {
             return(true);
         }
     }
     return(false);
 }
示例#4
0
        private string TryFormatValue(DkmClrValue value, DkmInspectionContext inspectionContext)
        {
            if (value.ValueFlags.HasFlag(DkmClrValueFlags.Error))
            {
                // Error message.  Just show the error.
                return(value.HostObjectValue as string);
            }
            else if (value.IsNull)
            {
                return("<uninitialized>");
            }

            Type     lmrType  = value.Type.GetLmrType();
            IrisType irisType = Utility.GetIrisTypeForLmrType(lmrType);

            if (irisType == IrisType.Invalid)
            {
                // We don't know how to format this value
                return(null);
            }

            uint radix = inspectionContext.Radix;

            if (irisType.IsArray)
            {
                SubRange subrange = new SubRange(value.ArrayLowerBounds.First(), value.ArrayDimensions.First() - 1);
                return(string.Format(
                           "array[{0}..{1}] of {2}",
                           FormatInteger(subrange.From, radix),
                           FormatInteger(subrange.To, radix),
                           irisType.GetElementType()));
            }

            object hostObjectValue = value.HostObjectValue;

            if (hostObjectValue != null)
            {
                // If the value can be marshalled into the debugger process, HostObjectValue is the
                // equivalent value in the debugger process.
                switch (System.Type.GetTypeCode(hostObjectValue.GetType()))
                {
                case TypeCode.Int32:
                    return(FormatInteger((int)hostObjectValue, radix));

                case TypeCode.Boolean:
                    return((bool)hostObjectValue ? "true" : "false");

                case TypeCode.String:
                    return(FormatString(hostObjectValue.ToString(), inspectionContext.EvaluationFlags));
                }
            }

            return(null);
        }
        protected void ParseVariableList(List <Tuple <Variable, FilePosition> > variables, bool isArgumentList)
        {
            bool first = true;

            do
            {
                bool isByRef = isArgumentList && Accept(Token.KwVar);

                FilePosition nameStart = _lexer.TokenStartPosition;
                if (!Accept(Token.Identifier))
                {
                    if (!isArgumentList && !first)
                    {
                        return; // Allow semicolon on the final var declaration
                    }
                    AddErrorAtTokenStart("Expecting variable name.");
                    SkipStatement();
                    return;
                }

                first = false;

                // Parse name list
                List <Tuple <string, FilePosition> > names = new List <Tuple <string, FilePosition> >();
                names.Add(new Tuple <string, FilePosition>(_lexeme, nameStart));
                while (Accept(Token.ChrComma))
                {
                    nameStart = _lexer.TokenStartPosition;
                    if (!Accept(Token.Identifier))
                    {
                        AddErrorAtTokenStart("Expecting variable name after ','.");
                    }
                    else
                    {
                        names.Add(new Tuple <string, FilePosition>(_lexeme, nameStart));
                    }
                }

                Expect(Token.ChrColon);

                // Now parse the type and create the variable(s)
                SubRange subRange = null;
                IrisType type     = ParseType(ref subRange, expectSubRange: !isArgumentList);
                if (isByRef)
                {
                    type = type.MakeByRefType();
                }

                foreach (Tuple <string, FilePosition> name in names)
                {
                    variables.Add(new Tuple <Variable, FilePosition>(new Variable(type, name.Item1, subRange), name.Item2));
                }
            }while (Accept(Token.ChrSemicolon));
        }
示例#6
0
        static bool MatchDomain(string input, string pattern, SubRange sub)
        {
            var i = IndexOf(input, pattern, sub.offset, sub.length);

            if (i >= 0)
            {
                if ((i == 0 || input[i - 1] == '.') && i + sub.length == input.Length)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#7
0
        public void InitArray(Symbol arraySymbol, SubRange subRange)
        {
            int lowerBound = 0;
            int dimension  = 0;

            if (subRange != null)
            {
                lowerBound = subRange.From;
                dimension  = subRange.To - subRange.From + 1;
                if (dimension < 0)
                {
                    dimension = 0;
                }
            }

            InitArrayHelper(arraySymbol, lowerBound, dimension);
        }
示例#8
0
 static bool MatchWildcard(string input, string pattern, SubRange sub)
 {
     return(Wildcard.IsMatch(input, pattern, sub.offset, sub.length));
 }
        public void InitArray(Symbol arraySymbol, SubRange subRange)
        {
            int lowerBound = 0;
            int dimension = 0;

            if (subRange != null)
            {
                lowerBound = subRange.From;
                dimension = subRange.To - subRange.From + 1;
                if (dimension < 0)
                    dimension = 0;
            }

            InitArrayHelper(arraySymbol, lowerBound, dimension);
        }
 public void InitArray(Symbol arraySymbol, SubRange subRange)
 {
     _textEmitter.InitArray(arraySymbol, subRange);
 }
 public void InitArray(Symbol arraySymbol, SubRange subRange)
 {
     if (_outputEnabled)
     {
         EmitDeferredInstructions();
         _emitter.InitArray(arraySymbol, subRange);
     }
 }
 public void InitArray(Symbol arraySymbol, SubRange subRange)
 {
     _textEmitter.InitArray(arraySymbol, subRange);
 }
 public Variable(IrisType type, string name, SubRange subRange)
 {
     Type = type;
     Name = name;
     SubRange = subRange;
 }
        protected IrisType ParseType(ref SubRange subRange, bool expectSubRange)
        {
            IrisType type;
            if (Accept(Token.KwArray))
            {
                subRange = null;
                FilePosition dimensionPosition = _lexer.TokenStartPosition;
                if (Accept(Token.ChrOpenBracket))
                {
                    Expect(Token.Number);
                    int from = _lastIntegerLexeme;
                    Expect(Token.ChrDotDot);
                    Expect(Token.Number);
                    int to = _lastIntegerLexeme;
                    Expect(Token.ChrCloseBracket);

                    subRange = new SubRange(from, to);
                }

                if (expectSubRange)
                {
                    // Expecting array subrange (local/global var declarations)
                    if (subRange == null)
                        AddError(dimensionPosition, "Expecting array subrange.");
                    else if (subRange.From != 0)
                        AddError(dimensionPosition, "Iris only support arrays that start at index zero.");
                }
                else if (subRange != null)
                {
                    // Not expecting array dimension (parameter list)
                    AddError(dimensionPosition, "Not expecting array subrange here.");
                }

                Expect(Token.KwOf);
                type = ParsePrimitiveType();
                if (type == IrisType.Invalid)
                    AddErrorAtTokenStart("Expecting  'integer', 'string', or 'boolean'");
                else
                    type = type.MakeArrayType();

                return type;
            }

            type = ParsePrimitiveType();
            if (type == IrisType.Invalid)
                AddErrorAtTokenStart("Expecting  'integer', 'string', 'boolean', or 'array'");

            return type;
        }
        protected IrisType ParseType()
        {
            SubRange sr = null;

            return(ParseType(ref sr, expectSubRange: false));
        }
示例#16
0
 public Variable(IrisType type, string name, SubRange subRange)
 {
     Type     = type;
     Name     = name;
     SubRange = subRange;
 }