Beispiel #1
0
        public override bool Equals(object obj)
        {
            AsciiString other = obj as AsciiString;

            if (other != null)
            {
                return(_str == other._str);
            }
            return(false);
        }
Beispiel #2
0
        public static PyBytesObject Create(DkmProcess process, AsciiString value) {
            var allocator = process.GetDataItem<PyObjectAllocator>();
            Debug.Assert(allocator != null);

            var result = allocator.Allocate<PyBytesObject>(value.Bytes.Length);
            result.ob_size.Write(value.Bytes.Length);
            process.WriteMemory(result.ob_sval.Address, value.Bytes);

            return result;
        }
Beispiel #3
0
        private object FinishBytesPlus(AsciiString s, List<string> verbatimImages, List<string> verbatimWhiteSpace) {
            Token t = PeekToken();
            while (true) {
                if (t is ConstantValueToken) {
                    AsciiString cvs;
                    string str;
                    if ((cvs = t.Value as AsciiString) != null) {
                        List<byte> res = new List<byte>(s.Bytes);
                        res.AddRange(cvs.Bytes);
                        s = new AsciiString(res.ToArray(), s.String + cvs.String);
                        NextToken();
                        if (_verbatim) {
                            verbatimWhiteSpace.Add(_tokenWhiteSpace);
                            verbatimImages.Add(t.VerbatimImage);
                        }
                        t = PeekToken();
                        continue;
                    } else if ((str = t.Value as string) != null) {
                        if (_langVersion.Is3x()) {
                            ReportSyntaxError("cannot mix bytes and nonbytes literals");
                        }

                        string final = s.String + str;
                        NextToken();
                        if (_verbatim) {
                            verbatimWhiteSpace.Add(_tokenWhiteSpace);
                            verbatimImages.Add(t.VerbatimImage);
                        }

                        return FinishStringPlus(final, verbatimImages, verbatimWhiteSpace);
                    } else {
                        ReportSyntaxError("invalid syntax");
                    }
                }
                break;
            }
            return s;
        }
Beispiel #4
0
        private object FinishBytesPlus(AsciiString s, Token initialToken, out string[] verbatimImages, out string[] verbatimWhiteSpace) {
            List<string> verbatimImagesList = null;
            List<string> verbatimWhiteSpaceList = null;
            if (_verbatim) {
                verbatimWhiteSpaceList = new List<string>();
                verbatimImagesList = new List<string>();
                verbatimWhiteSpaceList.Add(_tokenWhiteSpace);
                verbatimImagesList.Add(initialToken.VerbatimImage);
            }

            var res = FinishBytesPlus(s, verbatimImagesList, verbatimWhiteSpaceList);
            
            if (_verbatim) {
                verbatimWhiteSpace = verbatimWhiteSpaceList.ToArray();
                verbatimImages = verbatimImagesList.ToArray();
            } else {
                verbatimWhiteSpace = verbatimImages = null;
            }
            return res;
        }