Exemple #1
0
			public void Write(IO.EndianWriter stream)
			{
				int orgPos = stream.Position;

				if (address != 0)
				{
					if (offsets.Count == 0)
					{
						string name = (stream.Owner as Compiler).GetLocationName(this);
						Debug.LogFile.WriteLine("LocationWriteback: unused address! There are no references to '{0}'", name);
					}
					else foreach (uint tempPos in offsets)
					{
						stream.PositionUnsigned = tempPos;
						stream.WritePointer(address);
					}
				}
				else
				{
					string name = (stream.Owner as Compiler).GetLocationName(this);
					Debug.LogFile.WriteLine("LocationWriteback: failed to writeback! '{0}'s address was not set, {1} memory locations will be null!",
						name, offsets.Count.ToString());
				}

				stream.Position = orgPos;
			}
			public override void Write(IO.EndianWriter stream)
			{
				Compiler comp = stream.Owner as Compiler;

				uint elementsAddress = 0;
				int flags = (
						(tagRef.IsNonResolving ? 1<<1 : 0)
					);

				if (tagRef.Elements.Count > 1)
				{
					elementsAddress = stream.PositionUnsigned;
					foreach (string i in tagRef.Elements)
						stream.WriteTag(i);

					comp.MarkLocationFixup(tagRef.Name, stream, true);
					stream.Write(flags);
					stream.Write((int)-1);
					stream.WritePointer(elementsAddress);
				}
				else
				{
					comp.MarkLocationFixup(tagRef.Name, stream, true);
					stream.Write(flags);
					stream.WriteTag(tagRef.Elements[0]);
					stream.Write((int)0);
				}
			}
Exemple #3
0
			public void Write(IO.EndianWriter stream)
			{
				Compiler comp = stream.Owner as Compiler;
				Import import = comp.OwnerState.Importer as Import;

				int real_count = import.Groups.Count;
				stream.Write("dynamic tag groups", false);
				stream.Write((short)DataArray.MaxValue);
				stream.Write((short)Item.Size);
				stream.Write(true);
				stream.Write(true);
				stream.Write((short)0);
				MiscGroups.data.Write(stream);
				stream.Write((short)real_count);//stream.Write((short)Datums.Count);
				stream.Write((short)real_count);//stream.Write((short)Datums.Count);
				stream.Write(real_count);
				stream.WritePointer(stream.PositionUnsigned + 4);

				#region Write tag group datums
				foreach (Import.TagGroup tg in import.Groups.Values)
				{
					stream.Write((short)0); // Header
					stream.Write((short)0); // Flags
					comp.AddLocationFixup(tg.Name, stream, false);
					stream.Write((int)0);
				}
				#endregion

				#region Write null datums
				Item i = new Item();
				int count = DataArray.MaxValue - real_count;
				for (int x = 0; x < count; x++)
					i.Write(stream);
				#endregion
			}
			public override void Write(IO.EndianWriter stream)
			{
				Compiler comp = stream.Owner as Compiler;

				uint elementsAddress = stream.PositionUnsigned;
				// write string list's element's addresses
				foreach (uint i in stringList.Elements) stream.Write(i);

				comp.MarkLocationFixup(stringList.Name, stream, true);

				stream.Write(stringList.Elements.Count);
				stream.WritePointer(elementsAddress);
			}
Exemple #5
0
			public void Write(IO.EndianWriter stream)
			{
				Compiler comp = stream.Owner as Compiler;
				Import import = comp.OwnerState.Importer as Import;

				short real_count = (short)import.Groups.Count;
				var next_index = new DatumIndex((ushort)real_count,
					0); // note that this default value isn't ideal
				stream.Write("dynamic tag groups", false);
				stream.Write(DataArray.MaxValue);
				stream.Write(Item.Size);
				stream.Write((byte)0); // alignment bit
				stream.Write(true); // is valid
				stream.Write((short)0); // flags
				MiscGroups.data.Write(stream);
				stream.Write(uint.MinValue); // allocator
				stream.Write((int)0); // bit vector next index
				stream.Write(Datums.Count); // bit vector length
				stream.Write(Datums.Count); // actual count
				next_index.Write(stream); // next index
				stream.WritePointer(stream.PositionUnsigned + 8);
				stream.Write((int)0); // bit vector pointer

				#region Write tag group datums
				foreach (Import.TagGroup tg in import.Groups.Values)
				{
					stream.Write((short)0); // Header
					stream.Write((short)0); // Flags
					comp.AddLocationFixup(tg.Name, stream, false);
					stream.Write((int)0);
				}
				#endregion

				#region Write null datums
				Item i = new Item();
				int count = DataArray.MaxValue - real_count;
				for (int x = 0; x < count; x++)
					i.Write(stream);
				#endregion
			}
Exemple #6
0
			public override void Write(IO.EndianWriter stream)
			{
				Compiler comp = stream.Owner as Compiler;

				int flags;

				#region Block
				var tag_block = tagGroup.Block as Import.TagBlock;
				uint fieldsAddress = new FieldsWriter(tag_block.Fields).WriteFields(stream, comp);
				//comp.MarkLocationFixup(tag_block.Name, stream, false);

				flags = (
						(tag_block.DontReadChildren ? 1 << 0 : 0)
					);

				uint blockAddress = stream.PositionUnsigned;
				stream.Write(tagGroup.BlockName);
				stream.Write(flags);
				stream.Write((int)1); // max elements
				stream.Write(tag_block.CalculateSize(comp.OwnerState));
				stream.Write((int)0);
				stream.WritePointer(fieldsAddress);

				// procs
				stream.Write((int)0); stream.Write((int)0); stream.Write((int)0); stream.Write((int)0);

				stream.Write((int)0); // byte swap codes address
				#endregion

				comp.MarkLocationFixup(tagGroup.Name, stream, false);

				flags = (
						(tagGroup.IsIncludedInTagGroupsChecksum ? 1 << 0 : 0)
					);

				stream.Write(tagGroup.Name);
				stream.Write(flags);
				if (string.IsNullOrEmpty(tagGroup.GroupTag))
					Debug.LogFile.WriteLine("CheApe: tag_group '{0}' has a bad group-tag...check your XML?");
				stream.WriteTag(tagGroup.GroupTag);
				if (tagGroup.ParentTag != null)
				{
					if (string.IsNullOrEmpty(tagGroup.GroupTag))
						Debug.LogFile.WriteLine("CheApe: tag_group '{0}' has a bad parent group-tag...check your XML?");
					stream.WriteTag(tagGroup.ParentTag);
				}
				else
					stream.Write((int)-1);
				stream.Write(tagGroup.Version); stream.Write((short)0);
				stream.Write((int)0); // post process proc
				stream.WritePointer(blockAddress);
				for (int x = 0; x < 17; x++) stream.Write((int)0); // child group tags
				stream.Write((int)0); // we don't support that shit, gtfo
				stream.Write((int)0);
			}
Exemple #7
0
			public override void Write(IO.EndianWriter stream)
			{
				Compiler comp = stream.Owner as Compiler;

				uint fieldsAddress = new FieldsWriter(tagBlock.Fields).WriteFields(stream, comp);
				comp.MarkLocationFixup(tagBlock.Name, stream, false);

				int flags = (
						(tagBlock.DontReadChildren ? 1 << 0 : 0)
					);

				stream.Write(tagBlock.Name);
				stream.Write(flags);
				stream.Write(tagBlock.MaxElements);
				stream.Write(tagBlock.CalculateSize(comp.OwnerState));
				stream.Write((int)0);
				stream.WritePointer(fieldsAddress);

				// procs
				stream.Write((int)0); stream.Write((int)0); stream.Write((int)0); stream.Write((int)0);

				stream.Write((int)0); // byte swap codes address
			}
Exemple #8
0
			public override void Write(IO.EndianWriter stream)
			{
				Compiler comp = stream.Owner as Compiler;

				TagBlock tb = new TagBlock((Import.TagBlock)tagGroup.Block);
				tb.Write(stream);

				comp.MarkLocationFixup(tagGroup.Name, stream, false);

				stream.Write(tagGroup.Name);
				stream.Write((int)0);
				stream.WriteTag(tagGroup.GroupTag);
				if (tagGroup.ParentTag != null)
					stream.WriteTag(tagGroup.ParentTag);
				else
					stream.Write((int)-1);
				stream.Write(tagGroup.Version);
				stream.Write((short)1); // init'd
				stream.Write((int)0);
				stream.Write((int)0);
				stream.Write((int)0);
				stream.Write((int)0);
				stream.WritePointer(tb.RuntimeAddress);
				for (int x = 0; x < 17; x++) stream.Write((int)0); // child group tags
				stream.Write((int)0); // we don't support that shit, gtfo
				stream.Write(comp.Strings.GetNull());
			}
Exemple #9
0
			public override void Write(IO.EndianWriter stream)
			{
				Compiler comp = stream.Owner as Compiler;

				TagBlock tb = new TagBlock((Import.TagBlock)tagStruct.Block);
				tb.Write(stream);

				comp.MarkLocationFixup(tagStruct.Name, stream, false);

				stream.Write(tagStruct.Name);
				stream.WriteTag(tagStruct.GroupTag);
				stream.Write(tagStruct.Block.DisplayName);
				stream.WritePointer(tb.RuntimeAddress);
			}
Exemple #10
0
			public override void Write(IO.EndianWriter stream)
			{
				Compiler comp = stream.Owner as Compiler;

				#region FieldSets
				uint fieldSetsAddress = stream.PositionUnsigned;
				FieldSet temp = new FieldSet();
				Import.FieldSet fs;
				int x;
				for (x = 0; x < tagBlock.FieldSets.Count - 1; x++)
				{
					fs = tagBlock.FieldSets[x];
					temp.Reset(fs);
					temp.Write(stream);
				}

				uint fieldSetLatestAddress = stream.PositionUnsigned;
				fs = tagBlock.FieldSets[x];
				temp.Reset(fs);
				temp.Write(stream);
				#endregion

				comp.MarkLocationFixup(tagBlock.Name, stream, false);

				RuntimeAddress = stream.PositionUnsigned;
				stream.Write(tagBlock.Name);
				stream.Write(tagBlock.DisplayName);
				stream.Write((int)0);
				stream.Write(tagBlock.MaxElements);
				stream.Write(comp.Strings.GetNull());
				stream.WritePointer(fieldSetsAddress);
				stream.Write(tagBlock.FieldSets.Count);
				stream.WritePointer(fieldSetLatestAddress);
				stream.Write((int)0);
				stream.Write((int)0);
				stream.Write((int)0);
				stream.Write((int)0);
				stream.Write((int)0);
				stream.Write((int)0);
				stream.Write((int)0);
			}
Exemple #11
0
			public override void Write(IO.EndianWriter stream)
			{
				Compiler comp = stream.Owner as Compiler;

				#region Fields
				#region Byte swap codes
				/*
				uint fieldBSCodesAddress = stream.PositionUnsigned;
				stream.Write(comp.OwnerState.Definition.FieldTypes[comp.TypeIndexArrayStart].ByteSwapCodes[0]);
				stream.Write((int)1); // array count
				foreach (Import.Field f in fieldSet.Fields)
				{
					if (f.TypeIndex == comp.TypeIndexUselessPad) continue;
					else if (f.TypeIndex == comp.TypeIndexPad || f.TypeIndex == comp.TypeIndexSkip)
						stream.Write(f.ToInt());
					else
						foreach (int x in comp.OwnerState.Definition.FieldTypes[f.TypeIndex].ByteSwapCodes)
							if (x != 0)
								stream.Write(x);
				}
				stream.Write(comp.OwnerState.Definition.FieldTypes[comp.TypeIndexArrayEnd].ByteSwapCodes[0]);
				*/
				#endregion

				uint fieldsAddress = stream.PositionUnsigned;
				Field temp = new Field();
				foreach (Import.Field f in fieldSet.Fields)
				{
					temp.Reset(f);
					temp.Write(stream);
				}
				stream.Write(comp.TypeIndexTerminator); stream.Write((int)0); stream.Write((int)0); stream.Write((int)0);
				#endregion

				int field_set_size = fieldSet.CalculateSize(comp.OwnerState);

				stream.WritePointer(fieldsAddress);
				stream.Write((int)0);
				stream.Write((int)0);
				stream.Write((int)0);
				stream.Write(uint.MaxValue);
				stream.Write(field_set_size);
				stream.Write((int)0);
				stream.Write((int)0);
				stream.WritePointer(fieldsAddress);
				stream.Write(comp.Strings.GetNull());

				stream.Write(comp.Strings.GetNull());
				stream.Write(field_set_size);
				stream.Write((int)0);//stream.WritePointer(fieldBSCodesAddress);
				MiscGroups.bysw.Write(stream);
				stream.Write((int)0/*1*/);

				stream.Write((int)0);
				stream.Write((int)0);
				stream.Write((int)0);
				stream.Write((int)0);
			}