public void ThrowException(Type exceptionType) { this.CheckForDisposed(); if (exceptionType == null) { throw new ArgumentNullException("exceptionType"); } if (this.Document != null) { this.CurrentIndent = Indention.KeepCurrent; var codeLines = new List <CodeLine>(); var ctor = exceptionType.GetConstructor(Type.EmptyTypes); codeLines.Add(new CodeLine(this.GetLabelPrefix() + "newobj " + MethodDescriptorFactory.Create(ctor).Value, this.CurrentIndent, true)); this.LabelIndex += 5; codeLines.Add(new CodeLine(this.GetLabelPrefix() + "throw " + new TypeDescriptor( exceptionType, this.Builder.DeclaringType.Assembly).Value, this.CurrentIndent, true)); this.LabelIndex += OpCodes.Throw.Size; this.TempDocument.WriteText( codeLines, this.Generator, this.SymbolDocument); this.CurrentIndent = Indention.KeepCurrent; } this.Generator.ThrowException(exceptionType); }
private string EmitCallConsoleWriteLine(Type type) { var writer = typeof(TextWriter); var writeLine = writer.GetMethod("WriteLine", BindingFlags.Instance | BindingFlags.Public, null, new Type[] { type }, null); return(this.GetLabelPrefix() + "callvirt " + MethodDescriptorFactory.Create(writeLine).Value); }
public void EmitCall(OpCode opCode, MethodInfo methodInfo, Type[] optionalParameterTypes) { this.CheckForDisposed(); this.TempDocument.WriteText( new CodeLine(this.GetLabelPrefix() + opCode.ToString() + " " + MethodDescriptorFactory.Create(methodInfo).Value, this.CurrentIndent, true), this.Generator, this.SymbolDocument); this.LabelIndex += opCode.Size + 4; this.Generator.EmitCall(opCode, methodInfo, optionalParameterTypes); }
private void BeginMethod(MethodBase method) { if (this.Document != null) { this.TempDocument = new CodeDocument( this.Document.LinesOfCode, this.Document.IndentLevel); this.TempDocument.WriteText(new CodeLine( MethodDescriptorFactory.Create(method, true).Value, this.CurrentIndent)); this.TempDocument.WriteText(new CodeLine("{")); this.CurrentIndent = Indention.Increase; this.TempDocument.WriteText( new CodeLine(".locals init ({0})", this.CurrentIndent)); this.CurrentIndent = Indention.KeepCurrent; } }
public void Emit(OpCode opCode, MethodInfo method) { this.CheckForDisposed(); if (this.Document != null) { this.TempDocument.WriteText( new CodeLine(this.GetLabelPrefix() + opCode.ToString() + " " + MethodDescriptorFactory.Create(method).Value, this.CurrentIndent, true), this.Generator, this.SymbolDocument); this.CurrentIndent = Indention.KeepCurrent; this.LabelIndex += opCode.Size + 4; } this.Generator.Emit(opCode, method); }
internal static MethodDescriptor Create(MethodBase method) { return(MethodDescriptorFactory.Create(method, method.DeclaringType.Assembly, false)); }
internal static MethodDescriptor Create(MethodBase method, Assembly containingAssembly) { return(MethodDescriptorFactory.Create(method, containingAssembly, false)); }
internal static MethodDescriptor Create(MethodBase method, bool isDeclaration) { return(MethodDescriptorFactory.Create(method, method.DeclaringType.Assembly, isDeclaration)); }
private string EmitCallConsoleGetOutMethod() { return(this.GetLabelPrefix() + "call " + MethodDescriptorFactory.Create( typeof(Console).GetProperty("Out", BindingFlags.Static | BindingFlags.Public).GetGetMethod()).Value); }