Switched everything to ManagedByteCodeReader

This commit is contained in:
Yoshi Askharoun
2021-10-04 14:16:29 -05:00
parent 66b38fb952
commit d0f576c266
37 changed files with 223 additions and 377 deletions
@@ -292,7 +292,7 @@ namespace Microsoft.Iris.Markup
}
}
public override object DecodeBinary(ByteCodeReader reader)
public override object DecodeBinary(ManagedByteCodeReader reader)
{
object obj;
if (_type.IsEnum)
@@ -1,314 +0,0 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Markup.ByteCodeReader
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Library;
using Microsoft.Iris.OS;
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace Microsoft.Iris.Markup
{
internal class ManagedByteCodeReader : DisposableObject
{
private static char[] s_scratchCharArray = new char[100];
private BinaryReader _reader;
private IntPtr _buffer;
private byte[] _bytes;
private bool _inFixedMemory;
public unsafe ManagedByteCodeReader(IntPtr buffer, long size, bool ownsAllocation)
{
byte[] bytes = new byte[size];
Marshal.Copy(buffer, bytes, 0, (int)size);
_bytes = bytes;
_reader = new BinaryReader(new MemoryStream(_bytes));
_buffer = buffer;
}
public byte[] Bytes => _bytes;
public uint Size => (uint)_reader.BaseStream.Length;
public uint CurrentOffset
{
get => (uint)_reader.BaseStream.Position;
set => _reader.BaseStream.Seek(value <= Size ? value : throw new Exception("Invalid offset"), SeekOrigin.Begin);
}
public unsafe IntPtr CurrentAddress => new IntPtr(_buffer.ToInt64() + _reader.BaseStream.Position);
public bool IsInFixedMemory => _inFixedMemory;
public void MarkAsInFixedMemory() => _inFixedMemory = true;
public bool ReadBool() => _reader.ReadBoolean();
public unsafe byte ReadByte() => _reader.ReadByte();
public char ReadChar() => _reader.ReadChar();
public unsafe ushort ReadUInt16() => _reader.ReadUInt16();
public int ReadInt32() => _reader.ReadInt32();
public unsafe uint ReadUInt32() => _reader.ReadUInt32();
public static unsafe ushort ReadUInt16(IntPtr pData)
{
var reader = new ByteCodeReader(pData, sizeof(ushort), false);
return reader.ReadUInt16();
}
public static unsafe uint ReadUInt32(IntPtr pData)
{
var reader = new ByteCodeReader(pData, sizeof(uint), false);
return reader.ReadUInt32();
}
public long ReadInt64() => _reader.ReadInt64();
public unsafe ulong ReadUInt64() => _reader.ReadUInt64();
public unsafe float ReadSingle() => _reader.ReadSingle();
public unsafe double ReadDouble() => _reader.ReadDouble();
public unsafe string ReadString()
{
uint num1 = ReadUInt16();
if (num1 == ushort.MaxValue)
return null;
bool flag;
uint num2;
if (((int)num1 & 32768) != 0)
{
flag = true;
num1 &= (uint)short.MaxValue;
num2 = num1;
}
else
{
flag = false;
num2 = num1 * 2U;
}
if (CurrentOffset + num2 > Size)
ThrowReadError();
char[] chArray = num1 >= s_scratchCharArray.Length ? new char[num1] : s_scratchCharArray;
byte* numPtr1 = (byte*)(_buffer.ToInt64() + CurrentOffset);
if (flag)
{
for (int index = 0; index < num1; ++index)
chArray[index] = (char)*numPtr1++;
}
else
{
for (int index = 0; index < num1; ++index)
{
byte* numPtr2 = numPtr1;
byte* numPtr3 = numPtr2 + 1;
byte num3 = *numPtr2;
byte* numPtr4 = numPtr3;
numPtr1 = numPtr4 + 1;
byte num4 = *numPtr4;
chArray[index] = (char)(num3 | (uint)num4 << 8);
}
}
_reader.BaseStream.Seek(num2, SeekOrigin.Current);
return new string(chArray, 0, (int)num1);
}
public unsafe IntPtr ToIntPtr(out long size)
{
size = Size;
return _buffer;
}
public unsafe IntPtr GetAddress(uint offset) => new IntPtr(_buffer.ToInt64() + offset);
private void ThrowReadError() => throw new Exception("Attempted to read past the end of the buffer.");
protected override unsafe void OnDispose()
{
base.OnDispose();
_reader.Close();
_buffer = IntPtr.Zero;
}
}
internal class ByteCodeReader : DisposableObject
{
private static char[] s_scratchCharArray = new char[100];
private unsafe byte* _buffer;
private uint _offset;
private uint _size;
private bool _ownsAllocation;
private bool _inFixedMemory;
public unsafe ByteCodeReader(IntPtr buffer, uint size, bool ownsAllocation)
{
_buffer = (byte*)buffer.ToPointer();
_size = size;
_offset = 0U;
_ownsAllocation = ownsAllocation;
int num = _ownsAllocation ? 1 : 0;
}
public uint Size => _size;
public uint CurrentOffset
{
get => _offset;
set => _offset = value <= _size ? value : throw new Exception("Invalid offset");
}
public unsafe IntPtr CurrentAddress => new IntPtr(_buffer + (int)_offset);
public void MarkAsInFixedMemory() => _inFixedMemory = true;
public bool IsInFixedMemory => _inFixedMemory;
public bool ReadBool() => ReadByte() != 0;
public unsafe byte ReadByte()
{
if (_offset >= _size)
ThrowReadError();
byte num = _buffer[(int)_offset];
++_offset;
return num;
}
public char ReadChar() => (char)ReadUInt16();
public unsafe ushort ReadUInt16()
{
if (_offset + 2U > _size)
ThrowReadError();
byte* numPtr = _buffer + (int)_offset;
byte num1 = *numPtr;
byte num2 = numPtr[1];
_offset += 2U;
return (ushort)(num1 | (uint)num2 << 8);
}
public int ReadInt32() => (int)ReadUInt32();
public unsafe uint ReadUInt32()
{
if (_offset + 4U > _size)
ThrowReadError();
byte* numPtr = _buffer + (int)_offset;
byte num1 = *numPtr;
byte num2 = numPtr[1];
byte num3 = numPtr[2];
byte num4 = numPtr[3];
_offset += 4U;
return (uint)(num1 | num2 << 8 | num3 << 16 | num4 << 24);
}
public static unsafe ushort ReadUInt16(IntPtr pData)
{
byte* pointer = (byte*)pData.ToPointer();
return (ushort)(*pointer | (uint)pointer[1] << 8);
}
public static unsafe uint ReadUInt32(IntPtr pData)
{
byte* pointer = (byte*)pData.ToPointer();
return (uint)(*pointer | pointer[1] << 8 | pointer[2] << 16 | pointer[3] << 24);
}
public long ReadInt64() => (long)ReadUInt64();
public unsafe ulong ReadUInt64()
{
if (_offset + 8U > _size)
ThrowReadError();
byte* numPtr = _buffer + (int)_offset;
byte num1 = *numPtr;
byte num2 = numPtr[1];
byte num3 = numPtr[2];
byte num4 = numPtr[3];
byte num5 = numPtr[4];
byte num6 = numPtr[5];
byte num7 = numPtr[6];
byte num8 = numPtr[7];
_offset += 8U;
uint num9 = (uint)(num1 | num2 << 8 | num3 << 16 | num4 << 24);
return (ulong)(uint)(num5 | num6 << 8 | num7 << 16 | num8 << 24) << 32 | num9;
}
//public unsafe float ReadSingle() => *(float*)&ReadUInt32();
public unsafe float ReadSingle() => BitConverter.ToSingle(BitConverter.GetBytes(ReadUInt32()), 0);
//public unsafe double ReadDouble() => *(double*)&ReadInt64();
public unsafe double ReadDouble() => BitConverter.ToSingle(BitConverter.GetBytes(ReadUInt64()), 0);
public unsafe string ReadString()
{
uint num1 = ReadUInt16();
if (num1 == ushort.MaxValue)
return null;
bool flag;
uint num2;
if (((int)num1 & 32768) != 0)
{
flag = true;
num1 &= (uint)short.MaxValue;
num2 = num1;
}
else
{
flag = false;
num2 = num1 * 2U;
}
if (_offset + num2 > _size)
ThrowReadError();
char[] chArray = num1 >= s_scratchCharArray.Length ? new char[num1] : ByteCodeReader.s_scratchCharArray;
byte* numPtr1 = _buffer + (int)_offset;
if (flag)
{
for (int index = 0; index < num1; ++index)
chArray[index] = (char)*numPtr1++;
}
else
{
for (int index = 0; index < num1; ++index)
{
byte* numPtr2 = numPtr1;
byte* numPtr3 = numPtr2 + 1;
byte num3 = *numPtr2;
byte* numPtr4 = numPtr3;
numPtr1 = numPtr4 + 1;
byte num4 = *numPtr4;
chArray[index] = (char)(num3 | (uint)num4 << 8);
}
}
_offset += num2;
return new string(chArray, 0, (int)num1);
}
public unsafe IntPtr ToIntPtr(out uint size)
{
size = _size;
return new IntPtr(_buffer);
}
public unsafe IntPtr GetAddress(uint offset) => new IntPtr(_buffer + (int)offset);
private void ThrowReadError() => throw new Exception("Attempted to read past the end of the buffer.");
protected override unsafe void OnDispose()
{
base.OnDispose();
if (_ownsAllocation)
NativeApi.MemFree(new IntPtr(_buffer));
_buffer = null;
}
}
}
@@ -149,11 +149,11 @@ namespace Microsoft.Iris.Markup
}
}
public void Write(ByteCodeReader value) => Write(value, 0U);
public void Write(ManagedByteCodeReader value) => Write(value, 0U);
public unsafe void Write(ByteCodeReader value, uint offset)
public unsafe void Write(ManagedByteCodeReader value, uint offset)
{
IntPtr intPtr = value.ToIntPtr(out uint size);
IntPtr intPtr = value.ToIntPtr(out long size);
if (offset > size)
throw new ArgumentOutOfRangeException(nameof(offset));
Write(new IntPtr(intPtr.ToInt64() + offset), (uint)(size - offset));
@@ -219,10 +219,10 @@ namespace Microsoft.Iris.Markup
return pointer;
}
public unsafe ByteCodeReader CreateReader()
public unsafe ManagedByteCodeReader CreateReader()
{
uint totalSize;
return new ByteCodeReader(new IntPtr(ComposeFinalBuffer(out totalSize)), totalSize, true);
return new ManagedByteCodeReader(new IntPtr(ComposeFinalBuffer(out totalSize)), totalSize, true);
}
}
}
@@ -16,7 +16,7 @@ namespace Microsoft.Iris.Markup
{
private const uint c_LineNumberRecordSize = 12;
private CompiledMarkupLoadResult _loadResultTarget;
private ByteCodeReader _reader;
private ManagedByteCodeReader _reader;
private bool _hasErrors;
private LoadPass _currentDepersistPass;
private MarkupLoadResult _binaryDataTableLoadResult;
@@ -36,7 +36,7 @@ namespace Microsoft.Iris.Markup
private CompiledMarkupLoader(CompiledMarkupLoadResult loadResultTarget, Resource resource)
{
_loadResultTarget = loadResultTarget;
_reader = new ByteCodeReader(resource.Buffer, resource.Length, false);
_reader = new ManagedByteCodeReader(resource.Buffer, false);
if (resource is DllResource)
_reader.MarkAsInFixedMemory();
uint num1 = _reader.ReadUInt32();
@@ -499,12 +499,12 @@ namespace Microsoft.Iris.Markup
_loadResultTarget.SetDataMappingsTable(dataMappingsTable);
}
public static void DecodeInheritableSymbolTable(MarkupTypeSchema typeExport, ByteCodeReader reader, IntPtr startAddress)
public static void DecodeInheritableSymbolTable(MarkupTypeSchema typeExport, ManagedByteCodeReader reader, IntPtr startAddress)
{
if (reader == null)
{
uint size = ByteCodeReader.ReadUInt32(startAddress);
reader = new ByteCodeReader(new IntPtr(startAddress.ToInt64() + 4L), size, false);
uint size = ManagedByteCodeReader.ReadUInt32(startAddress);
reader = new ManagedByteCodeReader(new IntPtr(startAddress.ToInt64() + 4L), size, false);
}
else
{
@@ -562,13 +562,13 @@ namespace Microsoft.Iris.Markup
}
else
{
ByteCodeReader constantsTableReader = new ByteCodeReader(_reader.CurrentAddress, ByteCodeReader.ReadUInt32(_reader.GetAddress(_reader.CurrentOffset + num * 4U)), false);
ManagedByteCodeReader constantsTableReader = new ManagedByteCodeReader(_reader.CurrentAddress, ManagedByteCodeReader.ReadUInt32(_reader.GetAddress(_reader.CurrentOffset + num * 4U)), false);
constantsTable.SetConstantsTableReader(constantsTableReader, _loadResultTarget);
}
_loadResultTarget.BinaryDataTable.SetConstantsTable(constantsTable);
}
public static object DepersistConstant(ByteCodeReader reader, MarkupLoadResult loadResult)
public static object DepersistConstant(ManagedByteCodeReader reader, MarkupLoadResult loadResult)
{
ushort num = reader.ReadUInt16();
TypeSchema typeImport = loadResult.ImportTables.TypeImports[num];
@@ -591,7 +591,7 @@ namespace Microsoft.Iris.Markup
return instance;
}
private static MarkupLineNumberTable DecodeLineNumberTable(ByteCodeReader reader)
private static MarkupLineNumberTable DecodeLineNumberTable(ManagedByteCodeReader reader)
{
ushort num = reader.ReadUInt16();
ulong[] runtimeList = new ulong[num];
@@ -602,8 +602,8 @@ namespace Microsoft.Iris.Markup
public static MarkupLineNumberTable DecodeLineNumberTable(IntPtr address)
{
uint size = (uint)(ByteCodeReader.ReadUInt16(address) * 12 + 2);
return DecodeLineNumberTable(new ByteCodeReader(address, size, false));
uint size = (uint)(ManagedByteCodeReader.ReadUInt16(address) * 12 + 2);
return DecodeLineNumberTable(new ManagedByteCodeReader(address, size, false));
}
private void DepersistLineNumberTable()
@@ -624,10 +624,10 @@ namespace Microsoft.Iris.Markup
private void DepersistObjectSection()
{
uint num = _objectSectionEnd - _objectSectionStart;
ByteCodeReader reader;
ManagedByteCodeReader reader;
if (_reader.IsInFixedMemory)
{
reader = new ByteCodeReader(_reader.GetAddress(_objectSectionStart), num, false);
reader = new ManagedByteCodeReader(_reader.GetAddress(_objectSectionStart), num, false);
}
else
{
@@ -655,7 +655,7 @@ namespace Microsoft.Iris.Markup
}
}
else
_binaryDataTable.SetStringTableReader(new ByteCodeReader(_reader.CurrentAddress, ByteCodeReader.ReadUInt32(_reader.GetAddress(_reader.CurrentOffset + (uint)(stringCount * 4))), false));
_binaryDataTable.SetStringTableReader(new ManagedByteCodeReader(_reader.CurrentAddress, ManagedByteCodeReader.ReadUInt32(_reader.GetAddress(_reader.CurrentOffset + (uint)(stringCount * 4))), false));
_loadResultTarget.SetBinaryDataTable(_binaryDataTable);
_reader.CurrentOffset = currentOffset;
}
@@ -682,7 +682,7 @@ namespace Microsoft.Iris.Markup
private string ReadDataTableString() => _binaryDataTable.GetStringByIndex(_reader.ReadInt32());
private static string ReadDataTableString(ByteCodeReader reader, MarkupBinaryDataTable binaryDataTable)
private static string ReadDataTableString(ManagedByteCodeReader reader, MarkupBinaryDataTable binaryDataTable)
{
int index = reader.ReadInt32();
return binaryDataTable.GetStringByIndex(index);
@@ -799,7 +799,7 @@ namespace Microsoft.Iris.Markup
public static bool IsUIB(Resource resource)
{
bool flag = false;
if (resource.Length > 4U && ByteCodeReader.ReadUInt32(resource.Buffer) == 440551765U)
if (resource.Length > 4U && ManagedByteCodeReader.ReadUInt32(resource.Buffer) == 440551765U)
flag = true;
return flag;
}
@@ -6,5 +6,5 @@
namespace Microsoft.Iris.Markup
{
internal delegate object DecodeBinaryHandler(ByteCodeReader reader);
internal delegate object DecodeBinaryHandler(ManagedByteCodeReader reader);
}
+1 -1
View File
@@ -170,7 +170,7 @@ namespace Microsoft.Iris.Markup
public override void EncodeBinary(ByteCodeWriter writer, object instance) => writer.WriteInt32(ValueFromObject(instance));
public override object DecodeBinary(ByteCodeReader reader) => EnumValueToObject(reader.ReadInt32());
public override object DecodeBinary(ManagedByteCodeReader reader) => EnumValueToObject(reader.ReadInt32());
public override bool SupportsBinaryEncoding => true;
@@ -29,7 +29,7 @@ namespace Microsoft.Iris.Markup
public override void EncodeBinary(ByteCodeWriter writer, object instance) => _frameworkSchema.EncodeBinary(writer, instance);
public override object DecodeBinary(ByteCodeReader reader) => _frameworkSchema.DecodeBinary(reader);
public override object DecodeBinary(ManagedByteCodeReader reader) => _frameworkSchema.DecodeBinary(reader);
public override bool SupportsBinaryEncoding => _frameworkSchema.SupportsBinaryEncoding;
@@ -15,7 +15,7 @@ namespace Microsoft.Iris.Markup
public static object Run(InterpreterContext context)
{
object result = null;
ByteCodeReader byteCodeReader = null;
ManagedByteCodeReader byteCodeReader = null;
long num = -1L;
bool flag = true;
ErrorManager.EnterContext(context);
@@ -46,7 +46,7 @@ namespace Microsoft.Iris.Markup
}
// Token: 0x06000F22 RID: 3874 RVA: 0x00029EF8 File Offset: 0x00028EF8
private static object Run(InterpreterContext context, ByteCodeReader reader)
private static object Run(InterpreterContext context, ManagedByteCodeReader reader)
{
MarkupLoadResult loadResult = context.LoadResult;
IMarkupTypeBase instance = context.Instance;
@@ -841,7 +841,7 @@ namespace Microsoft.Iris.Markup
/// <summary>
/// Attempts to generate source UIX from a compiled result
/// </summary>
private static object RunDecompile(InterpreterContext context, ByteCodeReader reader)
private static object RunDecompile(InterpreterContext context, ManagedByteCodeReader reader)
{
Stack xmlStack = new Stack();
@@ -0,0 +1,160 @@
// Decompiled with JetBrains decompiler
// Type: Microsoft.Iris.Markup.ByteCodeReader
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
// Assembly location: C:\Program Files\Zune\UIX.dll
using Microsoft.Iris.Library;
using Microsoft.Iris.OS;
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Microsoft.Iris.Markup
{
internal class ManagedByteCodeReader : DisposableObject
{
private static char[] s_scratchCharArray = new char[100];
private BinaryReader _reader;
private IntPtr _buffer;
private byte[] _bytes;
private bool _inFixedMemory;
public unsafe ManagedByteCodeReader(IntPtr buffer, long size, bool ownsAllocation)
{
byte[] bytes = new byte[size];
Marshal.Copy(buffer, bytes, 0, (int)size);
_bytes = bytes;
_reader = new BinaryReader(new MemoryStream(_bytes));
_buffer = buffer;
}
public unsafe ManagedByteCodeReader(byte[] bytes, bool ownsAllocation)
{
_bytes = bytes;
_reader = new BinaryReader(new MemoryStream(_bytes));
_buffer = new IntPtr(Unsafe.AsPointer(ref new Span<byte>(bytes).GetPinnableReference()));
}
public byte[] Bytes => _bytes;
public uint Size => (uint)_reader.BaseStream.Length;
public uint CurrentOffset
{
get => (uint)_reader.BaseStream.Position;
set => _reader.BaseStream.Seek(value <= Size ? value : throw new Exception("Invalid offset"), SeekOrigin.Begin);
}
public unsafe IntPtr CurrentAddress => new IntPtr(_buffer.ToInt64() + _reader.BaseStream.Position);
public bool IsInFixedMemory => _inFixedMemory;
public void MarkAsInFixedMemory() => _inFixedMemory = true;
public bool ReadBool() => _reader.ReadBoolean();
public unsafe byte ReadByte() => _reader.ReadByte();
public char ReadChar() => _reader.ReadChar();
public unsafe ushort ReadUInt16() => _reader.ReadUInt16();
public int ReadInt32() => _reader.ReadInt32();
public unsafe uint ReadUInt32() => _reader.ReadUInt32();
public static unsafe ushort ReadUInt16(IntPtr pData)
{
var reader = new ManagedByteCodeReader(pData, sizeof(ushort), false);
return reader.ReadUInt16();
}
public static unsafe ushort ReadUInt16(byte[] pData)
{
var reader = new ManagedByteCodeReader(pData, false);
return reader.ReadUInt16();
}
public static unsafe uint ReadUInt32(IntPtr pData)
{
var reader = new ManagedByteCodeReader(pData, sizeof(uint), false);
return reader.ReadUInt32();
}
public static unsafe uint ReadUInt32(byte[] pData)
{
var reader = new ManagedByteCodeReader(pData, false);
return reader.ReadUInt32();
}
public long ReadInt64() => _reader.ReadInt64();
public unsafe ulong ReadUInt64() => _reader.ReadUInt64();
public unsafe float ReadSingle() => _reader.ReadSingle();
public unsafe double ReadDouble() => _reader.ReadDouble();
public unsafe string ReadString()
{
uint num1 = ReadUInt16();
if (num1 == ushort.MaxValue)
return null;
bool flag;
uint num2;
if (((int)num1 & 32768) != 0)
{
flag = true;
num1 &= (uint)short.MaxValue;
num2 = num1;
}
else
{
flag = false;
num2 = num1 * 2U;
}
if (CurrentOffset + num2 > Size)
ThrowReadError();
char[] chArray = num1 >= s_scratchCharArray.Length ? new char[num1] : s_scratchCharArray;
byte* numPtr1 = (byte*)(_buffer.ToInt64() + CurrentOffset);
if (flag)
{
for (int index = 0; index < num1; ++index)
chArray[index] = (char)*numPtr1++;
}
else
{
for (int index = 0; index < num1; ++index)
{
byte* numPtr2 = numPtr1;
byte* numPtr3 = numPtr2 + 1;
byte num3 = *numPtr2;
byte* numPtr4 = numPtr3;
numPtr1 = numPtr4 + 1;
byte num4 = *numPtr4;
chArray[index] = (char)(num3 | (uint)num4 << 8);
}
}
_reader.BaseStream.Seek(num2, SeekOrigin.Current);
return new string(chArray, 0, (int)num1);
}
public unsafe IntPtr ToIntPtr(out long size)
{
size = Size;
return _buffer;
}
public unsafe IntPtr GetAddress(uint offset) => new IntPtr(_buffer.ToInt64() + offset);
private void ThrowReadError() => throw new Exception("Attempted to read past the end of the buffer.");
protected override unsafe void OnDispose()
{
base.OnDispose();
_reader.Close();
_buffer = IntPtr.Zero;
}
}
}
@@ -14,7 +14,7 @@ namespace Microsoft.Iris.Markup
private MarkupImportTables _importTables;
private LoadResult[] _sharedDependenciesTable;
private SourceMarkupImportTables _sourceMarkupImportTables;
private ByteCodeReader _stringTableReader;
private ManagedByteCodeReader _stringTableReader;
public MarkupBinaryDataTable(string uri, int stringCount)
{
@@ -28,7 +28,7 @@ namespace Microsoft.Iris.Markup
{
}
public void SetStringTableReader(ByteCodeReader stringTableReader) => _stringTableReader = stringTableReader;
public void SetStringTableReader(ManagedByteCodeReader stringTableReader) => _stringTableReader = stringTableReader;
public string Uri => _uri;
@@ -84,17 +84,17 @@ namespace Microsoft.Iris.Markup
{
ErrorWatermark watermark = ErrorManager.Watermark;
IntPtr invalidHandleValue = Win32Api.INVALID_HANDLE_VALUE;
ByteCodeReader reader = writer.CreateReader();
ManagedByteCodeReader reader = writer.CreateReader();
reader.DeclareOwner(typeof(MarkupSystem));
IntPtr file = Win32Api.CreateFile(outputFile, 1073741824U, 0U, IntPtr.Zero, 2U, 0U, IntPtr.Zero);
if (file == Win32Api.INVALID_HANDLE_VALUE)
ErrorManager.ReportError("Unable to open output file '{0}'. Error code {1}", outputFile, Marshal.GetLastWin32Error());
if (!watermark.ErrorsDetected)
{
uint size = 0;
long size = 0;
IntPtr intPtr = reader.ToIntPtr(out size);
uint lpNumberOfBytesWritten = 0;
if (!Win32Api.WriteFile(file, intPtr, size, out lpNumberOfBytesWritten, IntPtr.Zero))
if (!Win32Api.WriteFile(file, intPtr, (uint)size, out lpNumberOfBytesWritten, IntPtr.Zero))
ErrorManager.ReportError("An error occurred while saving data to output file '{0}'. Error code {1}", outputFile, Marshal.GetLastWin32Error());
}
if (file != Win32Api.INVALID_HANDLE_VALUE)
@@ -487,7 +487,7 @@ namespace Microsoft.Iris.Markup
{
_writer.Overwrite(_objectSectionStartFixup, _writer.DataSize);
_writer.Write(_loadResult.ObjectSection);
_loadResult.ObjectSection.ToIntPtr(out uint _);
_loadResult.ObjectSection.ToIntPtr(out long _);
_writer.Overwrite(_objectSectionEndFixup, _writer.DataSize);
}
@@ -14,7 +14,7 @@ namespace Microsoft.Iris.Markup
private object[] _runtimeList;
private MarkupConstantPersist[] _persistList;
private Dictionary<MarkupConstantsTable.MarkupConstant, int> _lookupTable;
private ByteCodeReader _constantsTableReader;
private ManagedByteCodeReader _constantsTableReader;
private MarkupLoadResult _loadResultOwner;
public MarkupConstantsTable() => _lookupTable = new Dictionary<MarkupConstantsTable.MarkupConstant, int>(new MarkupConstantsTable.MarkupConstantEqualityComparer());
@@ -22,7 +22,7 @@ namespace Microsoft.Iris.Markup
public MarkupConstantsTable(object[] runtimeList) => _runtimeList = runtimeList;
public void SetConstantsTableReader(
ByteCodeReader constantsTableReader,
ManagedByteCodeReader constantsTableReader,
MarkupLoadResult loadResultOwner)
{
_constantsTableReader = constantsTableReader;
@@ -28,7 +28,7 @@ namespace Microsoft.Iris.Markup
_lineNumberTable = lineNumberTable;
}
public ByteCodeReader EncodeOBJECTSection(
public ManagedByteCodeReader EncodeOBJECTSection(
ParseResult parseResult,
string uri,
string sourceFilePathBestGuess)
@@ -40,7 +40,7 @@ namespace Microsoft.Iris.Markup
for (int index = 0; index < parseResult.ClassList.Count; ++index)
EncodeClass(parseResult.ClassList[index]);
}
ByteCodeReader reader = _writer.CreateReader();
ManagedByteCodeReader reader = _writer.CreateReader();
_writer = null;
return reader;
}
@@ -13,7 +13,7 @@ namespace Microsoft.Iris.Markup
internal abstract class MarkupLoadResult : LoadResult
{
private LoadResult[] _dependenciesTable = EmptyList;
private ByteCodeReader _reader;
private ManagedByteCodeReader _reader;
protected MarkupBinaryDataTable _binaryDataTable;
protected MarkupLineNumberTable _lineNumberTable;
private TypeSchema[] _exportTable = TypeSchema.EmptyList;
@@ -117,7 +117,7 @@ namespace Microsoft.Iris.Markup
public abstract MarkupImportTables ImportTables { get; }
public ByteCodeReader ObjectSection => _reader;
public ManagedByteCodeReader ObjectSection => _reader;
public override TypeSchema[] ExportTable => _exportTable;
@@ -141,7 +141,7 @@ namespace Microsoft.Iris.Markup
public void SetDependenciesTable(LoadResult[] dependenciesTable) => SetDependenciesTable(dependenciesTable, true);
public void SetObjectSection(ByteCodeReader reader)
public void SetObjectSection(ManagedByteCodeReader reader)
{
reader.DeclareOwner(this);
_reader = reader;
@@ -297,7 +297,7 @@ namespace Microsoft.Iris.Markup
{
}
public override object DecodeBinary(ByteCodeReader reader) => (object)null;
public override object DecodeBinary(ManagedByteCodeReader reader) => (object)null;
public override object PerformOperation(object left, object right, OperationType op) => (object)null;
@@ -155,7 +155,7 @@ namespace Microsoft.Iris.Markup
MarkupConstantsTable constantsTable = _loadResultTarget.BinaryDataTable == null ? new MarkupConstantsTable() : _loadResultTarget.BinaryDataTable.ConstantsTable;
_loadResultTarget.SetDataMappingsTable(PrepareDataMappingTable());
_loadResultTarget.ValidationComplete();
ByteCodeReader reader = null;
ManagedByteCodeReader reader = null;
if (!HasErrors)
reader = new MarkupEncoder(importTables, constantsTable, lineNumberTable).EncodeOBJECTSection(_parseResult, _loadResultTarget.Uri, null);
if (!_usingSharedBinaryDataTable)
+1 -1
View File
@@ -88,7 +88,7 @@ namespace Microsoft.Iris.Markup
public abstract void EncodeBinary(ByteCodeWriter writer, object instance);
public abstract object DecodeBinary(ByteCodeReader reader);
public abstract object DecodeBinary(ManagedByteCodeReader reader);
public abstract bool SupportsBinaryEncoding { get; }
@@ -20,7 +20,7 @@ namespace Microsoft.Iris.Markup.UIX
writer.WriteBool(flag);
}
private static object DecodeBinary(ByteCodeReader reader) => BooleanBoxes.Box(reader.ReadBool());
private static object DecodeBinary(ManagedByteCodeReader reader) => BooleanBoxes.Box(reader.ReadBool());
private static Result ConvertFromString(object valueObj, out object instanceObj)
{
@@ -22,7 +22,7 @@ namespace Microsoft.Iris.Markup.UIX
writer.WriteByte(num);
}
private static object DecodeBinary(ByteCodeReader reader) => reader.ReadByte();
private static object DecodeBinary(ManagedByteCodeReader reader) => reader.ReadByte();
private static object CallToStringString(object instanceObj, object[] parameters) => ((byte)instanceObj).ToString((string)parameters[0]);
@@ -20,7 +20,7 @@ namespace Microsoft.Iris.Markup.UIX
writer.WriteChar(ch);
}
private static object DecodeBinary(ByteCodeReader reader) => reader.ReadChar();
private static object DecodeBinary(ManagedByteCodeReader reader) => reader.ReadChar();
private static Result ConvertFromString(object valueObj, out object instanceObj)
{

Some files were not shown because too many files have changed in this diff Show More