示例#1
0
 public C64BasicRewriter(C64Basic arch, Address address, SortedList <ushort, C64BasicInstruction> prog, IRewriterHost host)
 {
     this.arch    = arch;
     this.address = address;
     this.prog    = prog;
     this.host    = host;
     this.strType = StringType.LengthPrefixedStringType(PrimitiveType.Char, PrimitiveType.Byte);
 }
示例#2
0
		/// <summary>
		/// Read a character string that is preceded by a character count. 
		/// </summary>
		/// <param name="lengthType"></param>
		/// <param name="charType"></param>
		/// <param name="encoding"></param>
		/// <returns></returns>
		public StringConstant ReadLengthPrefixedString(PrimitiveType lengthType, PrimitiveType charType, Encoding encoding)
		{
			int length = Read(lengthType).ToInt32();
			int iStart = (int)Offset;
			return new StringConstant(
				StringType.LengthPrefixedStringType(charType, lengthType),
				encoding.GetString(
					bytes,
					iStart,
					length * charType.Size));
		}
示例#3
0
        private bool GetIdentifier(out Identifier id)
        {
            var sb = new StringBuilder();

            id = null;
            if (i >= line.Length)
            {
                return(false);
            }
            char ch = (char)line[i];

            if ('A' > ch || ch > 'Z')
            {
                return(false);
            }
            sb.Append(ch);
            ++i;
            while (i < line.Length)
            {
                ch = (char)line[i];
                if (('A' > ch || ch > 'Z') &&
                    ('0' > ch || ch > '9'))
                {
                    break;
                }
                sb.Append(ch);
                ++i;
            }

            // Get the sigil if any.
            DataType dt     = PrimitiveType.Real32;
            string   suffix = "r";

            if (i < line.Length)
            {
                if (ch == '$')
                {
                    ++i;
                    suffix = "s";
                    dt     = StringType.LengthPrefixedStringType(PrimitiveType.Char, PrimitiveType.Byte);
                }
                else if (ch == '%')
                {
                    ++i;
                    suffix = "i";
                    dt     = PrimitiveType.Int16;
                }
            }
            sb.AppendFormat("_{0}", suffix);
            id = new Identifier(sb.ToString(), dt, new MemoryStorage());
            return(true);
        }
示例#4
0
 public C64BasicRewriter(
     C64Basic arch,
     Address address,
     SortedList <ushort, C64BasicInstruction> lines,
     IDictionary <Address, C64BasicInstruction> instrs,
     IRewriterHost host)
 {
     this.address = address;
     this.Lines   = lines;
     this.instrs  = instrs;
     this.host    = host;
     this.strType = StringType.LengthPrefixedStringType(PrimitiveType.Char, PrimitiveType.Byte);
 }
        public DataType VisitString(StringType_v2 str)
        {
            var dt = str.CharType.Accept(this);

            if (str.Termination == StringType_v2.ZeroTermination)
            {
                return(StringType.NullTerminated(dt));
            }
            if (str.Termination == StringType_v2.MsbTermination)
            {
                return(StringType.LengthPrefixedStringType((PrimitiveType)dt, PrimitiveType.Byte));
            }
            throw new NotImplementedException();
        }
示例#6
0
        public StringFinderCriteria GetCriteria()
        {
            Encoding      encoding;
            PrimitiveType charType;
            Func <MemoryArea, Address, Address, EndianImageReader> rdrCreator;

            switch (dlg.CharacterSizeList.SelectedIndex)
            {
            default:
                encoding   = Encoding.ASCII;
                charType   = PrimitiveType.Char;
                rdrCreator = (m, a, b) => new LeImageReader(m, a, b);
                break;

            case 1:
                encoding   = Encoding.GetEncoding("utf-16LE");
                charType   = PrimitiveType.WChar;
                rdrCreator = (m, a, b) => new LeImageReader(m, a, b);
                break;

            case 2:
                encoding   = Encoding.GetEncoding("utf-16BE");
                charType   = PrimitiveType.WChar;
                rdrCreator = (m, a, b) => new BeImageReader(m, a, b);
                break;
            }

            StringType strType;

            switch (dlg.StringKindList.SelectedIndex)
            {
            default: strType = StringType.NullTerminated(charType); break;

            case 1: strType = StringType.LengthPrefixedStringType(charType, PrimitiveType.Byte); break;

            case 2:
            case 3: strType = StringType.LengthPrefixedStringType(charType, PrimitiveType.UInt16); break;
            }

            return(new StringFinderCriteria
            {
                StringType = strType,
                Encoding = encoding,
                MinimumLength = dlg.MinLength,
                CreateReader = rdrCreator,
            });
        }
示例#7
0
        public StringType GetStringType()
        {
            var charType = ddlCharSize.SelectedIndex > 0
                ? PrimitiveType.WChar
                : PrimitiveType.Char;

            switch (ddlStringKind.SelectedIndex)
            {
            default: return(StringType.NullTerminated(charType));

            case 1: return(StringType.LengthPrefixedStringType(charType, PrimitiveType.Byte));

            case 2: return(StringType.LengthPrefixedStringType(charType, PrimitiveType.UInt16));

            case 3: return(StringType.LengthPrefixedStringType(charType, PrimitiveType.UInt32));
            }
        }