Ejemplo n.º 1
0
        internal static void Save(string fileName)
        {
            string rootDirectory = Directory.GetCurrentDirectory();
            string fullPath      = Path.Combine(rootDirectory.Substring(0, rootDirectory.IndexOf("ZEditor")), "ZEditor\\ZEditor", fileName);

            using (var writer = new IndentableStreamWriter(fullPath))
            {
                foreach (var templatePair in LOADED_TEMPLATES)
                {
                    writer.WriteLine("\"" + templatePair.Key + "\" {");
                    writer.Indent();
                    writer.WriteLine(templatePair.Value.GetType().Name + " {");
                    writer.Indent();
                    templatePair.Value.Save(writer);
                    writer.UnIndent();
                    writer.WriteLine("}");
                    writer.UnIndent();
                    writer.WriteLine("}");
                }
            }
        }
Ejemplo n.º 2
0
		public void Dump(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("IRInstruction {0}", Opcode.ToString());
			pWriter.WriteLine("{");
			pWriter.Indent++;
			pWriter.WriteLine("IRIndex {0}", IRIndex);
			DumpDetails(pWriter);

			if (Destination != null)
			{
				pWriter.WriteLine("Destination {0}", Destination.Type);
				pWriter.WriteLine("{");
				pWriter.Indent++;
				Destination.Dump(pWriter);
				pWriter.Indent--;
				pWriter.WriteLine("}");
			}
			if (Sources.Count > 0)
			{
				pWriter.WriteLine("Sources");
				pWriter.WriteLine("{");
				pWriter.Indent++;
				for (int index = 0; index < Sources.Count; ++index)
				{
					pWriter.WriteLine("Source {0}", Sources[index].Type);
					pWriter.WriteLine("{");
					pWriter.Indent++;
					Sources[index].Dump(pWriter);
					pWriter.Indent--;
					pWriter.WriteLine("}");
				}
				pWriter.Indent--;
				pWriter.WriteLine("}");
			}

			pWriter.Indent--;
			pWriter.WriteLine("}");
		}
Ejemplo n.º 3
0
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("Target {0}", Target.ToString());
			pWriter.WriteLine("Virtual {0}", Virtual);
		}
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("Field {0}", Field.ToString());
		}
Ejemplo n.º 5
0
		public void Dump(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("#" + mTempID + " Parent: " + ParentInstruction.IRIndex);
			switch (Type)
			{
				case IRLinearizedLocationType.Null: break;
				case IRLinearizedLocationType.Local:
					pWriter.WriteLine("LocalIndex {0}", Local.LocalIndex);
					break;
				case IRLinearizedLocationType.LocalAddress:
					pWriter.WriteLine("LocalIndex {0}", LocalAddress.LocalIndex);
					break;
				case IRLinearizedLocationType.Parameter:
					pWriter.WriteLine("ParameterIndex {0}", Parameter.ParameterIndex);
					break;
				case IRLinearizedLocationType.ParameterAddress:
					pWriter.WriteLine("ParameterIndex {0}", ParameterAddress.ParameterIndex);
					break;
				case IRLinearizedLocationType.ConstantI4:
					pWriter.WriteLine("Value {0}", ConstantI4.Value);
					break;
				case IRLinearizedLocationType.ConstantI8:
					pWriter.WriteLine("Value {0}", ConstantI8.Value);
					break;
				case IRLinearizedLocationType.ConstantR4:
					pWriter.WriteLine("Value {0}", ConstantR4.Value);
					break;
				case IRLinearizedLocationType.ConstantR8:
					pWriter.WriteLine("Value {0}", ConstantR8.Value);
					break;
				case IRLinearizedLocationType.Field:
					pWriter.WriteLine("Field {0}", Field.Field.ToString());
					pWriter.WriteLine("FieldLocation {0}", Field.FieldLocation.Type);
					pWriter.WriteLine("{");
					pWriter.Indent++;
					Field.FieldLocation.Dump(pWriter);
					pWriter.Indent--;
					pWriter.WriteLine("}");
					break;
				case IRLinearizedLocationType.FieldAddress:
					pWriter.WriteLine("Field {0}", FieldAddress.Field.ToString());
					pWriter.WriteLine("FieldLocation {0}", FieldAddress.FieldLocation.Type);
					pWriter.WriteLine("{");
					pWriter.Indent++;
					FieldAddress.FieldLocation.Dump(pWriter);
					pWriter.Indent--;
					pWriter.WriteLine("}");
					break;
				case IRLinearizedLocationType.StaticField:
					pWriter.WriteLine("Field {0}", StaticField.Field.ToString());
					break;
				case IRLinearizedLocationType.StaticFieldAddress:
					pWriter.WriteLine("Field {0}", StaticFieldAddress.Field.ToString());
					break;
				case IRLinearizedLocationType.Indirect:
					pWriter.WriteLine("Type {0}", Indirect.Type.ToString());
					pWriter.WriteLine("AddressLocation {0}", Indirect.AddressLocation.Type);
					pWriter.WriteLine("{");
					pWriter.Indent++;
					Indirect.AddressLocation.Dump(pWriter);
					pWriter.Indent--;
					pWriter.WriteLine("}");
					break;
				case IRLinearizedLocationType.SizeOf:
					pWriter.WriteLine("Type {0}", SizeOf.Type.ToString());
					break;
				case IRLinearizedLocationType.ArrayElement:
					pWriter.WriteLine("ElementType {0}", ArrayElement.ElementType.ToString());
					pWriter.WriteLine("ArrayLocation {0}", ArrayElement.ArrayLocation.Type);
					pWriter.WriteLine("{");
					pWriter.Indent++;
					ArrayElement.ArrayLocation.Dump(pWriter);
					pWriter.Indent--;
					pWriter.WriteLine("}");
					pWriter.WriteLine("IndexLocation {0}", ArrayElement.IndexLocation.Type);
					pWriter.WriteLine("{");
					pWriter.Indent++;
					ArrayElement.IndexLocation.Dump(pWriter);
					pWriter.Indent--;
					pWriter.WriteLine("}");
					break;
				case IRLinearizedLocationType.ArrayElementAddress:
					pWriter.WriteLine("ElementType {0}", ArrayElementAddress.ElementType.ToString());
					pWriter.WriteLine("ArrayLocation {0}", ArrayElementAddress.ArrayLocation.Type);
					pWriter.WriteLine("{");
					pWriter.Indent++;
					ArrayElementAddress.ArrayLocation.Dump(pWriter);
					pWriter.Indent--;
					pWriter.WriteLine("}");
					pWriter.WriteLine("IndexLocation {0}", ArrayElementAddress.IndexLocation.Type);
					pWriter.WriteLine("{");
					pWriter.Indent++;
					ArrayElementAddress.IndexLocation.Dump(pWriter);
					pWriter.Indent--;
					pWriter.WriteLine("}");
					break;
				case IRLinearizedLocationType.ArrayLength:
					pWriter.WriteLine("ArrayLocation {0}", ArrayLength.ArrayLocation.Type);
					pWriter.WriteLine("{");
					pWriter.Indent++;
					ArrayLength.ArrayLocation.Dump(pWriter);
					pWriter.Indent--;
					pWriter.WriteLine("}");
					break;
				case IRLinearizedLocationType.FunctionAddress:
					if (FunctionAddress.InstanceLocation != null)
					{
						pWriter.WriteLine("InstanceLocation {0}", FunctionAddress.InstanceLocation.Type);
						pWriter.WriteLine("{");
						pWriter.Indent++;
						FunctionAddress.InstanceLocation.Dump(pWriter);
						pWriter.Indent--;
						pWriter.WriteLine("}");
					}
					pWriter.WriteLine("Method {0}", FunctionAddress.Method.ToString());
					pWriter.WriteLine("Virtual {0}", FunctionAddress.Virtual);
					break;
				case IRLinearizedLocationType.RuntimeHandle:
					pWriter.WriteLine("HandleType {0}", RuntimeHandle.HandleType.ToString());
					if (RuntimeHandle.TargetType != null)
						pWriter.WriteLine("TargetType {0}", RuntimeHandle.TargetType.ToString());
					if (RuntimeHandle.TargetMethod != null)
						pWriter.WriteLine("TargetMethod {0}", RuntimeHandle.TargetMethod.ToString());
					if (RuntimeHandle.TargetField != null)
						pWriter.WriteLine("TargetField {0}", RuntimeHandle.TargetField.ToString());
					break;
				case IRLinearizedLocationType.String:
					pWriter.WriteLine("Value {0}", String.Value);
					break;
				case IRLinearizedLocationType.Phi:
					Phi.SourceLocations.ForEach(l => l.Dump(pWriter));
					break;
			}
		}
Ejemplo n.º 6
0
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("Type {0}", Type.ToString());
			pWriter.WriteLine("ThrowExceptionOnFailure {0}", ThrowExceptionOnFailure);
		}
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			if (TargetType != null) pWriter.WriteLine("TargetType {0}", TargetType.ToString());
			if (TargetMethod != null) pWriter.WriteLine("TargetMethod {0}", TargetMethod.ToString());
			if (TargetField != null) pWriter.WriteLine("TargetField {0}", TargetField.ToString());
		}
Ejemplo n.º 8
0
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("CompareCondition {0}", CompareCondition.ToString());
		}
Ejemplo n.º 9
0
		public void Dump(IndentableStreamWriter pWriter)
		{
			StringBuilder sb = new StringBuilder();
			if (IsLiteral) sb.AppendFormat(", LiteralType {0}", LiteralType.ToString());
			pWriter.WriteLine("IRField {0} @ {1}{2}", ToString(), Offset, sb.ToString());
		}
Ejemplo n.º 10
0
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("ForceEmit {0}", ForceEmit);
		}
Ejemplo n.º 11
0
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("BranchCondition {0} -> {1}", BranchCondition, TargetIRInstruction.IRIndex);
		}
Ejemplo n.º 12
0
		public void Dump(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("IRLocal #{0} {1} @ {2}", mTempID, ToString(), Offset);
		}
Ejemplo n.º 13
0
		public void Dump(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("IRAssembly {0}", File.ReferenceName);
			pWriter.WriteLine("{");
			pWriter.Indent++;
			Types.ForEach(t => t.Dump(pWriter));
			pWriter.Indent--;
			pWriter.WriteLine("}");
		}
Ejemplo n.º 14
0
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("ShiftType {0}", ShiftType.ToString());
		}
Ejemplo n.º 15
0
		public void Dump(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("IRParameter {0} @ {1}", ToString(), Offset);
		}
Ejemplo n.º 16
0
		public void Dump(IndentableStreamWriter pWriter)
		{
			StringBuilder sb = new StringBuilder(256);
			if (IsAbstract) sb.Append(" abstract");
			if (IsFinal) sb.Append(" final");
			if (IsInternalCall) sb.Append(" internalCall");
			if (IsRuntime) sb.Append(" runtime");
			if (IsSynchronized) sb.Append(" synchronized");
			if (IsVirtual) sb.Append(" virtual");
			if (sb.Length > 0)
			{
				sb.Insert(1, '|');
				sb.Append('|');
			}
			pWriter.WriteLine("IRMethod({0}) #{1}{2} {3}", mGlobalMethodID, mTempID, sb.ToString(), ToString());
			pWriter.WriteLine("{");
			pWriter.Indent++;
			Parameters.ForEach(p => p.Dump(pWriter));
			pWriter.WriteLine("Resolution State: {0}", (PresolvedMethod ? "Presolved" : (PostsolvedMethod ? "Postsolved" : (IsGeneric ? (Resolved ? "Instantiated" : "Unresolved") : "Original"))));
			if (!IsAbstract && !IsInternalCall && !IsRuntime)
			{
				Locals.ForEach(l => l.Dump(pWriter));
				pWriter.WriteLine("IRInstructions");
				pWriter.WriteLine("{");
				pWriter.Indent++;
				Instructions.ForEach(i => i.Dump(pWriter));
				pWriter.Indent--;
				pWriter.WriteLine("}");
				//if (LIRMethod != null) LIRMethod.Dump(pWriter);
			}
			pWriter.Indent--;
			pWriter.WriteLine("}");
		}
Ejemplo n.º 17
0
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("LocalIndex {0}", LocalIndex);
		}
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("ParameterIndex {0}", ParameterIndex);
		}
Ejemplo n.º 19
0
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("OverflowType {0}", OverflowType);
		}
Ejemplo n.º 20
0
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("Value {0}", Value);
		}
Ejemplo n.º 21
0
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("Type {0}", Type.ToString());
			pWriter.WriteLine("GetValue {0}", GetValue);
		}
Ejemplo n.º 22
0
		protected override void DumpDetails(IndentableStreamWriter pWriter)
		{
			pWriter.WriteLine("Constructor {0}", Constructor.ToString());
		}