Mercurial > pub > bltoolkit
comparison Source/Reflection/Emit/EmitHelper.cs @ 0:f990fcb411a9
Копия текущей версии из github
| author | cin |
|---|---|
| date | Thu, 27 Mar 2014 21:46:09 +0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f990fcb411a9 |
|---|---|
| 1 using System; | |
| 2 using System.Diagnostics.CodeAnalysis; | |
| 3 using System.Diagnostics.SymbolStore; | |
| 4 using System.Reflection; | |
| 5 using System.Reflection.Emit; | |
| 6 using System.Runtime.InteropServices; | |
| 7 | |
| 8 using BLToolkit.Common; | |
| 9 using BLToolkit.Properties; | |
| 10 | |
| 11 // ReSharper disable InconsistentNaming | |
| 12 | |
| 13 namespace BLToolkit.Reflection.Emit | |
| 14 { | |
| 15 /// <summary> | |
| 16 /// A wrapper around the <see cref="ILGenerator"/> class. | |
| 17 /// </summary> | |
| 18 /// <include file="Examples.CS.xml" path='examples/emit[@name="Emit"]/*' /> | |
| 19 /// <include file="Examples.VB.xml" path='examples/emit[@name="Emit"]/*' /> | |
| 20 /// <seealso cref="System.Reflection.Emit.ILGenerator">ILGenerator Class</seealso> | |
| 21 public class EmitHelper | |
| 22 { | |
| 23 /// <summary> | |
| 24 /// Initializes a new instance of the <see cref="EmitHelper"/> class | |
| 25 /// with the specified <see cref="System.Reflection.Emit.ILGenerator"/>. | |
| 26 /// </summary> | |
| 27 /// <param name="ilGenerator">The <see cref="System.Reflection.Emit.ILGenerator"/> to use.</param> | |
| 28 public EmitHelper(ILGenerator ilGenerator) | |
| 29 { | |
| 30 if (ilGenerator == null) throw new ArgumentNullException("ilGenerator"); | |
| 31 | |
| 32 _ilGenerator = ilGenerator; | |
| 33 } | |
| 34 | |
| 35 /// <summary> | |
| 36 /// Initializes a new instance of the <see cref="EmitHelper"/> class | |
| 37 /// with the specified <see cref="System.Reflection.Emit.ILGenerator"/>. | |
| 38 /// </summary> | |
| 39 /// <param name="methodBuilder">Associated <see cref="MethodBuilderBase"/>.</param> | |
| 40 /// <param name="ilGenerator">The <see cref="System.Reflection.Emit.ILGenerator"/> to use.</param> | |
| 41 public EmitHelper(MethodBuilderBase methodBuilder, ILGenerator ilGenerator) | |
| 42 { | |
| 43 if (methodBuilder == null) throw new ArgumentNullException("methodBuilder"); | |
| 44 if (ilGenerator == null) throw new ArgumentNullException("ilGenerator"); | |
| 45 | |
| 46 _method = methodBuilder; | |
| 47 _ilGenerator = ilGenerator; | |
| 48 } | |
| 49 | |
| 50 private readonly MethodBuilderBase _method; | |
| 51 /// <summary> | |
| 52 /// Gets <see cref="MethodBuilderHelper"/>. | |
| 53 /// </summary> | |
| 54 public MethodBuilderBase Method | |
| 55 { | |
| 56 get { return _method; } | |
| 57 } | |
| 58 | |
| 59 private readonly ILGenerator _ilGenerator; | |
| 60 /// <summary> | |
| 61 /// Gets MSIL generator. | |
| 62 /// </summary> | |
| 63 public ILGenerator ILGenerator | |
| 64 { | |
| 65 get { return _ilGenerator; } | |
| 66 } | |
| 67 | |
| 68 /// <summary> | |
| 69 /// Converts the supplied <see cref="EmitHelper"/> to a <see cref="ILGenerator"/>. | |
| 70 /// </summary> | |
| 71 /// <param name="emitHelper">The <see cref="EmitHelper"/>.</param> | |
| 72 /// <returns>An ILGenerator.</returns> | |
| 73 public static implicit operator ILGenerator(EmitHelper emitHelper) | |
| 74 { | |
| 75 if (emitHelper == null) throw new ArgumentNullException("emitHelper"); | |
| 76 | |
| 77 return emitHelper.ILGenerator; | |
| 78 } | |
| 79 | |
| 80 #region ILGenerator Methods | |
| 81 | |
| 82 /// <summary> | |
| 83 /// Begins a catch block. | |
| 84 /// </summary> | |
| 85 /// <param name="exceptionType">The Type object that represents the exception.</param> | |
| 86 /// <seealso cref="System.Reflection.Emit.ILGenerator.BeginCatchBlock(Type)">ILGenerator.BeginCatchBlock Method</seealso> | |
| 87 public EmitHelper BeginCatchBlock(Type exceptionType) | |
| 88 { | |
| 89 _ilGenerator.BeginCatchBlock(exceptionType); return this; | |
| 90 } | |
| 91 | |
| 92 /// <summary> | |
| 93 /// Begins an exception block for a filtered exception. | |
| 94 /// </summary> | |
| 95 /// <seealso cref="System.Reflection.Emit.ILGenerator.BeginExceptFilterBlock">ILGenerator.BeginCatchBlock Method</seealso> | |
| 96 public EmitHelper BeginExceptFilterBlock() | |
| 97 { | |
| 98 _ilGenerator.BeginExceptFilterBlock(); return this; | |
| 99 } | |
| 100 | |
| 101 /// <summary> | |
| 102 /// Begins an exception block for a non-filtered exception. | |
| 103 /// </summary> | |
| 104 /// <returns>The label for the end of the block.</returns> | |
| 105 public Label BeginExceptionBlock() | |
| 106 { | |
| 107 return _ilGenerator.BeginExceptionBlock(); | |
| 108 } | |
| 109 | |
| 110 /// <summary> | |
| 111 /// Begins an exception fault block in the Microsoft intermediate language (MSIL) stream. | |
| 112 /// </summary> | |
| 113 /// <returns>Current instance of the <see cref="EmitHelper"/>.</returns> | |
| 114 public EmitHelper BeginFaultBlock() | |
| 115 { | |
| 116 _ilGenerator.BeginFaultBlock(); return this; | |
| 117 } | |
| 118 | |
| 119 /// <summary> | |
| 120 /// Begins a finally block in the Microsoft intermediate language (MSIL) instruction stream. | |
| 121 /// </summary> | |
| 122 /// <returns>Current instance of the <see cref="EmitHelper"/>.</returns> | |
| 123 public EmitHelper BeginFinallyBlock() | |
| 124 { | |
| 125 _ilGenerator.BeginFinallyBlock(); return this; | |
| 126 } | |
| 127 | |
| 128 /// <summary> | |
| 129 /// Begins a lexical scope. | |
| 130 /// </summary> | |
| 131 /// <returns>Current instance of the <see cref="EmitHelper"/>.</returns> | |
| 132 public EmitHelper BeginScope() | |
| 133 { | |
| 134 _ilGenerator.BeginScope(); return this; | |
| 135 } | |
| 136 | |
| 137 /// <summary> | |
| 138 /// Declares a local variable. | |
| 139 /// </summary> | |
| 140 /// <param name="localType">The Type of the local variable.</param> | |
| 141 /// <returns>The declared local variable.</returns> | |
| 142 public LocalBuilder DeclareLocal(Type localType) | |
| 143 { | |
| 144 return _ilGenerator.DeclareLocal(localType); | |
| 145 } | |
| 146 | |
| 147 /// <summary> | |
| 148 /// Declares a local variable, optionally pinning the object referred to by the variable. | |
| 149 /// </summary> | |
| 150 /// <param name="localType">The Type of the local variable.</param> | |
| 151 /// <param name="pinned"><b>true</b> to pin the object in memory; otherwise, <b>false</b>.</param> | |
| 152 /// <returns>The declared local variable.</returns> | |
| 153 public LocalBuilder DeclareLocal(Type localType, bool pinned) | |
| 154 { | |
| 155 return _ilGenerator.DeclareLocal(localType, pinned); | |
| 156 } | |
| 157 | |
| 158 /// <summary> | |
| 159 /// Declares a new label. | |
| 160 /// </summary> | |
| 161 /// <returns>Returns a new label that can be used as a token for branching.</returns> | |
| 162 public Label DefineLabel() | |
| 163 { | |
| 164 return _ilGenerator.DefineLabel(); | |
| 165 } | |
| 166 | |
| 167 /// <summary> | |
| 168 /// Ends an exception block. | |
| 169 /// </summary> | |
| 170 /// <returns>Current instance of the <see cref="EmitHelper"/>.</returns> | |
| 171 public EmitHelper EndExceptionBlock() | |
| 172 { | |
| 173 _ilGenerator.EndExceptionBlock(); return this; | |
| 174 } | |
| 175 | |
| 176 /// <summary> | |
| 177 /// Ends a lexical scope. | |
| 178 /// </summary> | |
| 179 /// <returns>Current instance of the <see cref="EmitHelper"/>.</returns> | |
| 180 public EmitHelper EndScope() | |
| 181 { | |
| 182 _ilGenerator.EndScope(); return this; | |
| 183 } | |
| 184 | |
| 185 /// <summary> | |
| 186 /// Marks the Microsoft intermediate language (MSIL) stream's current position | |
| 187 /// with the given label. | |
| 188 /// </summary> | |
| 189 /// <param name="loc">The label for which to set an index.</param> | |
| 190 /// <returns>Current instance of the <see cref="EmitHelper"/>.</returns> | |
| 191 public EmitHelper MarkLabel(Label loc) | |
| 192 { | |
| 193 _ilGenerator.MarkLabel(loc); return this; | |
| 194 } | |
| 195 | |
| 196 /// <summary> | |
| 197 /// Marks a sequence point in the Microsoft intermediate language (MSIL) stream. | |
| 198 /// </summary> | |
| 199 /// <param name="document">The document for which the sequence point is being defined.</param> | |
| 200 /// <param name="startLine">The line where the sequence point begins.</param> | |
| 201 /// <param name="startColumn">The column in the line where the sequence point begins.</param> | |
| 202 /// <param name="endLine">The line where the sequence point ends.</param> | |
| 203 /// <param name="endColumn">The column in the line where the sequence point ends.</param> | |
| 204 /// <returns>Current instance of the <see cref="EmitHelper"/>.</returns> | |
| 205 public EmitHelper MarkSequencePoint( | |
| 206 ISymbolDocumentWriter document, | |
| 207 int startLine, | |
| 208 int startColumn, | |
| 209 int endLine, | |
| 210 int endColumn) | |
| 211 { | |
| 212 _ilGenerator.MarkSequencePoint(document, startLine, startColumn, endLine, endColumn); | |
| 213 return this; | |
| 214 } | |
| 215 | |
| 216 /// <summary> | |
| 217 /// Emits an instruction to throw an exception. | |
| 218 /// </summary> | |
| 219 /// <param name="exceptionType">The class of the type of exception to throw.</param> | |
| 220 /// <returns>Current instance of the <see cref="EmitHelper"/>.</returns> | |
| 221 public EmitHelper ThrowException(Type exceptionType) | |
| 222 { | |
| 223 _ilGenerator.ThrowException(exceptionType); return this; | |
| 224 } | |
| 225 | |
| 226 /// <summary> | |
| 227 /// Specifies the namespace to be used in evaluating locals and watches for | |
| 228 /// the current active lexical scope. | |
| 229 /// </summary> | |
| 230 /// <param name="namespaceName">The namespace to be used in evaluating locals and watches for the current active lexical scope.</param> | |
| 231 /// <returns>Current instance of the <see cref="EmitHelper"/>.</returns> | |
| 232 public EmitHelper UsingNamespace(string namespaceName) | |
| 233 { | |
| 234 _ilGenerator.UsingNamespace(namespaceName); return this; | |
| 235 } | |
| 236 | |
| 237 #endregion | |
| 238 | |
| 239 #region Emit Wrappers | |
| 240 | |
| 241 /// <summary> | |
| 242 /// Calls ILGenerator.Emit(<see cref="OpCodes.Add"/>) that | |
| 243 /// adds two values and pushes the result onto the evaluation stack. | |
| 244 /// </summary> | |
| 245 /// <seealso cref="OpCodes.Add">OpCodes.Add</seealso> | |
| 246 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 247 public EmitHelper add | |
| 248 { | |
| 249 get { _ilGenerator.Emit(OpCodes.Add); return this; } | |
| 250 } | |
| 251 | |
| 252 /// <summary> | |
| 253 /// Calls ILGenerator.Emit(<see cref="OpCodes.Add_Ovf"/>) that | |
| 254 /// adds two integers, performs an overflow check, and pushes the result onto the evaluation stack. | |
| 255 /// </summary> | |
| 256 /// <seealso cref="OpCodes.Add_Ovf">OpCodes.Add_Ovf</seealso> | |
| 257 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 258 public EmitHelper add_ovf | |
| 259 { | |
| 260 get { _ilGenerator.Emit(OpCodes.Add_Ovf); return this; } | |
| 261 } | |
| 262 | |
| 263 /// <summary> | |
| 264 /// Calls ILGenerator.Emit(<see cref="OpCodes.Add_Ovf_Un"/>) that | |
| 265 /// adds two unsigned integer values, performs an overflow check, and pushes the result onto the evaluation stack. | |
| 266 /// </summary> | |
| 267 /// <seealso cref="OpCodes.Add_Ovf_Un">OpCodes.Add_Ovf_Un</seealso> | |
| 268 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 269 public EmitHelper add_ovf_un | |
| 270 { | |
| 271 get { _ilGenerator.Emit(OpCodes.Add_Ovf_Un); return this; } | |
| 272 } | |
| 273 | |
| 274 /// <summary> | |
| 275 /// Calls ILGenerator.Emit(<see cref="OpCodes.And"/>) that | |
| 276 /// computes the bitwise AND of two values and pushes the result onto the evalution stack. | |
| 277 /// </summary> | |
| 278 /// <seealso cref="OpCodes.And">OpCodes.And</seealso> | |
| 279 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 280 public EmitHelper and | |
| 281 { | |
| 282 get { _ilGenerator.Emit(OpCodes.And); return this; } | |
| 283 } | |
| 284 | |
| 285 /// <summary> | |
| 286 /// Calls ILGenerator.Emit(<see cref="OpCodes.Arglist"/>) that | |
| 287 /// returns an unmanaged pointer to the argument list of the current method. | |
| 288 /// </summary> | |
| 289 /// <seealso cref="OpCodes.Arglist">OpCodes.Arglist</seealso> | |
| 290 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 291 public EmitHelper arglist | |
| 292 { | |
| 293 get { _ilGenerator.Emit(OpCodes.Arglist); return this; } | |
| 294 } | |
| 295 | |
| 296 /// <summary> | |
| 297 /// Calls ILGenerator.Emit(<see cref="OpCodes.Beq"/>, label) that | |
| 298 /// transfers control to a target instruction if two values are equal. | |
| 299 /// </summary> | |
| 300 /// <param name="label">The label to branch from this location.</param> | |
| 301 /// <seealso cref="OpCodes.Beq">OpCodes.Beq</seealso> | |
| 302 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 303 public EmitHelper beq(Label label) | |
| 304 { | |
| 305 _ilGenerator.Emit(OpCodes.Beq, label); return this; | |
| 306 } | |
| 307 | |
| 308 /// <summary> | |
| 309 /// Calls ILGenerator.Emit(<see cref="OpCodes.Beq_S"/>, label) that | |
| 310 /// transfers control to a target instruction (short form) if two values are equal. | |
| 311 /// </summary> | |
| 312 /// <param name="label">The label to branch from this location.</param> | |
| 313 /// <seealso cref="OpCodes.Beq_S">OpCodes.Beq_S</seealso> | |
| 314 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 315 public EmitHelper beq_s(Label label) | |
| 316 { | |
| 317 _ilGenerator.Emit(OpCodes.Beq_S, label); return this; | |
| 318 } | |
| 319 | |
| 320 /// <summary> | |
| 321 /// Calls ILGenerator.Emit(<see cref="OpCodes.Bge"/>, label) that | |
| 322 /// transfers control to a target instruction if the first value is greater than or equal to the second value. | |
| 323 /// </summary> | |
| 324 /// <param name="label">The label to branch from this location.</param> | |
| 325 /// <seealso cref="OpCodes.Bge">OpCodes.Bge</seealso> | |
| 326 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 327 public EmitHelper bge(Label label) | |
| 328 { | |
| 329 _ilGenerator.Emit(OpCodes.Bge, label); return this; | |
| 330 } | |
| 331 | |
| 332 /// <summary> | |
| 333 /// Calls ILGenerator.Emit(<see cref="OpCodes.Bge_S"/>, label) that | |
| 334 /// transfers control to a target instruction (short form) | |
| 335 /// if the first value is greater than or equal to the second value. | |
| 336 /// </summary> | |
| 337 /// <param name="label">The label to branch from this location.</param> | |
| 338 /// <seealso cref="OpCodes.Bge_S">OpCodes.Bge_S</seealso> | |
| 339 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 340 public EmitHelper bge_s(Label label) | |
| 341 { | |
| 342 _ilGenerator.Emit(OpCodes.Bge_S, label); return this; | |
| 343 } | |
| 344 | |
| 345 /// <summary> | |
| 346 /// Calls ILGenerator.Emit(<see cref="OpCodes.Bge_Un"/>, label) that | |
| 347 /// transfers control to a target instruction if the the first value is greather than the second value, | |
| 348 /// when comparing unsigned integer values or unordered float values. | |
| 349 /// </summary> | |
| 350 /// <param name="label">The label to branch from this location.</param> | |
| 351 /// <seealso cref="OpCodes.Bge_Un">OpCodes.Bge_Un</seealso> | |
| 352 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 353 public EmitHelper bge_un(Label label) | |
| 354 { | |
| 355 _ilGenerator.Emit(OpCodes.Bge_Un, label); return this; | |
| 356 } | |
| 357 | |
| 358 /// <summary> | |
| 359 /// Calls ILGenerator.Emit(<see cref="OpCodes.Bge_Un_S"/>, label) that | |
| 360 /// transfers control to a target instruction (short form) if if the the first value is greather than the second value, | |
| 361 /// when comparing unsigned integer values or unordered float values. | |
| 362 /// </summary> | |
| 363 /// <param name="label">The label to branch from this location.</param> | |
| 364 /// <seealso cref="OpCodes.Bge_Un_S">OpCodes.Bge_Un_S</seealso> | |
| 365 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 366 public EmitHelper bge_un_s(Label label) | |
| 367 { | |
| 368 _ilGenerator.Emit(OpCodes.Bge_Un_S, label); return this; | |
| 369 } | |
| 370 | |
| 371 /// <summary> | |
| 372 /// Calls ILGenerator.Emit(<see cref="OpCodes.Bgt"/>, label) that | |
| 373 /// transfers control to a target instruction if the first value is greater than the second value. | |
| 374 /// </summary> | |
| 375 /// <param name="label">The label to branch from this location.</param> | |
| 376 /// <seealso cref="OpCodes.Bgt">OpCodes.Bgt</seealso> | |
| 377 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 378 public EmitHelper bgt(Label label) | |
| 379 { | |
| 380 _ilGenerator.Emit(OpCodes.Bgt, label); return this; | |
| 381 } | |
| 382 | |
| 383 /// <summary> | |
| 384 /// Calls ILGenerator.Emit(<see cref="OpCodes.Bgt_S"/>, label) that | |
| 385 /// transfers control to a target instruction (short form) if the first value is greater than the second value. | |
| 386 /// </summary> | |
| 387 /// <param name="label">The label to branch from this location.</param> | |
| 388 /// <seealso cref="OpCodes.Bgt_S">OpCodes.Bgt_S</seealso> | |
| 389 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 390 public EmitHelper bgt_s(Label label) | |
| 391 { | |
| 392 _ilGenerator.Emit(OpCodes.Bgt_S, label); return this; | |
| 393 } | |
| 394 | |
| 395 /// <summary> | |
| 396 /// Calls ILGenerator.Emit(<see cref="OpCodes.Bgt_Un"/>, label) that | |
| 397 /// transfers control to a target instruction if the first value is greater than the second value, | |
| 398 /// when comparing unsigned integer values or unordered float values. | |
| 399 /// </summary> | |
| 400 /// <param name="label">The label to branch from this location.</param> | |
| 401 /// <seealso cref="OpCodes.Bgt_Un">OpCodes.Bgt_Un</seealso> | |
| 402 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 403 public EmitHelper bgt_un(Label label) | |
| 404 { | |
| 405 _ilGenerator.Emit(OpCodes.Bgt_Un, label); return this; | |
| 406 } | |
| 407 | |
| 408 /// <summary> | |
| 409 /// Calls ILGenerator.Emit(<see cref="OpCodes.Bgt_Un_S"/>, label) that | |
| 410 /// transfers control to a target instruction (short form) if the first value is greater than the second value, | |
| 411 /// when comparing unsigned integer values or unordered float values. | |
| 412 /// </summary> | |
| 413 /// <param name="label">The label to branch from this location.</param> | |
| 414 /// <seealso cref="OpCodes.Bgt_Un_S">OpCodes.Bgt_Un_S</seealso> | |
| 415 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 416 public EmitHelper bgt_un_s(Label label) | |
| 417 { | |
| 418 _ilGenerator.Emit(OpCodes.Bgt_Un_S, label); return this; | |
| 419 } | |
| 420 | |
| 421 /// <summary> | |
| 422 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ble"/>, label) that | |
| 423 /// transfers control to a target instruction if the first value is less than or equal to the second value. | |
| 424 /// </summary> | |
| 425 /// <param name="label">The label to branch from this location.</param> | |
| 426 /// <seealso cref="OpCodes.Ble">OpCodes.Ble</seealso> | |
| 427 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 428 public EmitHelper ble(Label label) | |
| 429 { | |
| 430 _ilGenerator.Emit(OpCodes.Ble, label); return this; | |
| 431 } | |
| 432 | |
| 433 /// <summary> | |
| 434 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ble_S"/>, label) that | |
| 435 /// transfers control to a target instruction (short form) if the first value is less than or equal to the second value. | |
| 436 /// </summary> | |
| 437 /// <param name="label">The label to branch from this location.</param> | |
| 438 /// <seealso cref="OpCodes.Ble_S">OpCodes.Ble_S</seealso> | |
| 439 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 440 public EmitHelper ble_s(Label label) | |
| 441 { | |
| 442 _ilGenerator.Emit(OpCodes.Ble_S, label); return this; | |
| 443 } | |
| 444 | |
| 445 /// <summary> | |
| 446 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ble_Un"/>, label) that | |
| 447 /// transfers control to a target instruction if the first value is less than or equal to the second value, | |
| 448 /// when comparing unsigned integer values or unordered float values. | |
| 449 /// </summary> | |
| 450 /// <param name="label">The label to branch from this location.</param> | |
| 451 /// <seealso cref="OpCodes.Ble_Un">OpCodes.Ble_Un</seealso> | |
| 452 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 453 public EmitHelper ble_un(Label label) | |
| 454 { | |
| 455 _ilGenerator.Emit(OpCodes.Ble_Un, label); return this; | |
| 456 } | |
| 457 | |
| 458 /// <summary> | |
| 459 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ble_Un_S"/>, label) that | |
| 460 /// transfers control to a target instruction (short form) if the first value is less than or equal to the second value, | |
| 461 /// when comparing unsigned integer values or unordered float values. | |
| 462 /// </summary> | |
| 463 /// <param name="label">The label to branch from this location.</param> | |
| 464 /// <seealso cref="OpCodes.Ble_Un_S">OpCodes.Ble_Un_S</seealso> | |
| 465 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 466 public EmitHelper ble_un_s(Label label) | |
| 467 { | |
| 468 _ilGenerator.Emit(OpCodes.Ble_Un_S, label); return this; | |
| 469 } | |
| 470 | |
| 471 /// <summary> | |
| 472 /// Calls ILGenerator.Emit(<see cref="OpCodes.Blt"/>, label) that | |
| 473 /// transfers control to a target instruction if the first value is less than the second value. | |
| 474 /// </summary> | |
| 475 /// <param name="label">The label to branch from this location.</param> | |
| 476 /// <seealso cref="OpCodes.Blt">OpCodes.Blt</seealso> | |
| 477 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 478 public EmitHelper blt(Label label) | |
| 479 { | |
| 480 _ilGenerator.Emit(OpCodes.Blt, label); return this; | |
| 481 } | |
| 482 | |
| 483 /// <summary> | |
| 484 /// Calls ILGenerator.Emit(<see cref="OpCodes.Blt_S"/>, label) that | |
| 485 /// transfers control to a target instruction (short form) if the first value is less than the second value. | |
| 486 /// </summary> | |
| 487 /// <param name="label">The label to branch from this location.</param> | |
| 488 /// <seealso cref="OpCodes.Blt_S">OpCodes.Blt_S</seealso> | |
| 489 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 490 public EmitHelper blt_s(Label label) | |
| 491 { | |
| 492 _ilGenerator.Emit(OpCodes.Blt_S, label); return this; | |
| 493 } | |
| 494 | |
| 495 /// <summary> | |
| 496 /// Calls ILGenerator.Emit(<see cref="OpCodes.Blt_Un"/>, label) that | |
| 497 /// transfers control to a target instruction if the first value is less than the second value, | |
| 498 /// when comparing unsigned integer values or unordered float values. | |
| 499 /// </summary> | |
| 500 /// <param name="label">The label to branch from this location.</param> | |
| 501 /// <seealso cref="OpCodes.Blt_Un">OpCodes.Blt_Un</seealso> | |
| 502 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 503 public EmitHelper blt_un(Label label) | |
| 504 { | |
| 505 _ilGenerator.Emit(OpCodes.Blt_Un, label); return this; | |
| 506 } | |
| 507 | |
| 508 /// <summary> | |
| 509 /// Calls ILGenerator.Emit(<see cref="OpCodes.Blt_Un_S"/>, label) that | |
| 510 /// transfers control to a target instruction (short form) if the first value is less than the second value, | |
| 511 /// when comparing unsigned integer values or unordered float values. | |
| 512 /// </summary> | |
| 513 /// <param name="label">The label to branch from this location.</param> | |
| 514 /// <seealso cref="OpCodes.Blt_Un_S">OpCodes.Blt_Un_S</seealso> | |
| 515 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 516 public EmitHelper blt_un_s(Label label) | |
| 517 { | |
| 518 _ilGenerator.Emit(OpCodes.Blt_Un_S, label); return this; | |
| 519 } | |
| 520 | |
| 521 /// <summary> | |
| 522 /// Calls ILGenerator.Emit(<see cref="OpCodes.Bne_Un"/>, label) that | |
| 523 /// transfers control to a target instruction when two unsigned integer values or unordered float values are not equal. | |
| 524 /// </summary> | |
| 525 /// <param name="label">The label to branch from this location.</param> | |
| 526 /// <seealso cref="OpCodes.Bne_Un">OpCodes.Bne_Un</seealso> | |
| 527 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 528 public EmitHelper bne_un(Label label) | |
| 529 { | |
| 530 _ilGenerator.Emit(OpCodes.Bne_Un, label); return this; | |
| 531 } | |
| 532 | |
| 533 /// <summary> | |
| 534 /// Calls ILGenerator.Emit(<see cref="OpCodes.Bne_Un_S"/>, label) that | |
| 535 /// transfers control to a target instruction (short form) | |
| 536 /// when two unsigned integer values or unordered float values are not equal. | |
| 537 /// </summary> | |
| 538 /// <param name="label">The label to branch from this location.</param> | |
| 539 /// <seealso cref="OpCodes.Bne_Un_S">OpCodes.Bne_Un_S</seealso> | |
| 540 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 541 public EmitHelper bne_un_s(Label label) | |
| 542 { | |
| 543 _ilGenerator.Emit(OpCodes.Bne_Un_S, label); return this; | |
| 544 } | |
| 545 | |
| 546 /// <summary> | |
| 547 /// Calls ILGenerator.Emit(<see cref="OpCodes.Box"/>, type) that | |
| 548 /// converts a value type to an object reference. | |
| 549 /// </summary> | |
| 550 /// <param name="type">A Type</param> | |
| 551 /// <seealso cref="OpCodes.Box">OpCodes.Box</seealso> | |
| 552 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 553 public EmitHelper box(Type type) | |
| 554 { | |
| 555 _ilGenerator.Emit(OpCodes.Box, type); return this; | |
| 556 } | |
| 557 | |
| 558 /// <summary> | |
| 559 /// Converts a value type to an object reference if the value is a value type. | |
| 560 /// </summary> | |
| 561 /// <param name="type">A Type</param> | |
| 562 /// <seealso cref="OpCodes.Box">OpCodes.Box</seealso> | |
| 563 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 564 public EmitHelper boxIfValueType(Type type) | |
| 565 { | |
| 566 if (type == null) throw new ArgumentNullException("type"); | |
| 567 | |
| 568 return type.IsValueType? box(type): this; | |
| 569 } | |
| 570 | |
| 571 /// <summary> | |
| 572 /// Calls ILGenerator.Emit(<see cref="OpCodes.Br"/>, label) that | |
| 573 /// unconditionally transfers control to a target instruction. | |
| 574 /// </summary> | |
| 575 /// <param name="label">The label to branch from this location.</param> | |
| 576 /// <seealso cref="OpCodes.Br">OpCodes.Br</seealso> | |
| 577 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 578 public EmitHelper br(Label label) | |
| 579 { | |
| 580 _ilGenerator.Emit(OpCodes.Br, label); return this; | |
| 581 } | |
| 582 | |
| 583 /// <summary> | |
| 584 /// Calls ILGenerator.Emit(<see cref="OpCodes.Break"/>) that | |
| 585 /// signals the Common Language Infrastructure (CLI) to inform the debugger that a break point has been tripped. | |
| 586 /// </summary> | |
| 587 /// <seealso cref="OpCodes.Break">OpCodes.Break</seealso> | |
| 588 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 589 public EmitHelper @break | |
| 590 { | |
| 591 get { _ilGenerator.Emit(OpCodes.Break); return this; } | |
| 592 } | |
| 593 | |
| 594 /// <summary> | |
| 595 /// Calls ILGenerator.Emit(<see cref="OpCodes.Brfalse"/>, label) that | |
| 596 /// transfers control to a target instruction if value is false, a null reference (Nothing in Visual Basic), or zero. | |
| 597 /// </summary> | |
| 598 /// <param name="label">The label to branch from this location.</param> | |
| 599 /// <seealso cref="OpCodes.Brfalse">OpCodes.Brfalse</seealso> | |
| 600 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 601 public EmitHelper brfalse(Label label) | |
| 602 { | |
| 603 _ilGenerator.Emit(OpCodes.Brfalse, label); return this; | |
| 604 } | |
| 605 | |
| 606 /// <summary> | |
| 607 /// Calls ILGenerator.Emit(<see cref="OpCodes.Brfalse_S"/>, label) that | |
| 608 /// transfers control to a target instruction if value is false, a null reference, or zero. | |
| 609 /// </summary> | |
| 610 /// <param name="label">The label to branch from this location.</param> | |
| 611 /// <seealso cref="OpCodes.Brfalse_S">OpCodes.Brfalse_S</seealso> | |
| 612 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 613 public EmitHelper brfalse_s(Label label) | |
| 614 { | |
| 615 _ilGenerator.Emit(OpCodes.Brfalse_S, label); return this; | |
| 616 } | |
| 617 | |
| 618 /// <summary> | |
| 619 /// Calls ILGenerator.Emit(<see cref="OpCodes.Brtrue"/>, label) that | |
| 620 /// transfers control to a target instruction if value is true, not null, or non-zero. | |
| 621 /// </summary> | |
| 622 /// <param name="label">The label to branch from this location.</param> | |
| 623 /// <seealso cref="OpCodes.Brtrue">OpCodes.Brtrue</seealso> | |
| 624 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 625 public EmitHelper brtrue(Label label) | |
| 626 { | |
| 627 _ilGenerator.Emit(OpCodes.Brtrue, label); return this; | |
| 628 } | |
| 629 | |
| 630 /// <summary> | |
| 631 /// Calls ILGenerator.Emit(<see cref="OpCodes.Brtrue_S"/>, label) that | |
| 632 /// transfers control to a target instruction (short form) if value is true, not null, or non-zero. | |
| 633 /// </summary> | |
| 634 /// <param name="label">The label to branch from this location.</param> | |
| 635 /// <seealso cref="OpCodes.Brtrue_S">OpCodes.Brtrue_S</seealso> | |
| 636 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 637 public EmitHelper brtrue_s(Label label) | |
| 638 { | |
| 639 _ilGenerator.Emit(OpCodes.Brtrue_S, label); return this; | |
| 640 } | |
| 641 | |
| 642 /// <summary> | |
| 643 /// Calls ILGenerator.Emit(<see cref="OpCodes.Br_S"/>, label) that | |
| 644 /// unconditionally transfers control to a target instruction (short form). | |
| 645 /// </summary> | |
| 646 /// <param name="label">The label to branch from this location.</param> | |
| 647 /// <seealso cref="OpCodes.Br_S">OpCodes.Br_S</seealso> | |
| 648 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 649 public EmitHelper br_s(Label label) | |
| 650 { | |
| 651 _ilGenerator.Emit(OpCodes.Br_S, label); return this; | |
| 652 } | |
| 653 | |
| 654 /// <summary> | |
| 655 /// Calls ILGenerator.Emit(<see cref="OpCodes.Call"/>, methodInfo) that | |
| 656 /// calls the method indicated by the passed method descriptor. | |
| 657 /// </summary> | |
| 658 /// <param name="methodInfo">The method to be called.</param> | |
| 659 /// <seealso cref="OpCodes.Call">OpCodes.Call</seealso> | |
| 660 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,MethodInfo)">ILGenerator.Emit</seealso> | |
| 661 public EmitHelper call(MethodInfo methodInfo) | |
| 662 { | |
| 663 _ilGenerator.Emit(OpCodes.Call, methodInfo); return this; | |
| 664 } | |
| 665 | |
| 666 /// <summary> | |
| 667 /// Calls ILGenerator.Emit(<see cref="OpCodes.Call"/>, constructorInfo) that | |
| 668 /// calls the method indicated by the passed method descriptor. | |
| 669 /// </summary> | |
| 670 /// <param name="constructorInfo">The constructor to be called.</param> | |
| 671 /// <seealso cref="OpCodes.Call">OpCodes.Call</seealso> | |
| 672 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,MethodInfo)">ILGenerator.Emit</seealso> | |
| 673 public EmitHelper call(ConstructorInfo constructorInfo) | |
| 674 { | |
| 675 _ilGenerator.Emit(OpCodes.Call, constructorInfo); return this; | |
| 676 } | |
| 677 | |
| 678 /// <summary> | |
| 679 /// Calls ILGenerator.EmitCall(<see cref="OpCodes.Call"/>, methodInfo, optionalParameterTypes) that | |
| 680 /// calls the method indicated by the passed method descriptor. | |
| 681 /// </summary> | |
| 682 /// <param name="methodInfo">The method to be called.</param> | |
| 683 /// <param name="optionalParameterTypes">The types of the optional arguments if the method is a varargs method.</param> | |
| 684 /// <seealso cref="OpCodes.Call">OpCodes.Call</seealso> | |
| 685 /// <seealso cref="System.Reflection.Emit.ILGenerator.EmitCall(OpCode,MethodInfo,Type[])">ILGenerator.EmitCall</seealso> | |
| 686 public EmitHelper call(MethodInfo methodInfo, Type[] optionalParameterTypes) | |
| 687 { | |
| 688 _ilGenerator.EmitCall(OpCodes.Call, methodInfo, optionalParameterTypes); return this; | |
| 689 } | |
| 690 | |
| 691 /// <summary> | |
| 692 /// Calls ILGenerator.EmitCall(<see cref="OpCodes.Call"/>, methodInfo, optionalParameterTypes) that | |
| 693 /// calls the method indicated by the passed method descriptor. | |
| 694 /// </summary> | |
| 695 /// <param name="type">A Type</param> | |
| 696 /// <param name="methodName">The name of the method to be called.</param> | |
| 697 /// <param name="optionalParameterTypes">The types of the optional arguments if the method is a varargs method.</param> | |
| 698 /// <seealso cref="OpCodes.Call">OpCodes.Call</seealso> | |
| 699 /// <seealso cref="System.Reflection.Emit.ILGenerator.EmitCall(OpCode,MethodInfo,Type[])">ILGenerator.EmitCall</seealso> | |
| 700 public EmitHelper call(Type type, string methodName, params Type[] optionalParameterTypes) | |
| 701 { | |
| 702 if (type == null) throw new ArgumentNullException("type"); | |
| 703 | |
| 704 MethodInfo methodInfo = type.GetMethod(methodName, optionalParameterTypes); | |
| 705 | |
| 706 if (methodInfo == null) | |
| 707 throw CreateNoSuchMethodException(type, methodName); | |
| 708 | |
| 709 return call(methodInfo); | |
| 710 } | |
| 711 | |
| 712 /// <summary> | |
| 713 /// Calls ILGenerator.EmitCall(<see cref="OpCodes.Call"/>, methodInfo, optionalParameterTypes) that | |
| 714 /// calls the method indicated by the passed method descriptor. | |
| 715 /// </summary> | |
| 716 /// <param name="type">A Type</param> | |
| 717 /// <param name="methodName">The name of the method to be called.</param> | |
| 718 /// <param name="flags">A bitmask comprised of one or more <see cref="BindingFlags"/> | |
| 719 /// that specify how the search is conducted.</param> | |
| 720 /// <param name="optionalParameterTypes">The types of the optional arguments if the method is a varargs method.</param> | |
| 721 /// <seealso cref="OpCodes.Call">OpCodes.Call</seealso> | |
| 722 /// <seealso cref="System.Reflection.Emit.ILGenerator.EmitCall(OpCode,MethodInfo,Type[])">ILGenerator.EmitCall</seealso> | |
| 723 public EmitHelper call(Type type, string methodName, BindingFlags flags, params Type[] optionalParameterTypes) | |
| 724 { | |
| 725 if (type == null) throw new ArgumentNullException("type"); | |
| 726 | |
| 727 MethodInfo methodInfo = type.GetMethod(methodName, flags, null, optionalParameterTypes, null); | |
| 728 | |
| 729 if (methodInfo == null) | |
| 730 throw CreateNoSuchMethodException(type, methodName); | |
| 731 | |
| 732 return call(methodInfo); | |
| 733 } | |
| 734 | |
| 735 #if !SILVERLIGHT | |
| 736 | |
| 737 /// <summary> | |
| 738 /// Calls ILGenerator.EmitCalli(<see cref="OpCodes.Calli"/>, <see cref="CallingConvention"/>, Type, Type[]) that | |
| 739 /// calls the method indicated on the evaluation stack (as a pointer to an entry point) | |
| 740 /// with arguments described by a calling convention using an unmanaged calling convention. | |
| 741 /// </summary> | |
| 742 /// <param name="unmanagedCallConv">The unmanaged calling convention to be used.</param> | |
| 743 /// <param name="returnType">The Type of the result.</param> | |
| 744 /// <param name="parameterTypes">The types of the required arguments to the instruction.</param> | |
| 745 /// <seealso cref="OpCodes.Calli">OpCodes.Calli</seealso> | |
| 746 /// <seealso cref="System.Reflection.Emit.ILGenerator.EmitCalli(OpCode,CallingConvention,Type,Type[])">ILGenerator.EmitCalli</seealso> | |
| 747 public EmitHelper calli(CallingConvention unmanagedCallConv, Type returnType, Type[] parameterTypes) | |
| 748 { | |
| 749 _ilGenerator.EmitCalli(OpCodes.Calli, unmanagedCallConv, returnType, parameterTypes); | |
| 750 return this; | |
| 751 } | |
| 752 | |
| 753 /// <summary> | |
| 754 /// Calls ILGenerator.EmitCalli(<see cref="OpCodes.Calli"/>, <see cref="CallingConvention"/>, Type, Type[], Type[]) that | |
| 755 /// calls the method indicated on the evaluation stack (as a pointer to an entry point) | |
| 756 /// with arguments described by a calling convention using a managed calling convention. | |
| 757 /// </summary> | |
| 758 /// <param name="callingConvention">The managed calling convention to be used.</param> | |
| 759 /// <param name="returnType">The Type of the result.</param> | |
| 760 /// <param name="parameterTypes">The types of the required arguments to the instruction.</param> | |
| 761 /// <param name="optionalParameterTypes">The types of the optional arguments for vararg calls.</param> | |
| 762 /// <seealso cref="OpCodes.Calli">OpCodes.Calli</seealso> | |
| 763 /// <seealso cref="System.Reflection.Emit.ILGenerator.EmitCalli(OpCode,CallingConventions,Type,Type[],Type[])">ILGenerator.EmitCalli</seealso> | |
| 764 public EmitHelper calli(CallingConventions callingConvention, Type returnType, Type[] parameterTypes, Type[] optionalParameterTypes) | |
| 765 { | |
| 766 _ilGenerator.EmitCalli(OpCodes.Calli, callingConvention, returnType, parameterTypes, optionalParameterTypes); | |
| 767 return this; | |
| 768 } | |
| 769 | |
| 770 #endif | |
| 771 | |
| 772 /// <summary> | |
| 773 /// Calls ILGenerator.Emit(<see cref="OpCodes.Callvirt"/>, methodInfo) that | |
| 774 /// calls a late-bound method on an object, pushing the return value onto the evaluation stack. | |
| 775 /// </summary> | |
| 776 /// <param name="methodInfo">The method to be called.</param> | |
| 777 /// <seealso cref="OpCodes.Callvirt">OpCodes.Callvirt</seealso> | |
| 778 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,MethodInfo)">ILGenerator.Emit</seealso> | |
| 779 public EmitHelper callvirt(MethodInfo methodInfo) | |
| 780 { | |
| 781 _ilGenerator.Emit(OpCodes.Callvirt, methodInfo); return this; | |
| 782 } | |
| 783 | |
| 784 /// <summary> | |
| 785 /// Calls ILGenerator.EmitCall(<see cref="OpCodes.Callvirt"/>, methodInfo, optionalParameterTypes) that | |
| 786 /// calls a late-bound method on an object, pushing the return value onto the evaluation stack. | |
| 787 /// </summary> | |
| 788 /// <param name="methodInfo">The method to be called.</param> | |
| 789 /// <param name="optionalParameterTypes">The types of the optional arguments if the method is a varargs method.</param> | |
| 790 /// <seealso cref="OpCodes.Callvirt">OpCodes.Callvirt</seealso> | |
| 791 /// <seealso cref="System.Reflection.Emit.ILGenerator.EmitCall(OpCode,MethodInfo,Type[])">ILGenerator.EmitCall</seealso> | |
| 792 public EmitHelper callvirt(MethodInfo methodInfo, Type[] optionalParameterTypes) | |
| 793 { | |
| 794 _ilGenerator.EmitCall(OpCodes.Callvirt, methodInfo, optionalParameterTypes); return this; | |
| 795 } | |
| 796 | |
| 797 /// <summary> | |
| 798 /// Calls ILGenerator.EmitCall(<see cref="OpCodes.Callvirt"/>, methodInfo, optionalParameterTypes) that | |
| 799 /// calls a late-bound method on an object, pushing the return value onto the evaluation stack. | |
| 800 /// </summary> | |
| 801 /// <param name="methodName">The method to be called.</param> | |
| 802 /// <param name="type">The declaring type of the method.</param> | |
| 803 /// <param name="optionalParameterTypes">The types of the optional arguments if the method is a varargs method.</param> | |
| 804 /// <seealso cref="OpCodes.Callvirt">OpCodes.Callvirt</seealso> | |
| 805 /// <seealso cref="System.Reflection.Emit.ILGenerator.EmitCall(OpCode,MethodInfo,Type[])">ILGenerator.EmitCall</seealso> | |
| 806 public EmitHelper callvirt(Type type, string methodName, params Type[] optionalParameterTypes) | |
| 807 { | |
| 808 if (type == null) throw new ArgumentNullException("type"); | |
| 809 | |
| 810 MethodInfo methodInfo = type.GetMethod(methodName, optionalParameterTypes); | |
| 811 | |
| 812 if (methodInfo == null) | |
| 813 throw CreateNoSuchMethodException(type, methodName); | |
| 814 | |
| 815 return callvirt(methodInfo); | |
| 816 } | |
| 817 | |
| 818 /// <summary> | |
| 819 /// Calls ILGenerator.EmitCall(<see cref="OpCodes.Callvirt"/>, methodInfo, optionalParameterTypes) that | |
| 820 /// calls a late-bound method on an object, pushing the return value onto the evaluation stack. | |
| 821 /// </summary> | |
| 822 /// <param name="methodName">The method to be called.</param> | |
| 823 /// <param name="type">The declaring type of the method.</param> | |
| 824 /// <param name="flags">A bitmask comprised of one or more <see cref="BindingFlags"/> | |
| 825 /// that specify how the search is conducted.</param> | |
| 826 /// <param name="optionalParameterTypes">The types of the optional arguments if the method is a varargs method.</param> | |
| 827 /// <seealso cref="OpCodes.Callvirt">OpCodes.Callvirt</seealso> | |
| 828 /// <seealso cref="System.Reflection.Emit.ILGenerator.EmitCall(OpCode,MethodInfo,Type[])">ILGenerator.EmitCall</seealso> | |
| 829 public EmitHelper callvirt(Type type, string methodName, BindingFlags flags, params Type[] optionalParameterTypes) | |
| 830 { | |
| 831 MethodInfo methodInfo = | |
| 832 optionalParameterTypes == null? | |
| 833 type.GetMethod(methodName, flags): | |
| 834 type.GetMethod(methodName, flags, null, optionalParameterTypes, null); | |
| 835 | |
| 836 if (methodInfo == null) | |
| 837 throw CreateNoSuchMethodException(type, methodName); | |
| 838 | |
| 839 return callvirt(methodInfo, null); | |
| 840 } | |
| 841 | |
| 842 /// <summary> | |
| 843 /// Calls ILGenerator.EmitCall(<see cref="OpCodes.Callvirt"/>, methodInfo, optionalParameterTypes) that | |
| 844 /// calls a late-bound method on an object, pushing the return value onto the evaluation stack. | |
| 845 /// </summary> | |
| 846 /// <param name="methodName">The method to be called.</param> | |
| 847 /// <param name="type">The declaring type of the method.</param> | |
| 848 /// <param name="flags">A bitmask comprised of one or more <see cref="BindingFlags"/> | |
| 849 /// that specify how the search is conducted.</param> | |
| 850 /// <seealso cref="OpCodes.Callvirt">OpCodes.Callvirt</seealso> | |
| 851 /// <seealso cref="System.Reflection.Emit.ILGenerator.EmitCall(OpCode,MethodInfo,Type[])">ILGenerator.EmitCall</seealso> | |
| 852 public EmitHelper callvirt(Type type, string methodName, BindingFlags flags) | |
| 853 { | |
| 854 return callvirt(type, methodName, flags, null); | |
| 855 } | |
| 856 | |
| 857 /// <summary> | |
| 858 /// Calls ILGenerator.EmitCall(<see cref="OpCodes.Callvirt"/>, methodInfo, optionalParameterTypes) that | |
| 859 /// calls a late-bound method on an object, pushing the return value onto the evaluation stack. | |
| 860 /// </summary> | |
| 861 /// <param name="methodName">The non-generic method to be called.</param> | |
| 862 /// <param name="type">The declaring type of the method.</param> | |
| 863 /// <param name="optionalParameterTypes">The types of the optional arguments if the method is a varargs method.</param> | |
| 864 /// <seealso cref="OpCodes.Callvirt">OpCodes.Callvirt</seealso> | |
| 865 /// <seealso cref="System.Reflection.Emit.ILGenerator.EmitCall(OpCode,MethodInfo,Type[])">ILGenerator.EmitCall</seealso> | |
| 866 public EmitHelper callvirtNoGenerics(Type type, string methodName, params Type[] optionalParameterTypes) | |
| 867 { | |
| 868 MethodInfo methodInfo = type.GetMethod( | |
| 869 methodName, | |
| 870 BindingFlags.Instance | BindingFlags.Public, | |
| 871 GenericBinder.NonGeneric, | |
| 872 optionalParameterTypes, null); | |
| 873 | |
| 874 if (methodInfo == null) | |
| 875 throw CreateNoSuchMethodException(type, methodName); | |
| 876 | |
| 877 return callvirt(methodInfo); | |
| 878 } | |
| 879 | |
| 880 /// <summary> | |
| 881 /// Calls ILGenerator.Emit(<see cref="OpCodes.Castclass"/>, type) that | |
| 882 /// attempts to cast an object passed by reference to the specified class. | |
| 883 /// </summary> | |
| 884 /// <param name="type">A Type</param> | |
| 885 /// <seealso cref="OpCodes.Castclass">OpCodes.Castclass</seealso> | |
| 886 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 887 public EmitHelper castclass(Type type) | |
| 888 { | |
| 889 _ilGenerator.Emit(OpCodes.Castclass, type); return this; | |
| 890 } | |
| 891 | |
| 892 /// <summary> | |
| 893 /// Attempts to cast an object passed by reference to the specified class | |
| 894 /// or to unbox if the type is a value type. | |
| 895 /// </summary> | |
| 896 /// <param name="type">A Type</param> | |
| 897 public EmitHelper castType(Type type) | |
| 898 { | |
| 899 if (type == null) throw new ArgumentNullException("type"); | |
| 900 | |
| 901 return type.IsValueType? unbox_any(type): castclass(type); | |
| 902 } | |
| 903 | |
| 904 /// <summary> | |
| 905 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ceq"/>) that | |
| 906 /// compares two values. If they are equal, the integer value 1 (int32) is pushed onto the evaluation stack; | |
| 907 /// otherwise 0 (int32) is pushed onto the evaluation stack. | |
| 908 /// </summary> | |
| 909 /// <seealso cref="OpCodes.Ceq">OpCodes.Ceq</seealso> | |
| 910 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 911 public EmitHelper ceq | |
| 912 { | |
| 913 get { _ilGenerator.Emit(OpCodes.Ceq); return this; } | |
| 914 } | |
| 915 | |
| 916 /// <summary> | |
| 917 /// Calls ILGenerator.Emit(<see cref="OpCodes.Cgt"/>) that | |
| 918 /// compares two values. If the first value is greater than the second, | |
| 919 /// the integer value 1 (int32) is pushed onto the evaluation stack; | |
| 920 /// otherwise 0 (int32) is pushed onto the evaluation stack. | |
| 921 /// </summary> | |
| 922 /// <seealso cref="OpCodes.Cgt">OpCodes.Cgt</seealso> | |
| 923 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 924 public EmitHelper cgt | |
| 925 { | |
| 926 get { _ilGenerator.Emit(OpCodes.Cgt); return this; } | |
| 927 } | |
| 928 | |
| 929 /// <summary> | |
| 930 /// Calls ILGenerator.Emit(<see cref="OpCodes.Cgt_Un"/>) that | |
| 931 /// compares two unsigned or unordered values. | |
| 932 /// If the first value is greater than the second, the integer value 1 (int32) is pushed onto the evaluation stack; | |
| 933 /// otherwise 0 (int32) is pushed onto the evaluation stack. | |
| 934 /// </summary> | |
| 935 /// <seealso cref="OpCodes.Cgt_Un">OpCodes.Cgt_Un</seealso> | |
| 936 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 937 public EmitHelper cgt_un | |
| 938 { | |
| 939 get { _ilGenerator.Emit(OpCodes.Cgt_Un); return this; } | |
| 940 } | |
| 941 | |
| 942 /// <summary> | |
| 943 /// Calls ILGenerator.Emit(<see cref="OpCodes.Constrained"/>) that | |
| 944 /// constrains the type on which a virtual method call is made. | |
| 945 /// </summary> | |
| 946 /// <param name="type">A Type</param> | |
| 947 /// <seealso cref="OpCodes.Cgt_Un">OpCodes.Constrained</seealso> | |
| 948 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 949 public EmitHelper constrained(Type type) | |
| 950 { | |
| 951 _ilGenerator.Emit(OpCodes.Constrained, type); return this; | |
| 952 } | |
| 953 | |
| 954 /// <summary> | |
| 955 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ckfinite"/>) that | |
| 956 /// throws <see cref="ArithmeticException"/> if value is not a finite number. | |
| 957 /// </summary> | |
| 958 /// <seealso cref="OpCodes.Ckfinite">OpCodes.Ckfinite</seealso> | |
| 959 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 960 public EmitHelper ckfinite | |
| 961 { | |
| 962 get { _ilGenerator.Emit(OpCodes.Ckfinite); return this; } | |
| 963 } | |
| 964 | |
| 965 /// <summary> | |
| 966 /// Calls ILGenerator.Emit(<see cref="OpCodes.Clt"/>) that | |
| 967 /// compares two values. If the first value is less than the second, | |
| 968 /// the integer value 1 (int32) is pushed onto the evaluation stack; | |
| 969 /// otherwise 0 (int32) is pushed onto the evaluation stack. | |
| 970 /// </summary> | |
| 971 /// <seealso cref="OpCodes.Clt">OpCodes.Clt</seealso> | |
| 972 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 973 public EmitHelper clt | |
| 974 { | |
| 975 get { _ilGenerator.Emit(OpCodes.Clt); return this; } | |
| 976 } | |
| 977 | |
| 978 /// <summary> | |
| 979 /// Calls ILGenerator.Emit(<see cref="OpCodes.Clt_Un"/>) that | |
| 980 /// compares the unsigned or unordered values value1 and value2. | |
| 981 /// If value1 is less than value2, then the integer value 1 (int32) is pushed onto the evaluation stack; | |
| 982 /// otherwise 0 (int32) is pushed onto the evaluation stack. | |
| 983 /// </summary> | |
| 984 /// <seealso cref="OpCodes.Clt_Un">OpCodes.Clt_Un</seealso> | |
| 985 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 986 public EmitHelper clt_un | |
| 987 { | |
| 988 get { _ilGenerator.Emit(OpCodes.Clt_Un); return this; } | |
| 989 } | |
| 990 | |
| 991 /// <summary> | |
| 992 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_I"/>) that | |
| 993 /// converts the value on top of the evaluation stack to natural int. | |
| 994 /// </summary> | |
| 995 /// <seealso cref="OpCodes.Conv_I">OpCodes.Conv_I</seealso> | |
| 996 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 997 public EmitHelper conv_i | |
| 998 { | |
| 999 get { _ilGenerator.Emit(OpCodes.Conv_I); return this; } | |
| 1000 } | |
| 1001 | |
| 1002 /// <summary> | |
| 1003 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_I1"/>) that | |
| 1004 /// converts the value on top of the evaluation stack to int8, then extends (pads) it to int32. | |
| 1005 /// </summary> | |
| 1006 /// <seealso cref="OpCodes.Conv_I1">OpCodes.Conv_I1</seealso> | |
| 1007 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1008 public EmitHelper conv_i1 | |
| 1009 { | |
| 1010 get { _ilGenerator.Emit(OpCodes.Conv_I1); return this; } | |
| 1011 } | |
| 1012 | |
| 1013 /// <summary> | |
| 1014 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_I2"/>) that | |
| 1015 /// converts the value on top of the evaluation stack to int16, then extends (pads) it to int32. | |
| 1016 /// </summary> | |
| 1017 /// <seealso cref="OpCodes.Conv_I2">OpCodes.Conv_I2</seealso> | |
| 1018 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1019 public EmitHelper conv_i2 | |
| 1020 { | |
| 1021 get { _ilGenerator.Emit(OpCodes.Conv_I2); return this; } | |
| 1022 } | |
| 1023 | |
| 1024 /// <summary> | |
| 1025 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_I4"/>) that | |
| 1026 /// converts the value on top of the evaluation stack to int32. | |
| 1027 /// </summary> | |
| 1028 /// <seealso cref="OpCodes.Conv_I4">OpCodes.Conv_I4</seealso> | |
| 1029 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1030 public EmitHelper conv_i4 | |
| 1031 { | |
| 1032 get { _ilGenerator.Emit(OpCodes.Conv_I4); return this; } | |
| 1033 } | |
| 1034 | |
| 1035 /// <summary> | |
| 1036 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_I8"/>) that | |
| 1037 /// converts the value on top of the evaluation stack to int64. | |
| 1038 /// </summary> | |
| 1039 /// <seealso cref="OpCodes.Conv_I8">OpCodes.Conv_I8</seealso> | |
| 1040 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1041 public EmitHelper conv_i8 | |
| 1042 { | |
| 1043 get { _ilGenerator.Emit(OpCodes.Conv_I8); return this; } | |
| 1044 } | |
| 1045 | |
| 1046 /// <summary> | |
| 1047 /// Converts the value on top of the evaluation stack to the specified type. | |
| 1048 /// </summary> | |
| 1049 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1050 public EmitHelper conv(Type type) | |
| 1051 { | |
| 1052 if (type == null) throw new ArgumentNullException("type"); | |
| 1053 | |
| 1054 switch (Type.GetTypeCode(type)) | |
| 1055 { | |
| 1056 case TypeCode.Boolean: | |
| 1057 case TypeCode.SByte: conv_i1.end(); break; | |
| 1058 case TypeCode.Int16: conv_i2.end(); break; | |
| 1059 case TypeCode.Int32: conv_i4.end(); break; | |
| 1060 case TypeCode.Int64: conv_i8.end(); break; | |
| 1061 | |
| 1062 case TypeCode.Byte: conv_u1.end(); break; | |
| 1063 case TypeCode.Char: | |
| 1064 case TypeCode.UInt16: conv_u2.end(); break; | |
| 1065 case TypeCode.UInt32: conv_u4.end(); break; | |
| 1066 case TypeCode.UInt64: conv_u8.end(); break; | |
| 1067 | |
| 1068 case TypeCode.Single: conv_r4.end(); break; | |
| 1069 case TypeCode.Double: conv_r8.end(); break; | |
| 1070 | |
| 1071 default: | |
| 1072 { | |
| 1073 if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) | |
| 1074 { | |
| 1075 ConstructorInfo ci = type.GetConstructor(type.GetGenericArguments()); | |
| 1076 if (ci != null) | |
| 1077 { | |
| 1078 newobj(ci); | |
| 1079 break; | |
| 1080 } | |
| 1081 } | |
| 1082 | |
| 1083 throw CreateNotExpectedTypeException(type); | |
| 1084 } | |
| 1085 } | |
| 1086 | |
| 1087 return this; | |
| 1088 } | |
| 1089 | |
| 1090 | |
| 1091 /// <summary> | |
| 1092 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_I"/>) that | |
| 1093 /// converts the signed value on top of the evaluation stack to signed natural int, | |
| 1094 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1095 /// </summary> | |
| 1096 /// <seealso cref="OpCodes.Conv_Ovf_I">OpCodes.Conv_Ovf_I</seealso> | |
| 1097 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1098 public EmitHelper conv_ovf_i | |
| 1099 { | |
| 1100 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_I); return this; } | |
| 1101 } | |
| 1102 | |
| 1103 /// <summary> | |
| 1104 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_I1"/>) that | |
| 1105 /// converts the signed value on top of the evaluation stack to signed int8 and extends it to int32, | |
| 1106 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1107 /// </summary> | |
| 1108 /// <seealso cref="OpCodes.Conv_Ovf_I1">OpCodes.Conv_Ovf_I1</seealso> | |
| 1109 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1110 public EmitHelper conv_ovf_i1 | |
| 1111 { | |
| 1112 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_I1); return this; } | |
| 1113 } | |
| 1114 | |
| 1115 /// <summary> | |
| 1116 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_I1_Un"/>) that | |
| 1117 /// converts the unsigned value on top of the evaluation stack to signed int8 and extends it to int32, | |
| 1118 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1119 /// </summary> | |
| 1120 /// <seealso cref="OpCodes.Conv_Ovf_I1_Un">OpCodes.Conv_Ovf_I1_Un</seealso> | |
| 1121 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1122 public EmitHelper conv_ovf_i1_un | |
| 1123 { | |
| 1124 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_I1_Un); return this; } | |
| 1125 } | |
| 1126 | |
| 1127 /// <summary> | |
| 1128 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_I2"/>) that | |
| 1129 /// converts the signed value on top of the evaluation stack to signed int16 and extending it to int32, | |
| 1130 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1131 /// </summary> | |
| 1132 /// <seealso cref="OpCodes.Conv_Ovf_I2">OpCodes.Conv_Ovf_I2</seealso> | |
| 1133 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1134 public EmitHelper conv_ovf_i2 | |
| 1135 { | |
| 1136 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_I2); return this; } | |
| 1137 } | |
| 1138 | |
| 1139 /// <summary> | |
| 1140 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_I2_Un"/>) that | |
| 1141 /// converts the unsigned value on top of the evaluation stack to signed int16 and extends it to int32, | |
| 1142 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1143 /// </summary> | |
| 1144 /// <seealso cref="OpCodes.Conv_Ovf_I2_Un">OpCodes.Conv_Ovf_I2_Un</seealso> | |
| 1145 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1146 public EmitHelper conv_ovf_i2_un | |
| 1147 { | |
| 1148 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_I2_Un); return this; } | |
| 1149 } | |
| 1150 | |
| 1151 /// <summary> | |
| 1152 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_I4"/>) that | |
| 1153 /// converts the signed value on top of the evaluation tack to signed int32, throwing <see cref="OverflowException"/> on overflow. | |
| 1154 /// </summary> | |
| 1155 /// <seealso cref="OpCodes.Conv_Ovf_I4">OpCodes.Conv_Ovf_I4</seealso> | |
| 1156 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1157 public EmitHelper conv_ovf_i4 | |
| 1158 { | |
| 1159 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_I2_Un); return this; } | |
| 1160 } | |
| 1161 | |
| 1162 /// <summary> | |
| 1163 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_I4_Un"/>) that | |
| 1164 /// converts the unsigned value on top of the evaluation stack to signed int32, throwing <see cref="OverflowException"/> on overflow. | |
| 1165 /// </summary> | |
| 1166 /// <seealso cref="OpCodes.Conv_Ovf_I4_Un">OpCodes.Conv_Ovf_I4_Un</seealso> | |
| 1167 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1168 public EmitHelper conv_ovf_i4_un | |
| 1169 { | |
| 1170 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_I4_Un); return this; } | |
| 1171 } | |
| 1172 | |
| 1173 /// <summary> | |
| 1174 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_I8"/>) that | |
| 1175 /// converts the signed value on top of the evaluation stack to signed int64, | |
| 1176 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1177 /// </summary> | |
| 1178 /// <seealso cref="OpCodes.Conv_Ovf_I8">OpCodes.Conv_Ovf_I8</seealso> | |
| 1179 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1180 public EmitHelper conv_ovf_i8 | |
| 1181 { | |
| 1182 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_I8); return this; } | |
| 1183 } | |
| 1184 | |
| 1185 /// <summary> | |
| 1186 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_I8_Un"/>) that | |
| 1187 /// converts the unsigned value on top of the evaluation stack to signed int64, throwing <see cref="OverflowException"/> on overflow. | |
| 1188 /// </summary> | |
| 1189 /// <seealso cref="OpCodes.Conv_Ovf_I8_Un">OpCodes.Conv_Ovf_I8_Un</seealso> | |
| 1190 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1191 public EmitHelper conv_ovf_i8_un | |
| 1192 { | |
| 1193 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_I8_Un); return this; } | |
| 1194 } | |
| 1195 | |
| 1196 /// <summary> | |
| 1197 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_I_Un"/>) that | |
| 1198 /// converts the unsigned value on top of the evaluation stack to signed natural int, | |
| 1199 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1200 /// </summary> | |
| 1201 /// <seealso cref="OpCodes.Conv_Ovf_I_Un">OpCodes.Conv_Ovf_I_Un</seealso> | |
| 1202 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1203 public EmitHelper conv_ovf_i_un | |
| 1204 { | |
| 1205 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_I_Un); return this; } | |
| 1206 } | |
| 1207 | |
| 1208 /// <summary> | |
| 1209 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_U"/>) that | |
| 1210 /// converts the signed value on top of the evaluation stack to unsigned natural int, | |
| 1211 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1212 /// </summary> | |
| 1213 /// <seealso cref="OpCodes.Conv_Ovf_U">OpCodes.Conv_Ovf_U</seealso> | |
| 1214 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1215 public EmitHelper conv_ovf_u | |
| 1216 { | |
| 1217 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_U); return this; } | |
| 1218 } | |
| 1219 | |
| 1220 /// <summary> | |
| 1221 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_U1"/>) that | |
| 1222 /// converts the signed value on top of the evaluation stack to unsigned int8 and extends it to int32, | |
| 1223 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1224 /// </summary> | |
| 1225 /// <seealso cref="OpCodes.Conv_Ovf_U1">OpCodes.Conv_Ovf_U1</seealso> | |
| 1226 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1227 public EmitHelper conv_ovf_u1 | |
| 1228 { | |
| 1229 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_U1); return this; } | |
| 1230 } | |
| 1231 | |
| 1232 /// <summary> | |
| 1233 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_U1_Un"/>) that | |
| 1234 /// converts the unsigned value on top of the evaluation stack to unsigned int8 and extends it to int32, | |
| 1235 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1236 /// </summary> | |
| 1237 /// <seealso cref="OpCodes.Conv_Ovf_U1_Un">OpCodes.Conv_Ovf_U1_Un</seealso> | |
| 1238 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1239 public EmitHelper conv_ovf_u1_un | |
| 1240 { | |
| 1241 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_U1_Un); return this; } | |
| 1242 } | |
| 1243 | |
| 1244 /// <summary> | |
| 1245 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_U2"/>) that | |
| 1246 /// converts the signed value on top of the evaluation stack to unsigned int16 and extends it to int32, | |
| 1247 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1248 /// </summary> | |
| 1249 /// <seealso cref="OpCodes.Conv_Ovf_U2">OpCodes.Conv_Ovf_U2</seealso> | |
| 1250 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1251 public EmitHelper conv_ovf_u2 | |
| 1252 { | |
| 1253 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_U2); return this; } | |
| 1254 } | |
| 1255 | |
| 1256 /// <summary> | |
| 1257 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_U2_Un"/>) that | |
| 1258 /// converts the unsigned value on top of the evaluation stack to unsigned int16 and extends it to int32, | |
| 1259 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1260 /// </summary> | |
| 1261 /// <seealso cref="OpCodes.Conv_Ovf_U2_Un">OpCodes.Conv_Ovf_U2_Un</seealso> | |
| 1262 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1263 public EmitHelper conv_ovf_u2_un | |
| 1264 { | |
| 1265 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_U2_Un); return this; } | |
| 1266 } | |
| 1267 | |
| 1268 /// <summary> | |
| 1269 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_U4"/>) that | |
| 1270 /// Converts the signed value on top of the evaluation stack to unsigned int32, throwing <see cref="OverflowException"/> on overflow. | |
| 1271 /// </summary> | |
| 1272 /// <seealso cref="OpCodes.Conv_Ovf_U4">OpCodes.Conv_Ovf_U4</seealso> | |
| 1273 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1274 public EmitHelper conv_ovf_u4 | |
| 1275 { | |
| 1276 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_U4); return this; } | |
| 1277 } | |
| 1278 | |
| 1279 /// <summary> | |
| 1280 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_U4_Un"/>) that | |
| 1281 /// converts the unsigned value on top of the evaluation stack to unsigned int32, throwing <see cref="OverflowException"/> on overflow. | |
| 1282 /// </summary> | |
| 1283 /// <seealso cref="OpCodes.Conv_Ovf_U4_Un">OpCodes.Conv_Ovf_U4_Un</seealso> | |
| 1284 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1285 public EmitHelper conv_ovf_u4_un | |
| 1286 { | |
| 1287 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_U4_Un); return this; } | |
| 1288 } | |
| 1289 | |
| 1290 /// <summary> | |
| 1291 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_U8"/>) that | |
| 1292 /// converts the signed value on top of the evaluation stack to unsigned int64, throwing <see cref="OverflowException"/> on overflow. | |
| 1293 /// </summary> | |
| 1294 /// <seealso cref="OpCodes.Conv_Ovf_U8">OpCodes.Conv_Ovf_U8</seealso> | |
| 1295 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1296 public EmitHelper conv_ovf_u8 | |
| 1297 { | |
| 1298 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_U8); return this; } | |
| 1299 } | |
| 1300 | |
| 1301 /// <summary> | |
| 1302 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_U8_Un"/>) that | |
| 1303 /// converts the unsigned value on top of the evaluation stack to unsigned int64, throwing <see cref="OverflowException"/> on overflow. | |
| 1304 /// </summary> | |
| 1305 /// <seealso cref="OpCodes.Conv_Ovf_U8_Un">OpCodes.Conv_Ovf_U8_Un</seealso> | |
| 1306 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1307 public EmitHelper conv_ovf_u8_un | |
| 1308 { | |
| 1309 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_U8_Un); return this; } | |
| 1310 } | |
| 1311 | |
| 1312 /// <summary> | |
| 1313 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_Ovf_U_Un"/>) that | |
| 1314 /// converts the unsigned value on top of the evaluation stack to unsigned natural int, | |
| 1315 /// throwing <see cref="OverflowException"/> on overflow. | |
| 1316 /// </summary> | |
| 1317 /// <seealso cref="OpCodes.Conv_Ovf_U_Un">OpCodes.Conv_Ovf_U_Un</seealso> | |
| 1318 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1319 public EmitHelper conv_ovf_u_un | |
| 1320 { | |
| 1321 get { _ilGenerator.Emit(OpCodes.Conv_Ovf_U_Un); return this; } | |
| 1322 } | |
| 1323 | |
| 1324 /// <summary> | |
| 1325 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_R4"/>) that | |
| 1326 /// converts the value on top of the evaluation stack to float32. | |
| 1327 /// </summary> | |
| 1328 /// <seealso cref="OpCodes.Conv_R4">OpCodes.Conv_R4</seealso> | |
| 1329 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1330 public EmitHelper conv_r4 | |
| 1331 { | |
| 1332 get { _ilGenerator.Emit(OpCodes.Conv_R4); return this; } | |
| 1333 } | |
| 1334 | |
| 1335 /// <summary> | |
| 1336 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_R8"/>) that | |
| 1337 /// converts the value on top of the evaluation stack to float64. | |
| 1338 /// </summary> | |
| 1339 /// <seealso cref="OpCodes.Conv_R8">OpCodes.Conv_R8</seealso> | |
| 1340 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1341 public EmitHelper conv_r8 | |
| 1342 { | |
| 1343 get { _ilGenerator.Emit(OpCodes.Conv_R8); return this; } | |
| 1344 } | |
| 1345 | |
| 1346 /// <summary> | |
| 1347 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_R_Un"/>) that | |
| 1348 /// converts the unsigned integer value on top of the evaluation stack to float32. | |
| 1349 /// </summary> | |
| 1350 /// <seealso cref="OpCodes.Conv_R_Un">OpCodes.Conv_R_Un</seealso> | |
| 1351 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1352 public EmitHelper conv_r_un | |
| 1353 { | |
| 1354 get { _ilGenerator.Emit(OpCodes.Conv_R_Un); return this; } | |
| 1355 } | |
| 1356 | |
| 1357 /// <summary> | |
| 1358 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_U"/>) that | |
| 1359 /// converts the value on top of the evaluation stack to unsigned natural int, and extends it to natural int. | |
| 1360 /// </summary> | |
| 1361 /// <seealso cref="OpCodes.Conv_U">OpCodes.Conv_U</seealso> | |
| 1362 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1363 public EmitHelper conv_u | |
| 1364 { | |
| 1365 get { _ilGenerator.Emit(OpCodes.Conv_U); return this; } | |
| 1366 } | |
| 1367 | |
| 1368 /// <summary> | |
| 1369 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_U1"/>) that | |
| 1370 /// converts the value on top of the evaluation stack to unsigned int8, and extends it to int32. | |
| 1371 /// </summary> | |
| 1372 /// <seealso cref="OpCodes.Conv_U1">OpCodes.Conv_U1</seealso> | |
| 1373 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1374 public EmitHelper conv_u1 | |
| 1375 { | |
| 1376 get { _ilGenerator.Emit(OpCodes.Conv_U1); return this; } | |
| 1377 } | |
| 1378 | |
| 1379 /// <summary> | |
| 1380 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_U2"/>) that | |
| 1381 /// converts the value on top of the evaluation stack to unsigned int16, and extends it to int32. | |
| 1382 /// </summary> | |
| 1383 /// <seealso cref="OpCodes.Conv_U2">OpCodes.Conv_U2</seealso> | |
| 1384 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1385 public EmitHelper conv_u2 | |
| 1386 { | |
| 1387 get { _ilGenerator.Emit(OpCodes.Conv_U2); return this; } | |
| 1388 } | |
| 1389 | |
| 1390 /// <summary> | |
| 1391 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_U4"/>) that | |
| 1392 /// converts the value on top of the evaluation stack to unsigned int32, and extends it to int32. | |
| 1393 /// </summary> | |
| 1394 /// <seealso cref="OpCodes.Conv_U4">OpCodes.Conv_U4</seealso> | |
| 1395 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1396 public EmitHelper conv_u4 | |
| 1397 { | |
| 1398 get { _ilGenerator.Emit(OpCodes.Conv_U4); return this; } | |
| 1399 } | |
| 1400 | |
| 1401 /// <summary> | |
| 1402 /// Calls ILGenerator.Emit(<see cref="OpCodes.Conv_U8"/>) that | |
| 1403 /// converts the value on top of the evaluation stack to unsigned int64, and extends it to int64. | |
| 1404 /// </summary> | |
| 1405 /// <seealso cref="OpCodes.Conv_U8">OpCodes.Conv_U8</seealso> | |
| 1406 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1407 public EmitHelper conv_u8 | |
| 1408 { | |
| 1409 get { _ilGenerator.Emit(OpCodes.Conv_U8); return this; } | |
| 1410 } | |
| 1411 | |
| 1412 /// <summary> | |
| 1413 /// Calls ILGenerator.Emit(<see cref="OpCodes.Cpblk"/>) that | |
| 1414 /// copies a specified number bytes from a source address to a destination address. | |
| 1415 /// </summary> | |
| 1416 /// <seealso cref="OpCodes.Cpblk">OpCodes.Cpblk</seealso> | |
| 1417 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1418 public EmitHelper cpblk | |
| 1419 { | |
| 1420 get { _ilGenerator.Emit(OpCodes.Cpblk); return this; } | |
| 1421 } | |
| 1422 | |
| 1423 /// <summary> | |
| 1424 /// Calls ILGenerator.Emit(<see cref="OpCodes.Cpobj"/>, type) that | |
| 1425 /// copies the value type located at the address of an object (type &, * or natural int) | |
| 1426 /// to the address of the destination object (type &, * or natural int). | |
| 1427 /// </summary> | |
| 1428 /// <param name="type">A Type</param> | |
| 1429 /// <seealso cref="OpCodes.Cpobj">OpCodes.Cpobj</seealso> | |
| 1430 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 1431 public EmitHelper cpobj(Type type) | |
| 1432 { | |
| 1433 _ilGenerator.Emit(OpCodes.Cpobj, type); return this; | |
| 1434 } | |
| 1435 | |
| 1436 /// <summary> | |
| 1437 /// Calls ILGenerator.Emit(<see cref="OpCodes.Div"/>) that | |
| 1438 /// divides two values and pushes the result as a floating-point (type F) or | |
| 1439 /// quotient (type int32) onto the evaluation stack. | |
| 1440 /// </summary> | |
| 1441 /// <seealso cref="OpCodes.Div">OpCodes.Div</seealso> | |
| 1442 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1443 public EmitHelper div | |
| 1444 { | |
| 1445 get { _ilGenerator.Emit(OpCodes.Div); return this; } | |
| 1446 } | |
| 1447 | |
| 1448 /// <summary> | |
| 1449 /// Calls ILGenerator.Emit(<see cref="OpCodes.Div_Un"/>) that | |
| 1450 /// divides two unsigned integer values and pushes the result (int32) onto the evaluation stack. | |
| 1451 /// </summary> | |
| 1452 /// <seealso cref="OpCodes.Div_Un">OpCodes.Div_Un</seealso> | |
| 1453 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1454 public EmitHelper div_un | |
| 1455 { | |
| 1456 get { _ilGenerator.Emit(OpCodes.Div_Un); return this; } | |
| 1457 } | |
| 1458 | |
| 1459 /// <summary> | |
| 1460 /// Calls ILGenerator.Emit(<see cref="OpCodes.Dup"/>) that | |
| 1461 /// copies the current topmost value on the evaluation stack, and then pushes the copy onto the evaluation stack. | |
| 1462 /// </summary> | |
| 1463 /// <seealso cref="OpCodes.Dup">OpCodes.Dup</seealso> | |
| 1464 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1465 public EmitHelper dup | |
| 1466 { | |
| 1467 get { _ilGenerator.Emit(OpCodes.Dup); return this; } | |
| 1468 } | |
| 1469 | |
| 1470 /// <summary> | |
| 1471 /// Calls ILGenerator.Emit(<see cref="OpCodes.Endfilter"/>) that | |
| 1472 /// transfers control from the filter clause of an exception back to | |
| 1473 /// the Common Language Infrastructure (CLI) exception handler. | |
| 1474 /// </summary> | |
| 1475 /// <seealso cref="OpCodes.Endfilter">OpCodes.Endfilter</seealso> | |
| 1476 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1477 public EmitHelper endfilter | |
| 1478 { | |
| 1479 get { _ilGenerator.Emit(OpCodes.Endfilter); return this; } | |
| 1480 } | |
| 1481 | |
| 1482 /// <summary> | |
| 1483 /// Calls ILGenerator.Emit(<see cref="OpCodes.Endfinally"/>) that | |
| 1484 /// transfers control from the fault or finally clause of an exception block back to | |
| 1485 /// the Common Language Infrastructure (CLI) exception handler. | |
| 1486 /// </summary> | |
| 1487 /// <seealso cref="OpCodes.Endfinally">OpCodes.Endfinally</seealso> | |
| 1488 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1489 public EmitHelper endfinally | |
| 1490 { | |
| 1491 get { _ilGenerator.Emit(OpCodes.Endfinally); return this; } | |
| 1492 } | |
| 1493 | |
| 1494 /// <summary> | |
| 1495 /// Calls ILGenerator.Emit(<see cref="OpCodes.Initblk"/>) that | |
| 1496 /// initializes a specified block of memory at a specific address to a given size and initial value. | |
| 1497 /// </summary> | |
| 1498 /// <seealso cref="OpCodes.Initblk">OpCodes.Initblk</seealso> | |
| 1499 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1500 public EmitHelper initblk | |
| 1501 { | |
| 1502 get { _ilGenerator.Emit(OpCodes.Initblk); return this; } | |
| 1503 } | |
| 1504 | |
| 1505 /// <summary> | |
| 1506 /// Calls ILGenerator.Emit(<see cref="OpCodes.Initobj"/>, type) that | |
| 1507 /// initializes all the fields of the object at a specific address to a null reference or | |
| 1508 /// a 0 of the appropriate primitive type. | |
| 1509 /// </summary> | |
| 1510 /// <param name="type">A Type</param> | |
| 1511 /// <seealso cref="OpCodes.Initobj">OpCodes.Initobj</seealso> | |
| 1512 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 1513 public EmitHelper initobj(Type type) | |
| 1514 { | |
| 1515 _ilGenerator.Emit(OpCodes.Initobj, type); return this; | |
| 1516 } | |
| 1517 | |
| 1518 /// <summary> | |
| 1519 /// Calls ILGenerator.Emit(<see cref="OpCodes.Isinst"/>, type) that | |
| 1520 /// tests whether an object reference (type O) is an instance of a particular class. | |
| 1521 /// </summary> | |
| 1522 /// <param name="type">A Type</param> | |
| 1523 /// <seealso cref="OpCodes.Isinst">OpCodes.Isinst</seealso> | |
| 1524 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 1525 public EmitHelper isinst(Type type) | |
| 1526 { | |
| 1527 _ilGenerator.Emit(OpCodes.Isinst, type); return this; | |
| 1528 } | |
| 1529 | |
| 1530 /// <summary> | |
| 1531 /// Calls ILGenerator.Emit(<see cref="OpCodes.Jmp"/>, methodInfo) that | |
| 1532 /// exits current method and jumps to specified method. | |
| 1533 /// </summary> | |
| 1534 /// <param name="methodInfo">The method to be jumped.</param> | |
| 1535 /// <seealso cref="OpCodes.Jmp">OpCodes.Jmp</seealso> | |
| 1536 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,MethodInfo)">ILGenerator.Emit</seealso> | |
| 1537 public EmitHelper jmp(MethodInfo methodInfo) | |
| 1538 { | |
| 1539 _ilGenerator.Emit(OpCodes.Jmp, methodInfo); return this; | |
| 1540 } | |
| 1541 | |
| 1542 /// <summary> | |
| 1543 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldarg"/>, short) that | |
| 1544 /// loads an argument (referenced by a specified index value) onto the stack. | |
| 1545 /// </summary> | |
| 1546 /// <param name="index">Index of the argument that is pushed onto the stack.</param> | |
| 1547 /// <seealso cref="OpCodes.Ldarg">OpCodes.Ldarg</seealso> | |
| 1548 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,short)">ILGenerator.Emit</seealso> | |
| 1549 public EmitHelper ldarg(short index) | |
| 1550 { | |
| 1551 _ilGenerator.Emit(OpCodes.Ldarg, index); return this; | |
| 1552 } | |
| 1553 | |
| 1554 /// <summary> | |
| 1555 /// Loads an argument onto the stack. | |
| 1556 /// </summary> | |
| 1557 /// <param name="parameterInfo">A <see cref="ParameterInfo"/> representing a parameter.</param> | |
| 1558 /// <param name="box">True, if parameter must be converted to a reference.</param> | |
| 1559 /// <seealso cref="ldarg(ParameterInfo)"/> | |
| 1560 public EmitHelper ldargEx(ParameterInfo parameterInfo, bool box) | |
| 1561 { | |
| 1562 ldarg(parameterInfo); | |
| 1563 | |
| 1564 Type type = parameterInfo.ParameterType; | |
| 1565 | |
| 1566 if (parameterInfo.ParameterType.IsByRef) | |
| 1567 type = parameterInfo.ParameterType.GetElementType(); | |
| 1568 | |
| 1569 if (parameterInfo.ParameterType.IsByRef) | |
| 1570 { | |
| 1571 if (type.IsValueType && type.IsPrimitive == false) | |
| 1572 ldobj(type); | |
| 1573 else | |
| 1574 ldind(type); | |
| 1575 } | |
| 1576 | |
| 1577 if (box) | |
| 1578 boxIfValueType(type); | |
| 1579 | |
| 1580 return this; | |
| 1581 } | |
| 1582 | |
| 1583 /// <summary> | |
| 1584 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldarg"/>, short) or | |
| 1585 /// ILGenerator.Emit(<see cref="OpCodes.Ldarg_S"/>, byte) that | |
| 1586 /// loads an argument (referenced by a specified index value) onto the stack. | |
| 1587 /// </summary> | |
| 1588 /// <param name="index">Index of the argument that is pushed onto the stack.</param> | |
| 1589 /// <seealso cref="OpCodes.Ldarg">OpCodes.Ldarg</seealso> | |
| 1590 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,short)">ILGenerator.Emit</seealso> | |
| 1591 public EmitHelper ldarg(int index) | |
| 1592 { | |
| 1593 switch (index) | |
| 1594 { | |
| 1595 case 0: ldarg_0.end(); break; | |
| 1596 case 1: ldarg_1.end(); break; | |
| 1597 case 2: ldarg_2.end(); break; | |
| 1598 case 3: ldarg_3.end(); break; | |
| 1599 default: | |
| 1600 if (index <= byte. MaxValue) ldarg_s((byte)index); | |
| 1601 else if (index <= short.MaxValue) ldarg ((short)index); | |
| 1602 else | |
| 1603 throw new ArgumentOutOfRangeException("index"); | |
| 1604 | |
| 1605 break; | |
| 1606 } | |
| 1607 | |
| 1608 return this; | |
| 1609 } | |
| 1610 | |
| 1611 /// <summary> | |
| 1612 /// Loads an argument onto the stack. | |
| 1613 /// </summary> | |
| 1614 /// <param name="parameterInfo">A <see cref="ParameterInfo"/> representing a parameter.</param> | |
| 1615 public EmitHelper ldarg(ParameterInfo parameterInfo) | |
| 1616 { | |
| 1617 if (parameterInfo == null) throw new ArgumentNullException("parameterInfo"); | |
| 1618 | |
| 1619 bool isStatic = | |
| 1620 Method is MethodBuilderHelper && ((MethodBuilderHelper)Method).MethodBuilder.IsStatic; | |
| 1621 | |
| 1622 return ldarg(parameterInfo.Position + (isStatic? 0: 1)); | |
| 1623 } | |
| 1624 | |
| 1625 /// <summary> | |
| 1626 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldarga"/>, short) that | |
| 1627 /// load an argument address onto the evaluation stack. | |
| 1628 /// </summary> | |
| 1629 /// <param name="index">Index of the address addr of the argument that is pushed onto the stack.</param> | |
| 1630 /// <seealso cref="OpCodes.Ldarga">OpCodes.Ldarga</seealso> | |
| 1631 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,short)">ILGenerator.Emit</seealso> | |
| 1632 public EmitHelper ldarga(short index) | |
| 1633 { | |
| 1634 _ilGenerator.Emit(OpCodes.Ldarga, index); return this; | |
| 1635 } | |
| 1636 | |
| 1637 /// <summary> | |
| 1638 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldarga_S"/>, byte) that | |
| 1639 /// load an argument address, in short form, onto the evaluation stack. | |
| 1640 /// </summary> | |
| 1641 /// <param name="index">Index of the address addr of the argument that is pushed onto the stack.</param> | |
| 1642 /// <seealso cref="OpCodes.Ldarga_S">OpCodes.Ldarga_S</seealso> | |
| 1643 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,byte)">ILGenerator.Emit</seealso> | |
| 1644 public EmitHelper ldarga_s(byte index) | |
| 1645 { | |
| 1646 _ilGenerator.Emit(OpCodes.Ldarga_S, index); return this; | |
| 1647 } | |
| 1648 | |
| 1649 /// <summary> | |
| 1650 /// Load an argument address onto the evaluation stack. | |
| 1651 /// </summary> | |
| 1652 /// <param name="index">Index of the address addr of the argument that is pushed onto the stack.</param> | |
| 1653 public EmitHelper ldarga(int index) | |
| 1654 { | |
| 1655 if (index <= byte. MaxValue) ldarga_s((byte)index); | |
| 1656 else if (index <= short.MaxValue) ldarga ((short)index); | |
| 1657 else | |
| 1658 throw new ArgumentOutOfRangeException("index"); | |
| 1659 | |
| 1660 return this; | |
| 1661 } | |
| 1662 | |
| 1663 /// <summary> | |
| 1664 /// Loads an argument address onto the stack. | |
| 1665 /// </summary> | |
| 1666 /// <param name="parameterInfo">A <see cref="ParameterInfo"/> representing a parameter.</param> | |
| 1667 public EmitHelper ldarga(ParameterInfo parameterInfo) | |
| 1668 { | |
| 1669 if (parameterInfo == null) throw new ArgumentNullException("parameterInfo"); | |
| 1670 | |
| 1671 bool isStatic = | |
| 1672 Method is MethodBuilderHelper && ((MethodBuilderHelper)Method).MethodBuilder.IsStatic; | |
| 1673 | |
| 1674 return ldarga(parameterInfo.Position + (isStatic? 0: 1)); | |
| 1675 } | |
| 1676 | |
| 1677 | |
| 1678 /// <summary> | |
| 1679 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldarg_0"/>) that | |
| 1680 /// loads the argument at index 0 onto the evaluation stack. | |
| 1681 /// </summary> | |
| 1682 /// <seealso cref="OpCodes.Ldarg_0">OpCodes.Ldarg_0</seealso> | |
| 1683 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1684 public EmitHelper ldarg_0 | |
| 1685 { | |
| 1686 get { _ilGenerator.Emit(OpCodes.Ldarg_0); return this; } | |
| 1687 } | |
| 1688 | |
| 1689 /// <summary> | |
| 1690 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldarg_1"/>) that | |
| 1691 /// loads the argument at index 1 onto the evaluation stack. | |
| 1692 /// </summary> | |
| 1693 /// <seealso cref="OpCodes.Ldarg_1">OpCodes.Ldarg_1</seealso> | |
| 1694 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1695 public EmitHelper ldarg_1 | |
| 1696 { | |
| 1697 get { _ilGenerator.Emit(OpCodes.Ldarg_1); return this; } | |
| 1698 } | |
| 1699 | |
| 1700 /// <summary> | |
| 1701 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldarg_2"/>) that | |
| 1702 /// loads the argument at index 2 onto the evaluation stack. | |
| 1703 /// </summary> | |
| 1704 /// <seealso cref="OpCodes.Ldarg_2">OpCodes.Ldarg_2</seealso> | |
| 1705 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1706 public EmitHelper ldarg_2 | |
| 1707 { | |
| 1708 get { _ilGenerator.Emit(OpCodes.Ldarg_2); return this; } | |
| 1709 } | |
| 1710 | |
| 1711 /// <summary> | |
| 1712 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldarg_3"/>) that | |
| 1713 /// loads the argument at index 3 onto the evaluation stack. | |
| 1714 /// </summary> | |
| 1715 /// <seealso cref="OpCodes.Ldarg_3">OpCodes.Ldarg_3</seealso> | |
| 1716 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1717 public EmitHelper ldarg_3 | |
| 1718 { | |
| 1719 get { _ilGenerator.Emit(OpCodes.Ldarg_3); return this; } | |
| 1720 } | |
| 1721 | |
| 1722 /// <summary> | |
| 1723 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldarg_S"/>, byte) that | |
| 1724 /// loads the argument (referenced by a specified short form index) onto the evaluation stack. | |
| 1725 /// </summary> | |
| 1726 /// <param name="index">Index of the argument value that is pushed onto the stack.</param> | |
| 1727 /// <seealso cref="OpCodes.Ldarg_S">OpCodes.Ldarg_S</seealso> | |
| 1728 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,byte)">ILGenerator.Emit</seealso> | |
| 1729 public EmitHelper ldarg_s(byte index) | |
| 1730 { | |
| 1731 _ilGenerator.Emit(OpCodes.Ldarg_S, index); return this; | |
| 1732 } | |
| 1733 | |
| 1734 /// <summary> | |
| 1735 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_0"/> or <see cref="OpCodes.Ldc_I4_1"/>) that | |
| 1736 /// pushes a supplied value of type int32 onto the evaluation stack as an int32. | |
| 1737 /// </summary> | |
| 1738 /// <param name="b">The value pushed onto the stack.</param> | |
| 1739 /// <seealso cref="OpCodes.Ldc_I4">OpCodes.Ldc_I4_0</seealso> | |
| 1740 /// <seealso cref="OpCodes.Ldc_I4">OpCodes.Ldc_I4_1</seealso> | |
| 1741 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,int)">ILGenerator.Emit</seealso> | |
| 1742 public EmitHelper ldc_bool(bool b) | |
| 1743 { | |
| 1744 _ilGenerator.Emit(b? OpCodes.Ldc_I4_1: OpCodes.Ldc_I4_0); return this; | |
| 1745 } | |
| 1746 | |
| 1747 /// <summary> | |
| 1748 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4"/>, int) that | |
| 1749 /// pushes a supplied value of type int32 onto the evaluation stack as an int32. | |
| 1750 /// </summary> | |
| 1751 /// <param name="num">The value pushed onto the stack.</param> | |
| 1752 /// <seealso cref="OpCodes.Ldc_I4">OpCodes.Ldc_I4</seealso> | |
| 1753 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,int)">ILGenerator.Emit</seealso> | |
| 1754 public EmitHelper ldc_i4(int num) | |
| 1755 { | |
| 1756 _ilGenerator.Emit(OpCodes.Ldc_I4, num); return this; | |
| 1757 } | |
| 1758 | |
| 1759 /// <summary> | |
| 1760 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_0"/>) that | |
| 1761 /// pushes the integer value of 0 onto the evaluation stack as an int32. | |
| 1762 /// </summary> | |
| 1763 /// <seealso cref="OpCodes.Ldc_I4_0">OpCodes.Ldc_I4_0</seealso> | |
| 1764 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1765 public EmitHelper ldc_i4_0 | |
| 1766 { | |
| 1767 get { _ilGenerator.Emit(OpCodes.Ldc_I4_0); return this; } | |
| 1768 } | |
| 1769 | |
| 1770 /// <summary> | |
| 1771 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_1"/>) that | |
| 1772 /// pushes the integer value of 1 onto the evaluation stack as an int32. | |
| 1773 /// </summary> | |
| 1774 /// <seealso cref="OpCodes.Ldc_I4_1">OpCodes.Ldc_I4_1</seealso> | |
| 1775 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1776 public EmitHelper ldc_i4_1 | |
| 1777 { | |
| 1778 get { _ilGenerator.Emit(OpCodes.Ldc_I4_1); return this; } | |
| 1779 } | |
| 1780 | |
| 1781 /// <summary> | |
| 1782 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_2"/>) that | |
| 1783 /// pushes the integer value of 2 onto the evaluation stack as an int32. | |
| 1784 /// </summary> | |
| 1785 /// <seealso cref="OpCodes.Ldc_I4_2">OpCodes.Ldc_I4_2</seealso> | |
| 1786 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1787 public EmitHelper ldc_i4_2 | |
| 1788 { | |
| 1789 get { _ilGenerator.Emit(OpCodes.Ldc_I4_2); return this; } | |
| 1790 } | |
| 1791 | |
| 1792 /// <summary> | |
| 1793 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_3"/>) that | |
| 1794 /// pushes the integer value of 3 onto the evaluation stack as an int32. | |
| 1795 /// </summary> | |
| 1796 /// <seealso cref="OpCodes.Ldc_I4_3">OpCodes.Ldc_I4_3</seealso> | |
| 1797 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1798 public EmitHelper ldc_i4_3 | |
| 1799 { | |
| 1800 get { _ilGenerator.Emit(OpCodes.Ldc_I4_3); return this; } | |
| 1801 } | |
| 1802 | |
| 1803 /// <summary> | |
| 1804 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_4"/>) that | |
| 1805 /// pushes the integer value of 4 onto the evaluation stack as an int32. | |
| 1806 /// </summary> | |
| 1807 /// <seealso cref="OpCodes.Ldc_I4_4">OpCodes.Ldc_I4_4</seealso> | |
| 1808 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1809 public EmitHelper ldc_i4_4 | |
| 1810 { | |
| 1811 get { _ilGenerator.Emit(OpCodes.Ldc_I4_4); return this; } | |
| 1812 } | |
| 1813 | |
| 1814 /// <summary> | |
| 1815 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_5"/>) that | |
| 1816 /// pushes the integer value of 5 onto the evaluation stack as an int32. | |
| 1817 /// </summary> | |
| 1818 /// <seealso cref="OpCodes.Ldc_I4_5">OpCodes.Ldc_I4_0</seealso> | |
| 1819 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1820 public EmitHelper ldc_i4_5 | |
| 1821 { | |
| 1822 get { _ilGenerator.Emit(OpCodes.Ldc_I4_5); return this; } | |
| 1823 } | |
| 1824 | |
| 1825 /// <summary> | |
| 1826 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_6"/>) that | |
| 1827 /// pushes the integer value of 6 onto the evaluation stack as an int32. | |
| 1828 /// </summary> | |
| 1829 /// <seealso cref="OpCodes.Ldc_I4_6">OpCodes.Ldc_I4_6</seealso> | |
| 1830 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1831 public EmitHelper ldc_i4_6 | |
| 1832 { | |
| 1833 get { _ilGenerator.Emit(OpCodes.Ldc_I4_6); return this; } | |
| 1834 } | |
| 1835 | |
| 1836 /// <summary> | |
| 1837 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_7"/>) that | |
| 1838 /// pushes the integer value of 7 onto the evaluation stack as an int32. | |
| 1839 /// </summary> | |
| 1840 /// <seealso cref="OpCodes.Ldc_I4_7">OpCodes.Ldc_I4_7</seealso> | |
| 1841 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1842 public EmitHelper ldc_i4_7 | |
| 1843 { | |
| 1844 get { _ilGenerator.Emit(OpCodes.Ldc_I4_7); return this; } | |
| 1845 } | |
| 1846 | |
| 1847 /// <summary> | |
| 1848 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_8"/>) that | |
| 1849 /// pushes the integer value of 8 onto the evaluation stack as an int32. | |
| 1850 /// </summary> | |
| 1851 /// <seealso cref="OpCodes.Ldc_I4_8">OpCodes.Ldc_I4_8</seealso> | |
| 1852 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1853 public EmitHelper ldc_i4_8 | |
| 1854 { | |
| 1855 get { _ilGenerator.Emit(OpCodes.Ldc_I4_8); return this; } | |
| 1856 } | |
| 1857 | |
| 1858 /// <summary> | |
| 1859 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_M1"/>) that | |
| 1860 /// pushes the integer value of -1 onto the evaluation stack as an int32. | |
| 1861 /// </summary> | |
| 1862 /// <seealso cref="OpCodes.Ldc_I4_M1">OpCodes.Ldc_I4_M1</seealso> | |
| 1863 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1864 public EmitHelper ldc_i4_m1 | |
| 1865 { | |
| 1866 get { _ilGenerator.Emit(OpCodes.Ldc_I4_M1); return this; } | |
| 1867 } | |
| 1868 | |
| 1869 /// <summary> | |
| 1870 /// Calls the best form of ILGenerator.Emit(Ldc_I4_X) that | |
| 1871 /// pushes the integer value of -1 onto the evaluation stack as an int32. | |
| 1872 /// </summary> | |
| 1873 /// <seealso cref="ldc_i4"/> | |
| 1874 public EmitHelper ldc_i4_(int num) | |
| 1875 { | |
| 1876 switch (num) | |
| 1877 { | |
| 1878 case -1: ldc_i4_m1.end(); break; | |
| 1879 case 0: ldc_i4_0. end(); break; | |
| 1880 case 1: ldc_i4_1. end(); break; | |
| 1881 case 2: ldc_i4_2. end(); break; | |
| 1882 case 3: ldc_i4_3. end(); break; | |
| 1883 case 4: ldc_i4_4. end(); break; | |
| 1884 case 5: ldc_i4_5. end(); break; | |
| 1885 case 6: ldc_i4_6. end(); break; | |
| 1886 case 7: ldc_i4_7. end(); break; | |
| 1887 case 8: ldc_i4_8. end(); break; | |
| 1888 default: | |
| 1889 if (num >= sbyte.MinValue && num <= sbyte.MaxValue) | |
| 1890 ldc_i4_s((sbyte)num); | |
| 1891 else | |
| 1892 ldc_i4 (num); | |
| 1893 | |
| 1894 break; | |
| 1895 } | |
| 1896 | |
| 1897 return this; | |
| 1898 } | |
| 1899 | |
| 1900 /// <summary> | |
| 1901 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I4_S"/>, byte) that | |
| 1902 /// pushes the supplied int8 value onto the evaluation stack as an int32, short form. | |
| 1903 /// </summary> | |
| 1904 /// <param name="num">The value pushed onto the stack.</param> | |
| 1905 /// <seealso cref="OpCodes.Ldc_I4_S">OpCodes.Ldc_I4_S</seealso> | |
| 1906 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,byte)">ILGenerator.Emit</seealso> | |
| 1907 [CLSCompliant(false)] | |
| 1908 public EmitHelper ldc_i4_s(sbyte num) | |
| 1909 { | |
| 1910 _ilGenerator.Emit(OpCodes.Ldc_I4_S, num); return this; | |
| 1911 } | |
| 1912 | |
| 1913 /// <summary> | |
| 1914 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_I8"/>, long) that | |
| 1915 /// pushes a supplied value of type int64 onto the evaluation stack as an int64. | |
| 1916 /// </summary> | |
| 1917 /// <param name="num">The value pushed onto the stack.</param> | |
| 1918 /// <seealso cref="OpCodes.Ldc_I8">OpCodes.Ldc_I8</seealso> | |
| 1919 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,long)">ILGenerator.Emit</seealso> | |
| 1920 public EmitHelper ldc_i8(long num) | |
| 1921 { | |
| 1922 _ilGenerator.Emit(OpCodes.Ldc_I8, num); return this; | |
| 1923 } | |
| 1924 | |
| 1925 /// <summary> | |
| 1926 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_R4"/>, float) that | |
| 1927 /// pushes a supplied value of type float32 onto the evaluation stack as type F (float). | |
| 1928 /// </summary> | |
| 1929 /// <param name="num">The value pushed onto the stack.</param> | |
| 1930 /// <seealso cref="OpCodes.Ldc_R4">OpCodes.Ldc_R4</seealso> | |
| 1931 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,float)">ILGenerator.Emit</seealso> | |
| 1932 public EmitHelper ldc_r4(float num) | |
| 1933 { | |
| 1934 _ilGenerator.Emit(OpCodes.Ldc_R4, num); return this; | |
| 1935 } | |
| 1936 | |
| 1937 /// <summary> | |
| 1938 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldc_R8"/>, double) that | |
| 1939 /// pushes a supplied value of type float64 onto the evaluation stack as type F (float). | |
| 1940 /// </summary> | |
| 1941 /// <param name="num">The value pushed onto the stack.</param> | |
| 1942 /// <seealso cref="OpCodes.Ldc_R8">OpCodes.Ldc_R8</seealso> | |
| 1943 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,double)">ILGenerator.Emit</seealso> | |
| 1944 public EmitHelper ldc_r8(double num) | |
| 1945 { | |
| 1946 _ilGenerator.Emit(OpCodes.Ldc_R8, num); return this; | |
| 1947 } | |
| 1948 | |
| 1949 /// <summary> | |
| 1950 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelema"/>, type) that | |
| 1951 /// loads the address of the array element at a specified array index onto the top of the evaluation stack | |
| 1952 /// as type & (managed pointer). | |
| 1953 /// </summary> | |
| 1954 /// <param name="type">A Type</param> | |
| 1955 /// <seealso cref="OpCodes.Ldelema">OpCodes.Ldelema</seealso> | |
| 1956 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 1957 public EmitHelper ldelema(Type type) | |
| 1958 { | |
| 1959 _ilGenerator.Emit(OpCodes.Ldelema, type); return this; | |
| 1960 } | |
| 1961 | |
| 1962 /// <summary> | |
| 1963 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelem_I"/>) that | |
| 1964 /// loads the element with type natural int at a specified array index onto the top of the evaluation stack | |
| 1965 /// as a natural int. | |
| 1966 /// </summary> | |
| 1967 /// <seealso cref="OpCodes.Ldelem_I">OpCodes.Ldelem_I</seealso> | |
| 1968 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1969 public EmitHelper ldelem_i | |
| 1970 { | |
| 1971 get { _ilGenerator.Emit(OpCodes.Ldelem_I); return this; } | |
| 1972 } | |
| 1973 | |
| 1974 /// <summary> | |
| 1975 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelem_I1"/>) that | |
| 1976 /// loads the element with type int8 at a specified array index onto the top of the evaluation stack as an int32. | |
| 1977 /// </summary> | |
| 1978 /// <seealso cref="OpCodes.Ldelem_I1">OpCodes.Ldelem_I1</seealso> | |
| 1979 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1980 public EmitHelper ldelem_i1 | |
| 1981 { | |
| 1982 get { _ilGenerator.Emit(OpCodes.Ldelem_I1); return this; } | |
| 1983 } | |
| 1984 | |
| 1985 /// <summary> | |
| 1986 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelem_I2"/>) that | |
| 1987 /// loads the element with type int16 at a specified array index onto the top of the evaluation stack as an int32. | |
| 1988 /// </summary> | |
| 1989 /// <seealso cref="OpCodes.Ldelem_I2">OpCodes.Ldelem_I2</seealso> | |
| 1990 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 1991 public EmitHelper ldelem_i2 | |
| 1992 { | |
| 1993 get { _ilGenerator.Emit(OpCodes.Ldelem_I2); return this; } | |
| 1994 } | |
| 1995 | |
| 1996 /// <summary> | |
| 1997 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelem_I4"/>) that | |
| 1998 /// loads the element with type int32 at a specified array index onto the top of the evaluation stack as an int32. | |
| 1999 /// </summary> | |
| 2000 /// <seealso cref="OpCodes.Ldelem_I4">OpCodes.Ldelem_I4</seealso> | |
| 2001 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2002 public EmitHelper ldelem_i4 | |
| 2003 { | |
| 2004 get { _ilGenerator.Emit(OpCodes.Ldelem_I4); return this; } | |
| 2005 } | |
| 2006 | |
| 2007 /// <summary> | |
| 2008 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelem_I8"/>) that | |
| 2009 /// loads the element with type int64 at a specified array index onto the top of the evaluation stack as an int64. | |
| 2010 /// </summary> | |
| 2011 /// <seealso cref="OpCodes.Ldelem_I8">OpCodes.Ldelem_I8</seealso> | |
| 2012 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2013 public EmitHelper ldelem_i8 | |
| 2014 { | |
| 2015 get { _ilGenerator.Emit(OpCodes.Ldelem_I8); return this; } | |
| 2016 } | |
| 2017 | |
| 2018 /// <summary> | |
| 2019 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelem_R4"/>) that | |
| 2020 /// loads the element with type float32 at a specified array index onto the top of the evaluation stack as type F (float). | |
| 2021 /// </summary> | |
| 2022 /// <seealso cref="OpCodes.Ldelem_R4">OpCodes.Ldelem_R4</seealso> | |
| 2023 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2024 public EmitHelper ldelem_r4 | |
| 2025 { | |
| 2026 get { _ilGenerator.Emit(OpCodes.Ldelem_R4); return this; } | |
| 2027 } | |
| 2028 | |
| 2029 /// <summary> | |
| 2030 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelem_R8"/>) that | |
| 2031 /// loads the element with type float64 at a specified array index onto the top of the evaluation stack as type F (float). | |
| 2032 /// </summary> | |
| 2033 /// <seealso cref="OpCodes.Ldelem_R8">OpCodes.Ldelem_R8</seealso> | |
| 2034 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2035 public EmitHelper ldelem_r8 | |
| 2036 { | |
| 2037 get { _ilGenerator.Emit(OpCodes.Ldelem_R8); return this; } | |
| 2038 } | |
| 2039 | |
| 2040 /// <summary> | |
| 2041 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelem_Ref"/>) that | |
| 2042 /// loads the element containing an object reference at a specified array index | |
| 2043 /// onto the top of the evaluation stack as type O (object reference). | |
| 2044 /// </summary> | |
| 2045 /// <seealso cref="OpCodes.Ldelem_Ref">OpCodes.Ldelem_Ref</seealso> | |
| 2046 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2047 public EmitHelper ldelem_ref | |
| 2048 { | |
| 2049 get { _ilGenerator.Emit(OpCodes.Ldelem_Ref); return this; } | |
| 2050 } | |
| 2051 | |
| 2052 /// <summary> | |
| 2053 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelem_U1"/>) that | |
| 2054 /// loads the element with type unsigned int8 at a specified array index onto the top of the evaluation stack as an int32. | |
| 2055 /// </summary> | |
| 2056 /// <seealso cref="OpCodes.Ldelem_U1">OpCodes.Ldelem_U1</seealso> | |
| 2057 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2058 public EmitHelper ldelem_u1 | |
| 2059 { | |
| 2060 get { _ilGenerator.Emit(OpCodes.Ldelem_U1); return this; } | |
| 2061 } | |
| 2062 | |
| 2063 /// <summary> | |
| 2064 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelem_U2"/>) that | |
| 2065 /// loads the element with type unsigned int16 at a specified array index | |
| 2066 /// onto the top of the evaluation stack as an int32. | |
| 2067 /// </summary> | |
| 2068 /// <seealso cref="OpCodes.Ldelem_U2">OpCodes.Ldelem_U2</seealso> | |
| 2069 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2070 public EmitHelper ldelem_u2 | |
| 2071 { | |
| 2072 get { _ilGenerator.Emit(OpCodes.Ldelem_U2); return this; } | |
| 2073 } | |
| 2074 | |
| 2075 /// <summary> | |
| 2076 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldelem_U4"/>) that | |
| 2077 /// loads the element with type unsigned int32 at a specified array index | |
| 2078 /// onto the top of the evaluation stack as an int32. | |
| 2079 /// </summary> | |
| 2080 /// <seealso cref="OpCodes.Ldelem_U4">OpCodes.Ldelem_U4</seealso> | |
| 2081 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2082 public EmitHelper ldelem_u4 | |
| 2083 { | |
| 2084 get { _ilGenerator.Emit(OpCodes.Ldelem_U4); return this; } | |
| 2085 } | |
| 2086 | |
| 2087 /// <summary> | |
| 2088 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldfld"/>, fieldInfo) that | |
| 2089 /// finds the value of a field in the object whose reference is currently on the evaluation stack. | |
| 2090 /// </summary> | |
| 2091 /// <param name="fieldInfo">A <see cref="FieldInfo"/> representing a field.</param> | |
| 2092 /// <seealso cref="OpCodes.Ldfld">OpCodes.Ldfld</seealso> | |
| 2093 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,FieldInfo)">ILGenerator.Emit</seealso> | |
| 2094 public EmitHelper ldfld(FieldInfo fieldInfo) | |
| 2095 { | |
| 2096 _ilGenerator.Emit(OpCodes.Ldfld, fieldInfo); return this; | |
| 2097 } | |
| 2098 | |
| 2099 /// <summary> | |
| 2100 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldflda"/>, fieldInfo) that | |
| 2101 /// finds the address of a field in the object whose reference is currently on the evaluation stack. | |
| 2102 /// </summary> | |
| 2103 /// <param name="fieldInfo">A <see cref="FieldInfo"/> representing a field.</param> | |
| 2104 /// <seealso cref="OpCodes.Ldflda">OpCodes.Ldflda</seealso> | |
| 2105 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,FieldInfo)">ILGenerator.Emit</seealso> | |
| 2106 public EmitHelper ldflda(FieldInfo fieldInfo) | |
| 2107 { | |
| 2108 _ilGenerator.Emit(OpCodes.Ldflda, fieldInfo); return this; | |
| 2109 } | |
| 2110 | |
| 2111 /// <summary> | |
| 2112 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldftn"/>, methodInfo) that | |
| 2113 /// pushes an unmanaged pointer (type natural int) to the native code implementing a specific method | |
| 2114 /// onto the evaluation stack. | |
| 2115 /// </summary> | |
| 2116 /// <param name="methodInfo">The method to be called.</param> | |
| 2117 /// <seealso cref="OpCodes.Ldftn">OpCodes.Ldftn</seealso> | |
| 2118 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,MethodInfo)">ILGenerator.Emit</seealso> | |
| 2119 public EmitHelper ldftn(MethodInfo methodInfo) | |
| 2120 { | |
| 2121 _ilGenerator.Emit(OpCodes.Ldftn, methodInfo); return this; | |
| 2122 } | |
| 2123 | |
| 2124 /// <summary> | |
| 2125 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldind_I"/>) that | |
| 2126 /// loads a value of type natural int as a natural int onto the evaluation stack indirectly. | |
| 2127 /// </summary> | |
| 2128 /// <seealso cref="OpCodes.Ldind_I">OpCodes.Ldind_I</seealso> | |
| 2129 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2130 public EmitHelper ldind_i | |
| 2131 { | |
| 2132 get { _ilGenerator.Emit(OpCodes.Ldind_I); return this; } | |
| 2133 } | |
| 2134 | |
| 2135 /// <summary> | |
| 2136 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldind_I1"/>) that | |
| 2137 /// loads a value of type int8 as an int32 onto the evaluation stack indirectly. | |
| 2138 /// </summary> | |
| 2139 /// <seealso cref="OpCodes.Ldind_I1">OpCodes.Ldind_I1</seealso> | |
| 2140 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2141 public EmitHelper ldind_i1 | |
| 2142 { | |
| 2143 get { _ilGenerator.Emit(OpCodes.Ldind_I1); return this; } | |
| 2144 } | |
| 2145 | |
| 2146 /// <summary> | |
| 2147 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldind_I2"/>) that | |
| 2148 /// loads a value of type int16 as an int32 onto the evaluation stack indirectly. | |
| 2149 /// </summary> | |
| 2150 /// <seealso cref="OpCodes.Ldind_I2">OpCodes.Ldind_I2</seealso> | |
| 2151 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2152 public EmitHelper ldind_i2 | |
| 2153 { | |
| 2154 get { _ilGenerator.Emit(OpCodes.Ldind_I2); return this; } | |
| 2155 } | |
| 2156 | |
| 2157 /// <summary> | |
| 2158 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldind_I4"/>) that | |
| 2159 /// loads a value of type int32 as an int32 onto the evaluation stack indirectly. | |
| 2160 /// </summary> | |
| 2161 /// <seealso cref="OpCodes.Ldind_I4">OpCodes.Ldind_I4</seealso> | |
| 2162 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2163 public EmitHelper ldind_i4 | |
| 2164 { | |
| 2165 get { _ilGenerator.Emit(OpCodes.Ldind_I4); return this; } | |
| 2166 } | |
| 2167 | |
| 2168 /// <summary> | |
| 2169 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldind_I8"/>) that | |
| 2170 /// loads a value of type int64 as an int64 onto the evaluation stack indirectly. | |
| 2171 /// </summary> | |
| 2172 /// <seealso cref="OpCodes.Ldind_I8">OpCodes.Ldind_I8</seealso> | |
| 2173 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2174 public EmitHelper ldind_i8 | |
| 2175 { | |
| 2176 get { _ilGenerator.Emit(OpCodes.Ldind_I8); return this; } | |
| 2177 } | |
| 2178 | |
| 2179 /// <summary> | |
| 2180 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldind_R4"/>) that | |
| 2181 /// loads a value of type float32 as a type F (float) onto the evaluation stack indirectly. | |
| 2182 /// </summary> | |
| 2183 /// <seealso cref="OpCodes.Ldind_R4">OpCodes.Ldind_R4</seealso> | |
| 2184 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2185 public EmitHelper ldind_r4 | |
| 2186 { | |
| 2187 get { _ilGenerator.Emit(OpCodes.Ldind_R4); return this; } | |
| 2188 } | |
| 2189 | |
| 2190 /// <summary> | |
| 2191 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldind_R8"/>) that | |
| 2192 /// loads a value of type float64 as a type F (float) onto the evaluation stack indirectly. | |
| 2193 /// </summary> | |
| 2194 /// <seealso cref="OpCodes.Ldind_R8">OpCodes.Ldind_R8</seealso> | |
| 2195 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2196 public EmitHelper ldind_r8 | |
| 2197 { | |
| 2198 get { _ilGenerator.Emit(OpCodes.Ldind_R8); return this; } | |
| 2199 } | |
| 2200 | |
| 2201 /// <summary> | |
| 2202 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldind_Ref"/>) that | |
| 2203 /// loads an object reference as a type O (object reference) onto the evaluation stack indirectly. | |
| 2204 /// </summary> | |
| 2205 /// <seealso cref="OpCodes.Ldind_Ref">OpCodes.Ldind_Ref</seealso> | |
| 2206 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2207 public EmitHelper ldind_ref | |
| 2208 { | |
| 2209 get { _ilGenerator.Emit(OpCodes.Ldind_Ref); return this; } | |
| 2210 } | |
| 2211 | |
| 2212 /// <summary> | |
| 2213 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldind_U1"/>) that | |
| 2214 /// loads a value of type unsigned int8 as an int32 onto the evaluation stack indirectly. | |
| 2215 /// </summary> | |
| 2216 /// <seealso cref="OpCodes.Ldind_U1">OpCodes.Ldind_U1</seealso> | |
| 2217 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2218 public EmitHelper ldind_u1 | |
| 2219 { | |
| 2220 get { _ilGenerator.Emit(OpCodes.Ldind_U1); return this; } | |
| 2221 } | |
| 2222 | |
| 2223 /// <summary> | |
| 2224 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldind_U2"/>) that | |
| 2225 /// loads a value of type unsigned int16 as an int32 onto the evaluation stack indirectly. | |
| 2226 /// </summary> | |
| 2227 /// <seealso cref="OpCodes.Ldind_U2">OpCodes.Ldind_U2</seealso> | |
| 2228 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2229 public EmitHelper ldind_u2 | |
| 2230 { | |
| 2231 get { _ilGenerator.Emit(OpCodes.Ldind_U2); return this; } | |
| 2232 } | |
| 2233 | |
| 2234 /// <summary> | |
| 2235 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldind_U4"/>) that | |
| 2236 /// loads a value of type unsigned int32 as an int32 onto the evaluation stack indirectly. | |
| 2237 /// </summary> | |
| 2238 /// <seealso cref="OpCodes.Ldind_U4">OpCodes.Ldind_U4</seealso> | |
| 2239 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2240 public EmitHelper ldind_u4 | |
| 2241 { | |
| 2242 get { _ilGenerator.Emit(OpCodes.Ldind_U4); return this; } | |
| 2243 } | |
| 2244 | |
| 2245 /// <summary> | |
| 2246 /// Loads a value of the type from a supplied address. | |
| 2247 /// </summary> | |
| 2248 /// <param name="type">A Type.</param> | |
| 2249 public EmitHelper ldind(Type type) | |
| 2250 { | |
| 2251 if (type == null) throw new ArgumentNullException("type"); | |
| 2252 | |
| 2253 switch (Type.GetTypeCode(type)) | |
| 2254 { | |
| 2255 case TypeCode.Boolean: | |
| 2256 case TypeCode.Byte: | |
| 2257 case TypeCode.SByte: ldind_i1.end(); break; | |
| 2258 | |
| 2259 case TypeCode.Char: | |
| 2260 case TypeCode.Int16: | |
| 2261 case TypeCode.UInt16: ldind_i2.end(); break; | |
| 2262 | |
| 2263 case TypeCode.Int32: | |
| 2264 case TypeCode.UInt32: ldind_i4.end(); break; | |
| 2265 | |
| 2266 case TypeCode.Int64: | |
| 2267 case TypeCode.UInt64: ldind_i8.end(); break; | |
| 2268 | |
| 2269 case TypeCode.Single: ldind_r4.end(); break; | |
| 2270 case TypeCode.Double: ldind_r8.end(); break; | |
| 2271 | |
| 2272 default: | |
| 2273 if (type.IsClass) | |
| 2274 ldind_ref.end(); | |
| 2275 else if (type.IsValueType) | |
| 2276 stobj(type); | |
| 2277 else | |
| 2278 throw CreateNotExpectedTypeException(type); | |
| 2279 break; | |
| 2280 } | |
| 2281 | |
| 2282 return this; | |
| 2283 } | |
| 2284 | |
| 2285 /// <summary> | |
| 2286 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldlen"/>) that | |
| 2287 /// pushes the number of elements of a zero-based, one-dimensional array onto the evaluation stack. | |
| 2288 /// </summary> | |
| 2289 /// <seealso cref="OpCodes.Ldlen">OpCodes.Ldlen</seealso> | |
| 2290 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2291 public EmitHelper ldlen | |
| 2292 { | |
| 2293 get { _ilGenerator.Emit(OpCodes.Ldlen); return this; } | |
| 2294 } | |
| 2295 | |
| 2296 /// <summary> | |
| 2297 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldloc"/>, short) that | |
| 2298 /// load an argument address onto the evaluation stack. | |
| 2299 /// </summary> | |
| 2300 /// <param name="index">Index of the local variable value pushed onto the stack.</param> | |
| 2301 /// <seealso cref="OpCodes.Ldloc">OpCodes.Ldloc</seealso> | |
| 2302 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,short)">ILGenerator.Emit</seealso> | |
| 2303 public EmitHelper ldloc(short index) | |
| 2304 { | |
| 2305 _ilGenerator.Emit(OpCodes.Ldloc, index); return this; | |
| 2306 } | |
| 2307 | |
| 2308 /// <summary> | |
| 2309 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldloc"/>, <see cref="LocalBuilder"/>) that | |
| 2310 /// load an argument address onto the evaluation stack. | |
| 2311 /// </summary> | |
| 2312 /// <param name="localBuilder">Local variable builder.</param> | |
| 2313 /// <seealso cref="OpCodes.Ldloc">OpCodes.Ldloc</seealso> | |
| 2314 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,short)">ILGenerator.Emit</seealso> | |
| 2315 public EmitHelper ldloc(LocalBuilder localBuilder) | |
| 2316 { | |
| 2317 _ilGenerator.Emit(OpCodes.Ldloc, localBuilder); return this; | |
| 2318 } | |
| 2319 | |
| 2320 /// <summary> | |
| 2321 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldloca"/>, short) that | |
| 2322 /// loads the address of the local variable at a specific index onto the evaluation stack. | |
| 2323 /// </summary> | |
| 2324 /// <param name="index">Index of the local variable.</param> | |
| 2325 /// <seealso cref="OpCodes.Ldloca">OpCodes.Ldloca</seealso> | |
| 2326 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,short)">ILGenerator.Emit</seealso> | |
| 2327 public EmitHelper ldloca(short index) | |
| 2328 { | |
| 2329 _ilGenerator.Emit(OpCodes.Ldloca, index); return this; | |
| 2330 } | |
| 2331 | |
| 2332 /// <summary> | |
| 2333 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldloca_S"/>, byte) that | |
| 2334 /// loads the address of the local variable at a specific index onto the evaluation stack, short form. | |
| 2335 /// </summary> | |
| 2336 /// <param name="index">Index of the local variable.</param> | |
| 2337 /// <seealso cref="OpCodes.Ldloca_S">OpCodes.Ldloca_S</seealso> | |
| 2338 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,byte)">ILGenerator.Emit</seealso> | |
| 2339 public EmitHelper ldloca_s(byte index) | |
| 2340 { | |
| 2341 _ilGenerator.Emit(OpCodes.Ldloca_S, index); return this; | |
| 2342 } | |
| 2343 | |
| 2344 /// <summary> | |
| 2345 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldloca"/>, <see cref="LocalBuilder"/>) that | |
| 2346 /// loads the address of the local variable at a specific index onto the evaluation stack. | |
| 2347 /// </summary> | |
| 2348 /// <param name="local">A <see cref="LocalBuilder"/> representing the local variable.</param> | |
| 2349 /// <seealso cref="OpCodes.Ldloca">OpCodes.Ldloca</seealso> | |
| 2350 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,short)">ILGenerator.Emit</seealso> | |
| 2351 public EmitHelper ldloca(LocalBuilder local) | |
| 2352 { | |
| 2353 _ilGenerator.Emit(OpCodes.Ldloca, local); return this; | |
| 2354 } | |
| 2355 | |
| 2356 /// <summary> | |
| 2357 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldloc_0"/>) that | |
| 2358 /// loads the local variable at index 0 onto the evaluation stack. | |
| 2359 /// </summary> | |
| 2360 /// <seealso cref="OpCodes.Ldloc_0">OpCodes.Ldloc_0</seealso> | |
| 2361 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2362 public EmitHelper ldloc_0 | |
| 2363 { | |
| 2364 get { _ilGenerator.Emit(OpCodes.Ldloc_0); return this; } | |
| 2365 } | |
| 2366 | |
| 2367 /// <summary> | |
| 2368 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldloc_1"/>) that | |
| 2369 /// loads the local variable at index 1 onto the evaluation stack. | |
| 2370 /// </summary> | |
| 2371 /// <seealso cref="OpCodes.Ldloc_1">OpCodes.Ldloc_1</seealso> | |
| 2372 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2373 public EmitHelper ldloc_1 | |
| 2374 { | |
| 2375 get { _ilGenerator.Emit(OpCodes.Ldloc_1); return this; } | |
| 2376 } | |
| 2377 | |
| 2378 /// <summary> | |
| 2379 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldloc_2"/>) that | |
| 2380 /// loads the local variable at index 2 onto the evaluation stack. | |
| 2381 /// </summary> | |
| 2382 /// <seealso cref="OpCodes.Ldloc_2">OpCodes.Ldloc_2</seealso> | |
| 2383 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2384 public EmitHelper ldloc_2 | |
| 2385 { | |
| 2386 get { _ilGenerator.Emit(OpCodes.Ldloc_2); return this; } | |
| 2387 } | |
| 2388 | |
| 2389 /// <summary> | |
| 2390 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldloc_3"/>) that | |
| 2391 /// loads the local variable at index 3 onto the evaluation stack. | |
| 2392 /// </summary> | |
| 2393 /// <seealso cref="OpCodes.Ldloc_3">OpCodes.Ldloc_3</seealso> | |
| 2394 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2395 public EmitHelper ldloc_3 | |
| 2396 { | |
| 2397 get { _ilGenerator.Emit(OpCodes.Ldloc_3); return this; } | |
| 2398 } | |
| 2399 | |
| 2400 /// <summary> | |
| 2401 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldloc_S"/>, byte) that | |
| 2402 /// loads the local variable at a specific index onto the evaluation stack, short form. | |
| 2403 /// </summary> | |
| 2404 /// <param name="index">Index of the local variable.</param> | |
| 2405 /// <seealso cref="OpCodes.Ldloc_S">OpCodes.Ldloc_S</seealso> | |
| 2406 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,byte)">ILGenerator.Emit</seealso> | |
| 2407 public EmitHelper ldloc_s(byte index) | |
| 2408 { | |
| 2409 _ilGenerator.Emit(OpCodes.Ldloca_S, index); return this; | |
| 2410 } | |
| 2411 | |
| 2412 /// <summary> | |
| 2413 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldnull"/>) that | |
| 2414 /// pushes a null reference (type O) onto the evaluation stack. | |
| 2415 /// </summary> | |
| 2416 /// <seealso cref="OpCodes.Ldnull">OpCodes.Ldnull</seealso> | |
| 2417 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2418 public EmitHelper ldnull | |
| 2419 { | |
| 2420 get { _ilGenerator.Emit(OpCodes.Ldnull); return this; } | |
| 2421 } | |
| 2422 | |
| 2423 /// <summary> | |
| 2424 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldobj"/>, type) that | |
| 2425 /// copies the value type object pointed to by an address to the top of the evaluation stack. | |
| 2426 /// </summary> | |
| 2427 /// <param name="type">A Type</param> | |
| 2428 /// <seealso cref="OpCodes.Ldobj">OpCodes.Ldobj</seealso> | |
| 2429 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 2430 public EmitHelper ldobj(Type type) | |
| 2431 { | |
| 2432 _ilGenerator.Emit(OpCodes.Ldobj, type); return this; | |
| 2433 } | |
| 2434 | |
| 2435 /// <summary> | |
| 2436 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldsfld"/>, fieldInfo) that | |
| 2437 /// pushes the value of a static field onto the evaluation stack. | |
| 2438 /// </summary> | |
| 2439 /// <param name="fieldInfo">A <see cref="FieldInfo"/> representing a field.</param> | |
| 2440 /// <seealso cref="OpCodes.Ldsfld">OpCodes.Ldsfld</seealso> | |
| 2441 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,FieldInfo)">ILGenerator.Emit</seealso> | |
| 2442 public EmitHelper ldsfld(FieldInfo fieldInfo) | |
| 2443 { | |
| 2444 _ilGenerator.Emit(OpCodes.Ldsfld, fieldInfo); return this; | |
| 2445 } | |
| 2446 | |
| 2447 /// <summary> | |
| 2448 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldsflda"/>, fieldInfo) that | |
| 2449 /// pushes the address of a static field onto the evaluation stack. | |
| 2450 /// </summary> | |
| 2451 /// <param name="fieldInfo">A <see cref="FieldInfo"/> representing a field.</param> | |
| 2452 /// <seealso cref="OpCodes.Ldsflda">OpCodes.Ldsflda</seealso> | |
| 2453 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,FieldInfo)">ILGenerator.Emit</seealso> | |
| 2454 public EmitHelper ldsflda(FieldInfo fieldInfo) | |
| 2455 { | |
| 2456 _ilGenerator.Emit(OpCodes.Ldsflda, fieldInfo); return this; | |
| 2457 } | |
| 2458 | |
| 2459 /// <summary> | |
| 2460 /// Calls <see cref="ldstr"/> -or- <see cref="ldnull"/>, | |
| 2461 /// if given string is a null reference. | |
| 2462 /// </summary> | |
| 2463 /// <param name="str">The String to be emitted.</param> | |
| 2464 /// <seealso cref="ldstr"/> | |
| 2465 /// <seealso cref="ldnull"/> | |
| 2466 public EmitHelper ldstrEx(string str) | |
| 2467 { | |
| 2468 return str == null ? ldnull : ldstr(str); | |
| 2469 } | |
| 2470 | |
| 2471 /// <summary> | |
| 2472 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldstr"/>, string) that | |
| 2473 /// pushes a new object reference to a string literal stored in the metadata. | |
| 2474 /// </summary> | |
| 2475 /// <param name="str">The String to be emitted.</param> | |
| 2476 /// <seealso cref="OpCodes.Ldstr">OpCodes.Ldstr</seealso> | |
| 2477 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,FieldInfo)">ILGenerator.Emit</seealso> | |
| 2478 public EmitHelper ldstr(string str) | |
| 2479 { | |
| 2480 _ilGenerator.Emit(OpCodes.Ldstr, str); return this; | |
| 2481 } | |
| 2482 | |
| 2483 /// <summary> | |
| 2484 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldstr"/>, string) that | |
| 2485 /// pushes a new object reference to a string literal stored in the metadata. | |
| 2486 /// </summary> | |
| 2487 /// <param name="nameOrIndex">The <see cref="NameOrIndexParameter"/> to be emitted.</param> | |
| 2488 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,FieldInfo)">ILGenerator.Emit</seealso> | |
| 2489 public EmitHelper ldNameOrIndex(NameOrIndexParameter nameOrIndex) | |
| 2490 { | |
| 2491 return nameOrIndex.ByName? | |
| 2492 ldstr (nameOrIndex.Name) .call(typeof(NameOrIndexParameter), "op_Implicit", typeof(string)): | |
| 2493 ldc_i4_(nameOrIndex.Index).call(typeof(NameOrIndexParameter), "op_Implicit", typeof(int)); | |
| 2494 } | |
| 2495 | |
| 2496 /// <summary> | |
| 2497 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldtoken"/>, methodInfo) that | |
| 2498 /// converts a metadata token to its runtime representation, pushing it onto the evaluation stack. | |
| 2499 /// </summary> | |
| 2500 /// <param name="methodInfo">The method to be called.</param> | |
| 2501 /// <seealso cref="OpCodes.Ldtoken">OpCodes.Ldtoken</seealso> | |
| 2502 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,MethodInfo)">ILGenerator.Emit</seealso> | |
| 2503 public EmitHelper ldtoken(MethodInfo methodInfo) | |
| 2504 { | |
| 2505 _ilGenerator.Emit(OpCodes.Ldtoken, methodInfo); return this; | |
| 2506 } | |
| 2507 | |
| 2508 /// <summary> | |
| 2509 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldtoken"/>, fieldInfo) that | |
| 2510 /// converts a metadata token to its runtime representation, | |
| 2511 /// pushing it onto the evaluation stack. | |
| 2512 /// </summary> | |
| 2513 /// <param name="fieldInfo">A <see cref="FieldInfo"/> representing a field.</param> | |
| 2514 /// <seealso cref="OpCodes.Ldtoken">OpCodes.Ldtoken</seealso> | |
| 2515 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,FieldInfo)">ILGenerator.Emit</seealso> | |
| 2516 public EmitHelper ldtoken(FieldInfo fieldInfo) | |
| 2517 { | |
| 2518 _ilGenerator.Emit(OpCodes.Ldtoken, fieldInfo); return this; | |
| 2519 } | |
| 2520 | |
| 2521 /// <summary> | |
| 2522 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldtoken"/>, type) that | |
| 2523 /// converts a metadata token to its runtime representation, pushing it onto the evaluation stack. | |
| 2524 /// </summary> | |
| 2525 /// <param name="type">A Type</param> | |
| 2526 /// <seealso cref="OpCodes.Ldtoken">OpCodes.Ldtoken</seealso> | |
| 2527 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 2528 public EmitHelper ldtoken(Type type) | |
| 2529 { | |
| 2530 _ilGenerator.Emit(OpCodes.Ldtoken, type); return this; | |
| 2531 } | |
| 2532 | |
| 2533 /// <summary> | |
| 2534 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ldvirtftn"/>, methodInfo) that | |
| 2535 /// pushes an unmanaged pointer (type natural int) to the native code implementing a particular virtual method | |
| 2536 /// associated with a specified object onto the evaluation stack. | |
| 2537 /// </summary> | |
| 2538 /// <param name="methodInfo">The method to be called.</param> | |
| 2539 /// <seealso cref="OpCodes.Ldvirtftn">OpCodes.Ldvirtftn</seealso> | |
| 2540 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,MethodInfo)">ILGenerator.Emit</seealso> | |
| 2541 public EmitHelper ldvirtftn(MethodInfo methodInfo) | |
| 2542 { | |
| 2543 _ilGenerator.Emit(OpCodes.Ldvirtftn, methodInfo); return this; | |
| 2544 } | |
| 2545 | |
| 2546 /// <summary> | |
| 2547 /// Calls ILGenerator.Emit(<see cref="OpCodes.Leave"/>, label) that | |
| 2548 /// exits a protected region of code, unconditionally tranferring control to a specific target instruction. | |
| 2549 /// </summary> | |
| 2550 /// <param name="label">The label.</param> | |
| 2551 /// <seealso cref="OpCodes.Leave">OpCodes.Leave</seealso> | |
| 2552 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 2553 public EmitHelper leave(Label label) | |
| 2554 { | |
| 2555 _ilGenerator.Emit(OpCodes.Leave, label); return this; | |
| 2556 } | |
| 2557 | |
| 2558 /// <summary> | |
| 2559 /// Calls ILGenerator.Emit(<see cref="OpCodes.Leave_S"/>, label) that | |
| 2560 /// exits a protected region of code, unconditionally transferring control to a target instruction (short form). | |
| 2561 /// </summary> | |
| 2562 /// <param name="label">The label.</param> | |
| 2563 /// <seealso cref="OpCodes.Leave_S">OpCodes.Leave_S</seealso> | |
| 2564 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 2565 public EmitHelper leave_s(Label label) | |
| 2566 { | |
| 2567 _ilGenerator.Emit(OpCodes.Leave_S, label); return this; | |
| 2568 } | |
| 2569 | |
| 2570 /// <summary> | |
| 2571 /// Calls ILGenerator.Emit(<see cref="OpCodes.Localloc"/>) that | |
| 2572 /// allocates a certain number of bytes from the local dynamic memory pool and pushes the address | |
| 2573 /// (a transient pointer, type *) of the first allocated byte onto the evaluation stack. | |
| 2574 /// </summary> | |
| 2575 /// <seealso cref="OpCodes.Localloc">OpCodes.Localloc</seealso> | |
| 2576 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2577 public EmitHelper localloc | |
| 2578 { | |
| 2579 get { _ilGenerator.Emit(OpCodes.Localloc); return this; } | |
| 2580 } | |
| 2581 | |
| 2582 /// <summary> | |
| 2583 /// Calls ILGenerator.Emit(<see cref="OpCodes.Mkrefany"/>, type) that | |
| 2584 /// pushes a typed reference to an instance of a specific type onto the evaluation stack. | |
| 2585 /// </summary> | |
| 2586 /// <param name="type">A Type</param> | |
| 2587 /// <seealso cref="OpCodes.Mkrefany">OpCodes.Mkrefany</seealso> | |
| 2588 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 2589 public EmitHelper mkrefany(Type type) | |
| 2590 { | |
| 2591 _ilGenerator.Emit(OpCodes.Mkrefany, type); return this; | |
| 2592 } | |
| 2593 | |
| 2594 /// <summary> | |
| 2595 /// Calls ILGenerator.Emit(<see cref="OpCodes.Mul"/>) that | |
| 2596 /// multiplies two values and pushes the result on the evaluation stack. | |
| 2597 /// (a transient pointer, type *) of the first allocated byte onto the evaluation stack. | |
| 2598 /// </summary> | |
| 2599 /// <seealso cref="OpCodes.Mul">OpCodes.Mul</seealso> | |
| 2600 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2601 public EmitHelper mul | |
| 2602 { | |
| 2603 get { _ilGenerator.Emit(OpCodes.Mul); return this; } | |
| 2604 } | |
| 2605 | |
| 2606 /// <summary> | |
| 2607 /// Calls ILGenerator.Emit(<see cref="OpCodes.Mul_Ovf"/>) that | |
| 2608 /// multiplies two integer values, performs an overflow check, | |
| 2609 /// and pushes the result onto the evaluation stack. | |
| 2610 /// </summary> | |
| 2611 /// <seealso cref="OpCodes.Mul_Ovf">OpCodes.Mul_Ovf</seealso> | |
| 2612 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2613 public EmitHelper mul_ovf | |
| 2614 { | |
| 2615 get { _ilGenerator.Emit(OpCodes.Mul_Ovf); return this; } | |
| 2616 } | |
| 2617 | |
| 2618 /// <summary> | |
| 2619 /// Calls ILGenerator.Emit(<see cref="OpCodes.Mul_Ovf_Un"/>) that | |
| 2620 /// multiplies two unsigned integer values, performs an overflow check, | |
| 2621 /// and pushes the result onto the evaluation stack. | |
| 2622 /// </summary> | |
| 2623 /// <seealso cref="OpCodes.Mul_Ovf_Un">OpCodes.Mul_Ovf_Un</seealso> | |
| 2624 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2625 public EmitHelper mul_ovf_un | |
| 2626 { | |
| 2627 get { _ilGenerator.Emit(OpCodes.Mul_Ovf_Un); return this; } | |
| 2628 } | |
| 2629 | |
| 2630 /// <summary> | |
| 2631 /// Calls ILGenerator.Emit(<see cref="OpCodes.Neg"/>) that | |
| 2632 /// negates a value and pushes the result onto the evaluation stack. | |
| 2633 /// </summary> | |
| 2634 /// <seealso cref="OpCodes.Neg">OpCodes.Neg</seealso> | |
| 2635 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2636 public EmitHelper neg | |
| 2637 { | |
| 2638 get { _ilGenerator.Emit(OpCodes.Neg); return this; } | |
| 2639 } | |
| 2640 | |
| 2641 /// <summary> | |
| 2642 /// Calls ILGenerator.Emit(<see cref="OpCodes.Newarr"/>, type) that | |
| 2643 /// pushes an object reference to a new zero-based, one-dimensional array whose elements | |
| 2644 /// are of a specific type onto the evaluation stack. | |
| 2645 /// </summary> | |
| 2646 /// <param name="type">A Type</param> | |
| 2647 /// <seealso cref="OpCodes.Newarr">OpCodes.Newarr</seealso> | |
| 2648 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 2649 public EmitHelper newarr(Type type) | |
| 2650 { | |
| 2651 _ilGenerator.Emit(OpCodes.Newarr, type); return this; | |
| 2652 } | |
| 2653 | |
| 2654 /// <summary> | |
| 2655 /// Calls ILGenerator.Emit(<see cref="OpCodes.Newobj"/>, <see cref="ConstructorInfo"/>) that | |
| 2656 /// creates a new object or a new instance of a value type, | |
| 2657 /// pushing an object reference (type O) onto the evaluation stack. | |
| 2658 /// </summary> | |
| 2659 /// <param name="constructorInfo">A <see cref="ConstructorInfo"/> representing a constructor.</param> | |
| 2660 /// <seealso cref="OpCodes.Newobj">OpCodes.Newobj</seealso> | |
| 2661 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,ConstructorInfo)">ILGenerator.Emit</seealso> | |
| 2662 public EmitHelper newobj(ConstructorInfo constructorInfo) | |
| 2663 { | |
| 2664 _ilGenerator.Emit(OpCodes.Newobj, constructorInfo); return this; | |
| 2665 } | |
| 2666 | |
| 2667 /// <summary> | |
| 2668 /// Calls ILGenerator.Emit(<see cref="OpCodes.Newobj"/>, ConstructorInfo) that | |
| 2669 /// creates a new object or a new instance of a value type, | |
| 2670 /// pushing an object reference (type O) onto the evaluation stack. | |
| 2671 /// </summary> | |
| 2672 /// <param name="type">A type.</param> | |
| 2673 /// <param name="parameters">An array of System.Type objects representing | |
| 2674 /// the number, order, and type of the parameters for the desired constructor. | |
| 2675 /// -or- An empty array of System.Type objects, to get a constructor that takes | |
| 2676 /// no parameters. Such an empty array is provided by the static field System.Type.EmptyTypes.</param> | |
| 2677 public EmitHelper newobj(Type type, params Type[] parameters) | |
| 2678 { | |
| 2679 if (type == null) throw new ArgumentNullException("type"); | |
| 2680 | |
| 2681 ConstructorInfo ci = type.GetConstructor(parameters); | |
| 2682 | |
| 2683 return newobj(ci); | |
| 2684 } | |
| 2685 | |
| 2686 /// <summary> | |
| 2687 /// Calls ILGenerator.Emit(<see cref="OpCodes.Nop"/>) that | |
| 2688 /// fills space if opcodes are patched. No meaningful operation is performed although | |
| 2689 /// a processing cycle can be consumed. | |
| 2690 /// </summary> | |
| 2691 /// <seealso cref="OpCodes.Nop">OpCodes.Nop</seealso> | |
| 2692 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2693 public EmitHelper nop | |
| 2694 { | |
| 2695 get { _ilGenerator.Emit(OpCodes.Nop); return this; } | |
| 2696 } | |
| 2697 | |
| 2698 /// <summary> | |
| 2699 /// Calls ILGenerator.Emit(<see cref="OpCodes.Not"/>) that | |
| 2700 /// computes the bitwise complement of the integer value on top of the stack | |
| 2701 /// and pushes the result onto the evaluation stack as the same type. | |
| 2702 /// </summary> | |
| 2703 /// <seealso cref="OpCodes.Not">OpCodes.Not</seealso> | |
| 2704 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2705 public EmitHelper not | |
| 2706 { | |
| 2707 get { _ilGenerator.Emit(OpCodes.Not); return this; } | |
| 2708 } | |
| 2709 | |
| 2710 /// <summary> | |
| 2711 /// Calls ILGenerator.Emit(<see cref="OpCodes.Or"/>) that | |
| 2712 /// compute the bitwise complement of the two integer values on top of the stack and | |
| 2713 /// pushes the result onto the evaluation stack. | |
| 2714 /// </summary> | |
| 2715 /// <seealso cref="OpCodes.Or">OpCodes.Or</seealso> | |
| 2716 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2717 public EmitHelper or | |
| 2718 { | |
| 2719 get { _ilGenerator.Emit(OpCodes.Or); return this; } | |
| 2720 } | |
| 2721 | |
| 2722 /// <summary> | |
| 2723 /// Calls ILGenerator.Emit(<see cref="OpCodes.Pop"/>) that | |
| 2724 /// removes the value currently on top of the evaluation stack. | |
| 2725 /// </summary> | |
| 2726 /// <seealso cref="OpCodes.Pop">OpCodes.Pop</seealso> | |
| 2727 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2728 public EmitHelper pop | |
| 2729 { | |
| 2730 get { _ilGenerator.Emit(OpCodes.Pop); return this; } | |
| 2731 } | |
| 2732 | |
| 2733 /// <summary> | |
| 2734 /// Calls ILGenerator.Emit(<see cref="OpCodes.Refanytype"/>) that | |
| 2735 /// specifies that the subsequent array address operation performs | |
| 2736 /// no type check at run time, and that it returns a managed pointer | |
| 2737 /// whose mutability is restricted. | |
| 2738 /// </summary> | |
| 2739 /// <seealso cref="OpCodes.Refanytype">OpCodes.Refanytype</seealso> | |
| 2740 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2741 public EmitHelper @readonly | |
| 2742 { | |
| 2743 get { _ilGenerator.Emit(OpCodes.Readonly); return this; } | |
| 2744 } | |
| 2745 | |
| 2746 /// <summary> | |
| 2747 /// Calls ILGenerator.Emit(<see cref="OpCodes.Refanytype"/>) that | |
| 2748 /// retrieves the type token embedded in a typed reference. | |
| 2749 /// </summary> | |
| 2750 /// <seealso cref="OpCodes.Refanytype">OpCodes.Refanytype</seealso> | |
| 2751 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2752 public EmitHelper refanytype | |
| 2753 { | |
| 2754 get { _ilGenerator.Emit(OpCodes.Refanytype); return this; } | |
| 2755 } | |
| 2756 | |
| 2757 /// <summary> | |
| 2758 /// Calls ILGenerator.Emit(<see cref="OpCodes.Refanyval"/>, type) that | |
| 2759 /// retrieves the address (type &) embedded in a typed reference. | |
| 2760 /// </summary> | |
| 2761 /// <param name="type">A Type</param> | |
| 2762 /// <seealso cref="OpCodes.Refanyval">OpCodes.Refanyval</seealso> | |
| 2763 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 2764 public EmitHelper refanyval(Type type) | |
| 2765 { | |
| 2766 _ilGenerator.Emit(OpCodes.Refanyval, type); return this; | |
| 2767 } | |
| 2768 | |
| 2769 /// <summary> | |
| 2770 /// Calls ILGenerator.Emit(<see cref="OpCodes.Rem"/>) that | |
| 2771 /// divides two values and pushes the remainder onto the evaluation stack. | |
| 2772 /// </summary> | |
| 2773 /// <seealso cref="OpCodes.Rem">OpCodes.Rem</seealso> | |
| 2774 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2775 public EmitHelper rem | |
| 2776 { | |
| 2777 get { _ilGenerator.Emit(OpCodes.Rem); return this; } | |
| 2778 } | |
| 2779 | |
| 2780 /// <summary> | |
| 2781 /// Calls ILGenerator.Emit(<see cref="OpCodes.Rem_Un"/>) that | |
| 2782 /// divides two unsigned values and pushes the remainder onto the evaluation stack. | |
| 2783 /// </summary> | |
| 2784 /// <seealso cref="OpCodes.Rem_Un">OpCodes.Rem_Un</seealso> | |
| 2785 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2786 public EmitHelper rem_un | |
| 2787 { | |
| 2788 get { _ilGenerator.Emit(OpCodes.Rem_Un); return this; } | |
| 2789 } | |
| 2790 | |
| 2791 /// <summary> | |
| 2792 /// Calls ILGenerator.Emit(<see cref="OpCodes.Ret"/>) that | |
| 2793 /// returns from the current method, pushing a return value (if present) | |
| 2794 /// from the caller's evaluation stack onto the callee's evaluation stack. | |
| 2795 /// </summary> | |
| 2796 /// <seealso cref="OpCodes.Ret">OpCodes.Ret</seealso> | |
| 2797 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2798 public EmitHelper ret() | |
| 2799 { | |
| 2800 _ilGenerator.Emit(OpCodes.Ret); return this; | |
| 2801 } | |
| 2802 | |
| 2803 /// <summary> | |
| 2804 /// Calls ILGenerator.Emit(<see cref="OpCodes.Rethrow"/>) that | |
| 2805 /// rethrows the current exception. | |
| 2806 /// </summary> | |
| 2807 /// <seealso cref="OpCodes.Rethrow">OpCodes.Rethrow</seealso> | |
| 2808 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2809 public EmitHelper rethrow | |
| 2810 { | |
| 2811 get { _ilGenerator.Emit(OpCodes.Rethrow); return this; } | |
| 2812 } | |
| 2813 | |
| 2814 /// <summary> | |
| 2815 /// Calls ILGenerator.Emit(<see cref="OpCodes.Shl"/>) that | |
| 2816 /// shifts an integer value to the left (in zeroes) by a specified number of bits, | |
| 2817 /// pushing the result onto the evaluation stack. | |
| 2818 /// </summary> | |
| 2819 /// <seealso cref="OpCodes.Shl">OpCodes.Shl</seealso> | |
| 2820 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2821 public EmitHelper shl | |
| 2822 { | |
| 2823 get { _ilGenerator.Emit(OpCodes.Shl); return this; } | |
| 2824 } | |
| 2825 | |
| 2826 /// <summary> | |
| 2827 /// Calls ILGenerator.Emit(<see cref="OpCodes.Shr"/>) that | |
| 2828 /// shifts an integer value (in sign) to the right by a specified number of bits, | |
| 2829 /// pushing the result onto the evaluation stack. | |
| 2830 /// </summary> | |
| 2831 /// <seealso cref="OpCodes.Shr">OpCodes.Shr</seealso> | |
| 2832 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2833 public EmitHelper shr | |
| 2834 { | |
| 2835 get { _ilGenerator.Emit(OpCodes.Shr); return this; } | |
| 2836 } | |
| 2837 | |
| 2838 /// <summary> | |
| 2839 /// Calls ILGenerator.Emit(<see cref="OpCodes.Shr_Un"/>) that | |
| 2840 /// shifts an unsigned integer value (in zeroes) to the right by a specified number of bits, | |
| 2841 /// pushing the result onto the evaluation stack. | |
| 2842 /// </summary> | |
| 2843 /// <seealso cref="OpCodes.Shr_Un">OpCodes.Shr_Un</seealso> | |
| 2844 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2845 public EmitHelper shr_un | |
| 2846 { | |
| 2847 get { _ilGenerator.Emit(OpCodes.Shr_Un); return this; } | |
| 2848 } | |
| 2849 | |
| 2850 /// <summary> | |
| 2851 /// Calls ILGenerator.Emit(<see cref="OpCodes.Sizeof"/>, type) that | |
| 2852 /// pushes the size, in bytes, of a supplied value type onto the evaluation stack. | |
| 2853 /// </summary> | |
| 2854 /// <param name="type">A Type</param> | |
| 2855 /// <seealso cref="OpCodes.Sizeof">OpCodes.Sizeof</seealso> | |
| 2856 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 2857 public EmitHelper @sizeof(Type type) | |
| 2858 { | |
| 2859 _ilGenerator.Emit(OpCodes.Sizeof, type); return this; | |
| 2860 } | |
| 2861 | |
| 2862 /// <summary> | |
| 2863 /// Calls ILGenerator.Emit(<see cref="OpCodes.Starg"/>, short) that | |
| 2864 /// stores the value on top of the evaluation stack in the argument slot at a specified index. | |
| 2865 /// </summary> | |
| 2866 /// <param name="index">Slot index.</param> | |
| 2867 /// <seealso cref="OpCodes.Starg">OpCodes.Starg</seealso> | |
| 2868 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,short)">ILGenerator.Emit</seealso> | |
| 2869 public EmitHelper starg(short index) | |
| 2870 { | |
| 2871 _ilGenerator.Emit(OpCodes.Starg, index); return this; | |
| 2872 } | |
| 2873 | |
| 2874 /// <summary> | |
| 2875 /// Calls ILGenerator.Emit(<see cref="OpCodes.Starg_S"/>, byte) that | |
| 2876 /// stores the value on top of the evaluation stack in the argument slot at a specified index, | |
| 2877 /// short form. | |
| 2878 /// </summary> | |
| 2879 /// <param name="index">Slot index.</param> | |
| 2880 /// <seealso cref="OpCodes.Starg_S">OpCodes.Starg_S</seealso> | |
| 2881 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,byte)">ILGenerator.Emit</seealso> | |
| 2882 public EmitHelper starg_s(byte index) | |
| 2883 { | |
| 2884 _ilGenerator.Emit(OpCodes.Starg_S, index); return this; | |
| 2885 } | |
| 2886 | |
| 2887 /// <summary> | |
| 2888 /// Stores the value on top of the evaluation stack in the argument slot at a specified index. | |
| 2889 /// </summary> | |
| 2890 /// <param name="index">Slot index.</param> | |
| 2891 /// <seealso cref="OpCodes.Starg">OpCodes.Starg</seealso> | |
| 2892 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,short)">ILGenerator.Emit</seealso> | |
| 2893 public EmitHelper starg(int index) | |
| 2894 { | |
| 2895 if (index < byte. MaxValue) starg_s((byte)index); | |
| 2896 else if (index < short.MaxValue) starg ((short)index); | |
| 2897 else | |
| 2898 throw new ArgumentOutOfRangeException("index"); | |
| 2899 | |
| 2900 return this; | |
| 2901 } | |
| 2902 | |
| 2903 /// <summary> | |
| 2904 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stelem_I"/>) that | |
| 2905 /// replaces the array element at a given index with the natural int value | |
| 2906 /// on the evaluation stack. | |
| 2907 /// </summary> | |
| 2908 /// <seealso cref="OpCodes.Stelem_I">OpCodes.Stelem_I</seealso> | |
| 2909 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2910 public EmitHelper stelem_i | |
| 2911 { | |
| 2912 get { _ilGenerator.Emit(OpCodes.Stelem_I); return this; } | |
| 2913 } | |
| 2914 | |
| 2915 /// <summary> | |
| 2916 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stelem_I1"/>) that | |
| 2917 /// replaces the array element at a given index with the int8 value on the evaluation stack. | |
| 2918 /// </summary> | |
| 2919 /// <seealso cref="OpCodes.Stelem_I1">OpCodes.Stelem_I1</seealso> | |
| 2920 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2921 public EmitHelper stelem_i1 | |
| 2922 { | |
| 2923 get { _ilGenerator.Emit(OpCodes.Stelem_I1); return this; } | |
| 2924 } | |
| 2925 | |
| 2926 /// <summary> | |
| 2927 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stelem_I2"/>) that | |
| 2928 /// replaces the array element at a given index with the int16 value on the evaluation stack. | |
| 2929 /// </summary> | |
| 2930 /// <seealso cref="OpCodes.Stelem_I2">OpCodes.Stelem_I2</seealso> | |
| 2931 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2932 public EmitHelper stelem_i2 | |
| 2933 { | |
| 2934 get { _ilGenerator.Emit(OpCodes.Stelem_I2); return this; } | |
| 2935 } | |
| 2936 | |
| 2937 /// <summary> | |
| 2938 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stelem_I4"/>) that | |
| 2939 /// replaces the array element at a given index with the int32 value on the evaluation stack. | |
| 2940 /// </summary> | |
| 2941 /// <seealso cref="OpCodes.Stelem_I4">OpCodes.Stelem_I4</seealso> | |
| 2942 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2943 public EmitHelper stelem_i4 | |
| 2944 { | |
| 2945 get { _ilGenerator.Emit(OpCodes.Stelem_I4); return this; } | |
| 2946 } | |
| 2947 | |
| 2948 /// <summary> | |
| 2949 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stelem_I8"/>) that | |
| 2950 /// replaces the array element at a given index with the int64 value on the evaluation stack. | |
| 2951 /// </summary> | |
| 2952 /// <seealso cref="OpCodes.Stelem_I8">OpCodes.Stelem_I8</seealso> | |
| 2953 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2954 public EmitHelper stelem_i8 | |
| 2955 { | |
| 2956 get { _ilGenerator.Emit(OpCodes.Stelem_I8); return this; } | |
| 2957 } | |
| 2958 | |
| 2959 /// <summary> | |
| 2960 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stelem_R4"/>) that | |
| 2961 /// replaces the array element at a given index with the float32 value on the evaluation stack. | |
| 2962 /// </summary> | |
| 2963 /// <seealso cref="OpCodes.Stelem_R4">OpCodes.Stelem_R4</seealso> | |
| 2964 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2965 public EmitHelper stelem_r4 | |
| 2966 { | |
| 2967 get { _ilGenerator.Emit(OpCodes.Stelem_R4); return this; } | |
| 2968 } | |
| 2969 | |
| 2970 /// <summary> | |
| 2971 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stelem_R8"/>) that | |
| 2972 /// replaces the array element at a given index with the float64 value on the evaluation stack. | |
| 2973 /// </summary> | |
| 2974 /// <seealso cref="OpCodes.Stelem_R8">OpCodes.Stelem_R8</seealso> | |
| 2975 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2976 public EmitHelper stelem_r8 | |
| 2977 { | |
| 2978 get { _ilGenerator.Emit(OpCodes.Stelem_R8); return this; } | |
| 2979 } | |
| 2980 | |
| 2981 /// <summary> | |
| 2982 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stelem_Ref"/>) that | |
| 2983 /// replaces the array element at a given index with the object ref value (type O) | |
| 2984 /// on the evaluation stack. | |
| 2985 /// </summary> | |
| 2986 /// <seealso cref="OpCodes.Stelem_Ref">OpCodes.Stelem_Ref</seealso> | |
| 2987 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 2988 public EmitHelper stelem_ref | |
| 2989 { | |
| 2990 get { _ilGenerator.Emit(OpCodes.Stelem_Ref); return this; } | |
| 2991 } | |
| 2992 | |
| 2993 /// <summary> | |
| 2994 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stfld"/>, <see cref="FieldInfo"/>) that | |
| 2995 /// replaces the value stored in the field of an object reference or pointer with a new value. | |
| 2996 /// </summary> | |
| 2997 /// <param name="fieldInfo">A <see cref="FieldInfo"/> representing a field.</param> | |
| 2998 /// <seealso cref="OpCodes.Stfld">OpCodes.Stfld</seealso> | |
| 2999 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,FieldInfo)">ILGenerator.Emit</seealso> | |
| 3000 public EmitHelper stfld(FieldInfo fieldInfo) | |
| 3001 { | |
| 3002 _ilGenerator.Emit(OpCodes.Stfld, fieldInfo); return this; | |
| 3003 } | |
| 3004 | |
| 3005 /// <summary> | |
| 3006 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stind_I"/>) that | |
| 3007 /// stores a value of type natural int at a supplied address. | |
| 3008 /// </summary> | |
| 3009 /// <seealso cref="OpCodes.Stind_I">OpCodes.Stind_I</seealso> | |
| 3010 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3011 public EmitHelper stind_i | |
| 3012 { | |
| 3013 get { _ilGenerator.Emit(OpCodes.Stind_I); return this; } | |
| 3014 } | |
| 3015 | |
| 3016 /// <summary> | |
| 3017 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stind_I1"/>) that | |
| 3018 /// stores a value of type int8 at a supplied address. | |
| 3019 /// </summary> | |
| 3020 /// <seealso cref="OpCodes.Stind_I1">OpCodes.Stind_I1</seealso> | |
| 3021 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3022 public EmitHelper stind_i1 | |
| 3023 { | |
| 3024 get { _ilGenerator.Emit(OpCodes.Stind_I1); return this; } | |
| 3025 } | |
| 3026 | |
| 3027 /// <summary> | |
| 3028 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stind_I2"/>) that | |
| 3029 /// stores a value of type int16 at a supplied address. | |
| 3030 /// </summary> | |
| 3031 /// <seealso cref="OpCodes.Stind_I2">OpCodes.Stind_I2</seealso> | |
| 3032 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3033 public EmitHelper stind_i2 | |
| 3034 { | |
| 3035 get { _ilGenerator.Emit(OpCodes.Stind_I2); return this; } | |
| 3036 } | |
| 3037 | |
| 3038 /// <summary> | |
| 3039 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stind_I4"/>) that | |
| 3040 /// stores a value of type int32 at a supplied address. | |
| 3041 /// </summary> | |
| 3042 /// <seealso cref="OpCodes.Stind_I4">OpCodes.Stind_I4</seealso> | |
| 3043 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3044 public EmitHelper stind_i4 | |
| 3045 { | |
| 3046 get { _ilGenerator.Emit(OpCodes.Stind_I4); return this; } | |
| 3047 } | |
| 3048 | |
| 3049 /// <summary> | |
| 3050 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stind_I8"/>) that | |
| 3051 /// stores a value of type int64 at a supplied address. | |
| 3052 /// </summary> | |
| 3053 /// <seealso cref="OpCodes.Stind_I8">OpCodes.Stind_I8</seealso> | |
| 3054 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3055 public EmitHelper stind_i8 | |
| 3056 { | |
| 3057 get { _ilGenerator.Emit(OpCodes.Stind_I8); return this; } | |
| 3058 } | |
| 3059 | |
| 3060 /// <summary> | |
| 3061 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stind_R4"/>) that | |
| 3062 /// stores a value of type float32 at a supplied address. | |
| 3063 /// </summary> | |
| 3064 /// <seealso cref="OpCodes.Stind_R4">OpCodes.Stind_R4</seealso> | |
| 3065 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3066 public EmitHelper stind_r4 | |
| 3067 { | |
| 3068 get { _ilGenerator.Emit(OpCodes.Stind_R4); return this; } | |
| 3069 } | |
| 3070 | |
| 3071 /// <summary> | |
| 3072 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stind_R8"/>) that | |
| 3073 /// stores a value of type float64 at a supplied address. | |
| 3074 /// </summary> | |
| 3075 /// <seealso cref="OpCodes.Stind_R8">OpCodes.Stind_R8</seealso> | |
| 3076 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3077 public EmitHelper stind_r8 | |
| 3078 { | |
| 3079 get { _ilGenerator.Emit(OpCodes.Stind_R8); return this; } | |
| 3080 } | |
| 3081 | |
| 3082 /// <summary> | |
| 3083 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stind_Ref"/>) that | |
| 3084 /// stores an object reference value at a supplied address. | |
| 3085 /// </summary> | |
| 3086 /// <seealso cref="OpCodes.Stind_Ref">OpCodes.Stind_Ref</seealso> | |
| 3087 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3088 public EmitHelper stind_ref | |
| 3089 { | |
| 3090 get { _ilGenerator.Emit(OpCodes.Stind_Ref); return this; } | |
| 3091 } | |
| 3092 | |
| 3093 /// <summary> | |
| 3094 /// Stores a value of the type at a supplied address. | |
| 3095 /// </summary> | |
| 3096 /// <param name="type">A Type.</param> | |
| 3097 public EmitHelper stind(Type type) | |
| 3098 { | |
| 3099 if (type == null) throw new ArgumentNullException("type"); | |
| 3100 | |
| 3101 switch (Type.GetTypeCode(type)) | |
| 3102 { | |
| 3103 case TypeCode.Boolean: | |
| 3104 case TypeCode.Byte: | |
| 3105 case TypeCode.SByte: stind_i1.end(); break; | |
| 3106 | |
| 3107 case TypeCode.Char: | |
| 3108 case TypeCode.Int16: | |
| 3109 case TypeCode.UInt16: stind_i2.end(); break; | |
| 3110 | |
| 3111 case TypeCode.Int32: | |
| 3112 case TypeCode.UInt32: stind_i4.end(); break; | |
| 3113 | |
| 3114 case TypeCode.Int64: | |
| 3115 case TypeCode.UInt64: stind_i8.end(); break; | |
| 3116 | |
| 3117 case TypeCode.Single: stind_r4.end(); break; | |
| 3118 case TypeCode.Double: stind_r8.end(); break; | |
| 3119 | |
| 3120 default: | |
| 3121 if (type.IsClass) | |
| 3122 stind_ref.end(); | |
| 3123 else if (type.IsValueType) | |
| 3124 stobj(type); | |
| 3125 else | |
| 3126 throw CreateNotExpectedTypeException(type); | |
| 3127 break; | |
| 3128 } | |
| 3129 | |
| 3130 return this; | |
| 3131 } | |
| 3132 | |
| 3133 /// <summary> | |
| 3134 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stloc"/>, <see cref="LocalBuilder"/>) that | |
| 3135 /// pops the current value from the top of the evaluation stack and stores it | |
| 3136 /// in the local variable list at a specified index. | |
| 3137 /// </summary> | |
| 3138 /// <param name="local">A local variable.</param> | |
| 3139 /// <seealso cref="OpCodes.Stloc">OpCodes.Stloc</seealso> | |
| 3140 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,LocalBuilder)">ILGenerator.Emit</seealso> | |
| 3141 public EmitHelper stloc(LocalBuilder local) | |
| 3142 { | |
| 3143 _ilGenerator.Emit(OpCodes.Stloc, local); return this; | |
| 3144 } | |
| 3145 | |
| 3146 /// <summary> | |
| 3147 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stloc"/>, short) that | |
| 3148 /// pops the current value from the top of the evaluation stack and stores it | |
| 3149 /// in the local variable list at a specified index. | |
| 3150 /// </summary> | |
| 3151 /// <param name="index">A local variable index.</param> | |
| 3152 /// <seealso cref="OpCodes.Stloc">OpCodes.Stloc</seealso> | |
| 3153 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,short)">ILGenerator.Emit</seealso> | |
| 3154 public EmitHelper stloc(short index) | |
| 3155 { | |
| 3156 if (index >= byte.MinValue && index <= byte.MaxValue) | |
| 3157 return stloc_s((byte)index); | |
| 3158 | |
| 3159 _ilGenerator.Emit(OpCodes.Stloc, index); | |
| 3160 return this; | |
| 3161 } | |
| 3162 | |
| 3163 /// <summary> | |
| 3164 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stloc_0"/>) that | |
| 3165 /// pops the current value from the top of the evaluation stack and stores it | |
| 3166 /// in the local variable list at index 0. | |
| 3167 /// </summary> | |
| 3168 /// <seealso cref="OpCodes.Stloc_0">OpCodes.Stloc_0</seealso> | |
| 3169 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3170 public EmitHelper stloc_0 | |
| 3171 { | |
| 3172 get { _ilGenerator.Emit(OpCodes.Stloc_0); return this; } | |
| 3173 } | |
| 3174 | |
| 3175 /// <summary> | |
| 3176 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stloc_1"/>) that | |
| 3177 /// pops the current value from the top of the evaluation stack and stores it | |
| 3178 /// in the local variable list at index 1. | |
| 3179 /// </summary> | |
| 3180 /// <seealso cref="OpCodes.Stloc_1">OpCodes.Stloc_1</seealso> | |
| 3181 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3182 public EmitHelper stloc_1 | |
| 3183 { | |
| 3184 get { _ilGenerator.Emit(OpCodes.Stloc_1); return this; } | |
| 3185 } | |
| 3186 | |
| 3187 /// <summary> | |
| 3188 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stloc_2"/>) that | |
| 3189 /// pops the current value from the top of the evaluation stack and stores it | |
| 3190 /// in the local variable list at index 2. | |
| 3191 /// </summary> | |
| 3192 /// <seealso cref="OpCodes.Stloc_2">OpCodes.Stloc_2</seealso> | |
| 3193 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3194 public EmitHelper stloc_2 | |
| 3195 { | |
| 3196 get { _ilGenerator.Emit(OpCodes.Stloc_2); return this; } | |
| 3197 } | |
| 3198 | |
| 3199 /// <summary> | |
| 3200 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stloc_3"/>) that | |
| 3201 /// pops the current value from the top of the evaluation stack and stores it | |
| 3202 /// in the local variable list at index 3. | |
| 3203 /// </summary> | |
| 3204 /// <seealso cref="OpCodes.Stloc_3">OpCodes.Stloc_3</seealso> | |
| 3205 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3206 public EmitHelper stloc_3 | |
| 3207 { | |
| 3208 get { _ilGenerator.Emit(OpCodes.Stloc_3); return this; } | |
| 3209 } | |
| 3210 | |
| 3211 /// <summary> | |
| 3212 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stloc_S"/>, <see cref="LocalBuilder"/>) that | |
| 3213 /// pops the current value from the top of the evaluation stack and stores it | |
| 3214 /// in the local variable list at index (short form). | |
| 3215 /// </summary> | |
| 3216 /// <param name="local">A local variable.</param> | |
| 3217 /// <seealso cref="OpCodes.Stloc_S">OpCodes.Stloc_S</seealso> | |
| 3218 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,LocalBuilder)">ILGenerator.Emit</seealso> | |
| 3219 public EmitHelper stloc_s(LocalBuilder local) | |
| 3220 { | |
| 3221 _ilGenerator.Emit(OpCodes.Stloc_S, local); return this; | |
| 3222 } | |
| 3223 | |
| 3224 /// <summary> | |
| 3225 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stloc_S"/>, byte) that | |
| 3226 /// pops the current value from the top of the evaluation stack and stores it | |
| 3227 /// in the local variable list at index (short form). | |
| 3228 /// </summary> | |
| 3229 /// <param name="index">A local variable index.</param> | |
| 3230 /// <seealso cref="OpCodes.Stloc_S">OpCodes.Stloc_S</seealso> | |
| 3231 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,short)">ILGenerator.Emit</seealso> | |
| 3232 public EmitHelper stloc_s(byte index) | |
| 3233 { | |
| 3234 switch (index) | |
| 3235 { | |
| 3236 case 0: stloc_0.end(); break; | |
| 3237 case 1: stloc_1.end(); break; | |
| 3238 case 2: stloc_2.end(); break; | |
| 3239 case 3: stloc_3.end(); break; | |
| 3240 | |
| 3241 default: | |
| 3242 _ilGenerator.Emit(OpCodes.Stloc_S, index); break; | |
| 3243 } | |
| 3244 | |
| 3245 return this; | |
| 3246 } | |
| 3247 | |
| 3248 /// <summary> | |
| 3249 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stobj"/>, type) that | |
| 3250 /// copies a value of a specified type from the evaluation stack into a supplied memory address. | |
| 3251 /// </summary> | |
| 3252 /// <param name="type">A Type</param> | |
| 3253 /// <seealso cref="OpCodes.Stobj">OpCodes.Stobj</seealso> | |
| 3254 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 3255 public EmitHelper stobj(Type type) | |
| 3256 { | |
| 3257 _ilGenerator.Emit(OpCodes.Stobj, type); return this; | |
| 3258 } | |
| 3259 | |
| 3260 /// <summary> | |
| 3261 /// Calls ILGenerator.Emit(<see cref="OpCodes.Stsfld"/>, fieldInfo) that | |
| 3262 /// replaces the value of a static field with a value from the evaluation stack. | |
| 3263 /// </summary> | |
| 3264 /// <param name="fieldInfo">A <see cref="FieldInfo"/> representing a field.</param> | |
| 3265 /// <seealso cref="OpCodes.Stsfld">OpCodes.Stsfld</seealso> | |
| 3266 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,FieldInfo)">ILGenerator.Emit</seealso> | |
| 3267 public EmitHelper stsfld(FieldInfo fieldInfo) | |
| 3268 { | |
| 3269 _ilGenerator.Emit(OpCodes.Stsfld, fieldInfo); return this; | |
| 3270 } | |
| 3271 | |
| 3272 /// <summary> | |
| 3273 /// Calls ILGenerator.Emit(<see cref="OpCodes.Sub"/>) that | |
| 3274 /// subtracts one value from another and pushes the result onto the evaluation stack. | |
| 3275 /// </summary> | |
| 3276 /// <seealso cref="OpCodes.Sub">OpCodes.Sub</seealso> | |
| 3277 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3278 public EmitHelper sub | |
| 3279 { | |
| 3280 get { _ilGenerator.Emit(OpCodes.Sub); return this; } | |
| 3281 } | |
| 3282 | |
| 3283 /// <summary> | |
| 3284 /// Calls ILGenerator.Emit(<see cref="OpCodes.Sub_Ovf"/>) that | |
| 3285 /// subtracts one integer value from another, performs an overflow check, | |
| 3286 /// and pushes the result onto the evaluation stack. | |
| 3287 /// </summary> | |
| 3288 /// <seealso cref="OpCodes.Sub_Ovf">OpCodes.Sub_Ovf</seealso> | |
| 3289 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3290 public EmitHelper sub_ovf | |
| 3291 { | |
| 3292 get { _ilGenerator.Emit(OpCodes.Sub_Ovf); return this; } | |
| 3293 } | |
| 3294 | |
| 3295 /// <summary> | |
| 3296 /// Calls ILGenerator.Emit(<see cref="OpCodes.Sub_Ovf_Un"/>) that | |
| 3297 /// subtracts one unsigned integer value from another, performs an overflow check, | |
| 3298 /// and pushes the result onto the evaluation stack. | |
| 3299 /// </summary> | |
| 3300 /// <seealso cref="OpCodes.Sub_Ovf_Un">OpCodes.Sub_Ovf_Un</seealso> | |
| 3301 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3302 public EmitHelper sub_ovf_un | |
| 3303 { | |
| 3304 get { _ilGenerator.Emit(OpCodes.Sub_Ovf_Un); return this; } | |
| 3305 } | |
| 3306 | |
| 3307 /// <summary> | |
| 3308 /// Calls ILGenerator.Emit(<see cref="OpCodes.Switch"/>, label[]) that | |
| 3309 /// implements a jump table. | |
| 3310 /// </summary> | |
| 3311 /// <param name="labels">The array of label objects to which to branch from this location.</param> | |
| 3312 /// <seealso cref="OpCodes.Switch">OpCodes.Switch</seealso> | |
| 3313 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label[])">ILGenerator.Emit</seealso> | |
| 3314 public EmitHelper @switch(Label[] labels) | |
| 3315 { | |
| 3316 _ilGenerator.Emit(OpCodes.Switch, labels); return this; | |
| 3317 } | |
| 3318 | |
| 3319 /// <summary> | |
| 3320 /// Calls ILGenerator.Emit(<see cref="OpCodes.Tailcall"/>) that | |
| 3321 /// performs a postfixed method call instruction such that the current method's stack frame | |
| 3322 /// is removed before the actual call instruction is executed. | |
| 3323 /// </summary> | |
| 3324 /// <seealso cref="OpCodes.Tailcall">OpCodes.Tailcall</seealso> | |
| 3325 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3326 public EmitHelper tailcall | |
| 3327 { | |
| 3328 get { _ilGenerator.Emit(OpCodes.Tailcall); return this; } | |
| 3329 } | |
| 3330 | |
| 3331 /// <summary> | |
| 3332 /// Calls ILGenerator.Emit(<see cref="OpCodes.Throw"/>) that | |
| 3333 /// throws the exception object currently on the evaluation stack. | |
| 3334 /// </summary> | |
| 3335 /// <seealso cref="OpCodes.Throw">OpCodes.Throw</seealso> | |
| 3336 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3337 public EmitHelper @throw | |
| 3338 { | |
| 3339 get { _ilGenerator.Emit(OpCodes.Throw); return this; } | |
| 3340 } | |
| 3341 | |
| 3342 /// <summary> | |
| 3343 /// Calls ILGenerator.Emit(<see cref="OpCodes.Unaligned"/>, label) that | |
| 3344 /// indicates that an address currently atop the evaluation stack might not be aligned | |
| 3345 /// to the natural size of the immediately following ldind, stind, ldfld, stfld, ldobj, stobj, | |
| 3346 /// initblk, or cpblk instruction. | |
| 3347 /// </summary> | |
| 3348 /// <param name="label">The label to branch from this location.</param> | |
| 3349 /// <seealso cref="OpCodes.Unaligned">OpCodes.Unaligned</seealso> | |
| 3350 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Label)">ILGenerator.Emit</seealso> | |
| 3351 public EmitHelper unaligned(Label label) | |
| 3352 { | |
| 3353 _ilGenerator.Emit(OpCodes.Unaligned, label); return this; | |
| 3354 } | |
| 3355 | |
| 3356 /// <summary> | |
| 3357 /// Calls ILGenerator.Emit(<see cref="OpCodes.Unaligned"/>, long) that | |
| 3358 /// indicates that an address currently atop the evaluation stack might not be aligned | |
| 3359 /// to the natural size of the immediately following ldind, stind, ldfld, stfld, ldobj, stobj, | |
| 3360 /// initblk, or cpblk instruction. | |
| 3361 /// </summary> | |
| 3362 /// <param name="addr">An address is pushed onto the stack.</param> | |
| 3363 /// <seealso cref="OpCodes.Unaligned">OpCodes.Unaligned</seealso> | |
| 3364 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,long)">ILGenerator.Emit</seealso> | |
| 3365 public EmitHelper unaligned(long addr) | |
| 3366 { | |
| 3367 _ilGenerator.Emit(OpCodes.Unaligned, addr); return this; | |
| 3368 } | |
| 3369 | |
| 3370 /// <summary> | |
| 3371 /// Calls ILGenerator.Emit(<see cref="OpCodes.Unbox"/>, type) that | |
| 3372 /// converts the boxed representation of a value type to its unboxed form. | |
| 3373 /// </summary> | |
| 3374 /// <param name="type">A Type</param> | |
| 3375 /// <seealso cref="OpCodes.Unbox">OpCodes.Unbox</seealso> | |
| 3376 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 3377 public EmitHelper unbox(Type type) | |
| 3378 { | |
| 3379 _ilGenerator.Emit(OpCodes.Unbox, type); return this; | |
| 3380 } | |
| 3381 | |
| 3382 /// <summary> | |
| 3383 /// Calls ILGenerator.Emit(<see cref="OpCodes.Unbox_Any"/>, type) that | |
| 3384 /// converts the boxed representation of a value type to its unboxed form. | |
| 3385 /// </summary> | |
| 3386 /// <param name="type">A Type</param> | |
| 3387 /// <seealso cref="OpCodes.Unbox_Any">OpCodes.Unbox_Any</seealso> | |
| 3388 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 3389 public EmitHelper unbox_any(Type type) | |
| 3390 { | |
| 3391 _ilGenerator.Emit(OpCodes.Unbox_Any, type); | |
| 3392 return this; | |
| 3393 } | |
| 3394 | |
| 3395 /// <summary> | |
| 3396 /// Calls <see cref="unbox_any(Type)"/> if given type is a value type. | |
| 3397 /// </summary> | |
| 3398 /// <param name="type">A Type</param> | |
| 3399 /// <seealso cref="OpCodes.Unbox_Any">OpCodes.Unbox</seealso> | |
| 3400 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode,Type)">ILGenerator.Emit</seealso> | |
| 3401 public EmitHelper unboxIfValueType(Type type) | |
| 3402 { | |
| 3403 if (type == null) throw new ArgumentNullException("type"); | |
| 3404 | |
| 3405 return type.IsValueType? unbox_any(type): this; | |
| 3406 } | |
| 3407 | |
| 3408 /// <summary> | |
| 3409 /// Calls ILGenerator.Emit(<see cref="OpCodes.Volatile"/>) that | |
| 3410 /// specifies that an address currently atop the evaluation stack might be volatile, | |
| 3411 /// and the results of reading that location cannot be cached or that multiple stores | |
| 3412 /// to that location cannot be suppressed. | |
| 3413 /// </summary> | |
| 3414 /// <seealso cref="OpCodes.Volatile">OpCodes.Volatile</seealso> | |
| 3415 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3416 public EmitHelper @volatile | |
| 3417 { | |
| 3418 get { _ilGenerator.Emit(OpCodes.Volatile); return this; } | |
| 3419 } | |
| 3420 | |
| 3421 /// <summary> | |
| 3422 /// Calls ILGenerator.Emit(<see cref="OpCodes.Xor"/>) that | |
| 3423 /// computes the bitwise XOR of the top two values on the evaluation stack, | |
| 3424 /// pushing the result onto the evaluation stack. | |
| 3425 /// </summary> | |
| 3426 /// <seealso cref="OpCodes.Xor">OpCodes.Xor</seealso> | |
| 3427 /// <seealso cref="System.Reflection.Emit.ILGenerator.Emit(OpCode)">ILGenerator.Emit</seealso> | |
| 3428 public EmitHelper xor | |
| 3429 { | |
| 3430 get { _ilGenerator.Emit(OpCodes.Xor); return this; } | |
| 3431 } | |
| 3432 | |
| 3433 /// <summary> | |
| 3434 /// Ends sequence of property calls. | |
| 3435 /// </summary> | |
| 3436 [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] | |
| 3437 public void end() | |
| 3438 { | |
| 3439 } | |
| 3440 | |
| 3441 #endregion | |
| 3442 | |
| 3443 /// <summary> | |
| 3444 /// Loads default value of given type onto the evaluation stack. | |
| 3445 /// </summary> | |
| 3446 /// <param name="type">A Type</param> | |
| 3447 public EmitHelper LoadInitValue(Type type) | |
| 3448 { | |
| 3449 if (type == null) throw new ArgumentNullException("type"); | |
| 3450 | |
| 3451 switch (Type.GetTypeCode(type)) | |
| 3452 { | |
| 3453 case TypeCode.Boolean: | |
| 3454 case TypeCode.Char: | |
| 3455 case TypeCode.SByte: | |
| 3456 case TypeCode.Int16: | |
| 3457 case TypeCode.Int32: | |
| 3458 case TypeCode.Byte: | |
| 3459 case TypeCode.UInt16: | |
| 3460 case TypeCode.UInt32: | |
| 3461 ldc_i4_0.end(); | |
| 3462 break; | |
| 3463 | |
| 3464 case TypeCode.Int64: | |
| 3465 case TypeCode.UInt64: | |
| 3466 ldc_i4_0.conv_i8.end(); | |
| 3467 break; | |
| 3468 | |
| 3469 case TypeCode.Single: | |
| 3470 case TypeCode.Double: | |
| 3471 ldc_r4(0).end(); | |
| 3472 break; | |
| 3473 | |
| 3474 case TypeCode.String: | |
| 3475 ldsfld(typeof(string).GetField("Empty")); | |
| 3476 break; | |
| 3477 | |
| 3478 default: | |
| 3479 if (type.IsClass || type.IsInterface) | |
| 3480 ldnull.end(); | |
| 3481 else | |
| 3482 throw CreateNotExpectedTypeException(type); | |
| 3483 break; | |
| 3484 } | |
| 3485 | |
| 3486 return this; | |
| 3487 } | |
| 3488 | |
| 3489 /// <summary> | |
| 3490 /// Loads supplied object value (if possible) onto the evaluation stack. | |
| 3491 /// </summary> | |
| 3492 /// <param name="o">Any object instance or null reference.</param> | |
| 3493 /// <returns>True is a value was loaded, otherwise false.</returns> | |
| 3494 public bool LoadWellKnownValue(object o) | |
| 3495 { | |
| 3496 if (o == null) | |
| 3497 ldnull.end(); | |
| 3498 else | |
| 3499 switch (Type.GetTypeCode(o.GetType())) | |
| 3500 { | |
| 3501 case TypeCode.Boolean: ldc_bool((Boolean)o); break; | |
| 3502 case TypeCode.Char: ldc_i4_ ((Char) o); break; | |
| 3503 case TypeCode.Single: ldc_r4 ((Single) o); break; | |
| 3504 case TypeCode.Double: ldc_r8 ((Double) o); break; | |
| 3505 case TypeCode.String: ldstr ((String) o); break; | |
| 3506 case TypeCode.SByte: ldc_i4_ ((SByte) o); break; | |
| 3507 case TypeCode.Int16: ldc_i4_ ((Int16) o); break; | |
| 3508 case TypeCode.Int32: ldc_i4_ ((Int32) o); break; | |
| 3509 case TypeCode.Int64: ldc_i8 ((Int64) o); break; | |
| 3510 case TypeCode.Byte: ldc_i4_ ((Byte) o); break; | |
| 3511 case TypeCode.UInt16: ldc_i4_ ((UInt16) o); break; | |
| 3512 case TypeCode.UInt32: ldc_i4_ (unchecked((Int32)(UInt32)o)); break; | |
| 3513 case TypeCode.UInt64: ldc_i8 (unchecked((Int64)(UInt64)o)); break; | |
| 3514 default: | |
| 3515 return false; | |
| 3516 } | |
| 3517 | |
| 3518 return true; | |
| 3519 } | |
| 3520 | |
| 3521 /// <summary> | |
| 3522 /// Initialize parameter with some default value. | |
| 3523 /// </summary> | |
| 3524 /// <param name="parameterInfo">A method parameter.</param> | |
| 3525 /// <param name="index">The parameter index.</param> | |
| 3526 public EmitHelper Init(ParameterInfo parameterInfo, int index) | |
| 3527 { | |
| 3528 if (parameterInfo == null) throw new ArgumentNullException("parameterInfo"); | |
| 3529 | |
| 3530 Type type = TypeHelper.GetUnderlyingType(parameterInfo.ParameterType); | |
| 3531 | |
| 3532 if (parameterInfo.ParameterType.IsByRef) | |
| 3533 { | |
| 3534 type = type.GetElementType(); | |
| 3535 | |
| 3536 return type.IsValueType && type.IsPrimitive == false? | |
| 3537 ldarg(index).initobj(type): | |
| 3538 ldarg(index).LoadInitValue(type).stind(type); | |
| 3539 } | |
| 3540 else | |
| 3541 { | |
| 3542 return type.IsValueType && type.IsPrimitive == false? | |
| 3543 ldarga(index).initobj(type): | |
| 3544 LoadInitValue(type).starg(index); | |
| 3545 } | |
| 3546 } | |
| 3547 | |
| 3548 /// <summary> | |
| 3549 /// Initialize all output parameters with some default value. | |
| 3550 /// </summary> | |
| 3551 /// <param name="parameters">A method parameters array.</param> | |
| 3552 public EmitHelper InitOutParameters(ParameterInfo[] parameters) | |
| 3553 { | |
| 3554 for (int i = 0; i < parameters.Length; i++) | |
| 3555 { | |
| 3556 ParameterInfo pi = parameters[i]; | |
| 3557 | |
| 3558 if (pi.IsOut) | |
| 3559 Init(pi, i + 1); | |
| 3560 } | |
| 3561 | |
| 3562 return this; | |
| 3563 } | |
| 3564 | |
| 3565 /// <summary> | |
| 3566 /// Initialize local variable with some default value. | |
| 3567 /// </summary> | |
| 3568 /// <param name="localBuilder">A method local variable.</param> | |
| 3569 public EmitHelper Init(LocalBuilder localBuilder) | |
| 3570 { | |
| 3571 if (localBuilder == null) throw new ArgumentNullException("localBuilder"); | |
| 3572 | |
| 3573 Type type = localBuilder.LocalType; | |
| 3574 | |
| 3575 if (type.IsEnum) | |
| 3576 type = Enum.GetUnderlyingType(type); | |
| 3577 | |
| 3578 return type.IsValueType && type.IsPrimitive == false? | |
| 3579 ldloca(localBuilder).initobj(type): | |
| 3580 LoadInitValue(type).stloc(localBuilder); | |
| 3581 } | |
| 3582 | |
| 3583 /// <summary> | |
| 3584 /// Loads a type instance at runtime. | |
| 3585 /// </summary> | |
| 3586 /// <param name="type">A type</param> | |
| 3587 public EmitHelper LoadType(Type type) | |
| 3588 { | |
| 3589 return type == null? | |
| 3590 ldnull: | |
| 3591 ldtoken(type).call(typeof(Type), "GetTypeFromHandle", typeof(RuntimeTypeHandle)); | |
| 3592 } | |
| 3593 | |
| 3594 /// <summary> | |
| 3595 /// Loads a field instance at runtime. | |
| 3596 /// </summary> | |
| 3597 /// <param name="fieldInfo">A <see cref="FieldInfo"/> representing a field.</param> | |
| 3598 public EmitHelper LoadField(FieldInfo fieldInfo) | |
| 3599 { | |
| 3600 return fieldInfo.IsStatic ? ldsfld(fieldInfo) : ldarg_0.ldfld(fieldInfo); | |
| 3601 } | |
| 3602 | |
| 3603 /// <summary> | |
| 3604 /// Cast an object passed by reference to the specified type | |
| 3605 /// or unbox a boxed value type. | |
| 3606 /// </summary> | |
| 3607 /// <param name="type">A type</param> | |
| 3608 public EmitHelper CastFromObject(Type type) | |
| 3609 { | |
| 3610 if (type == null) throw new ArgumentNullException("type"); | |
| 3611 | |
| 3612 return | |
| 3613 type == typeof(object)? this: | |
| 3614 (type.IsValueType? unbox_any(type): | |
| 3615 castclass(type)); | |
| 3616 } | |
| 3617 | |
| 3618 /// <summary> | |
| 3619 /// Cast an object passed by reference to the specified type | |
| 3620 /// or unbox a boxed value type unless <paramref name="expectedType"/> | |
| 3621 /// is a parent of <paramref name="actualType"/>. | |
| 3622 /// </summary> | |
| 3623 /// <param name="expectedType">A type required.</param> | |
| 3624 /// <param name="actualType">A type available.</param> | |
| 3625 public EmitHelper CastIfNecessary(Type expectedType, Type actualType) | |
| 3626 { | |
| 3627 if (expectedType == null) throw new ArgumentNullException("expectedType"); | |
| 3628 if (actualType == null) throw new ArgumentNullException("actualType"); | |
| 3629 | |
| 3630 return | |
| 3631 TypeHelper.IsSameOrParent(expectedType, actualType)? this: | |
| 3632 actualType.IsValueType? unbox_any(expectedType): | |
| 3633 castclass(expectedType); | |
| 3634 } | |
| 3635 | |
| 3636 /// <summary> | |
| 3637 /// Increase max stack size by specified delta. | |
| 3638 /// </summary> | |
| 3639 /// <param name="size">Number of bytes to enlarge max stack size.</param> | |
| 3640 public void AddMaxStackSize(int size) | |
| 3641 { | |
| 3642 // m_maxStackSize isn't public so we need some hacking here. | |
| 3643 // | |
| 3644 FieldInfo fi = _ilGenerator.GetType().GetField( | |
| 3645 "m_maxStackSize", BindingFlags.Instance | BindingFlags.NonPublic); | |
| 3646 | |
| 3647 if (fi != null) | |
| 3648 { | |
| 3649 size += (int)fi.GetValue(_ilGenerator); | |
| 3650 fi.SetValue(_ilGenerator, size); | |
| 3651 } | |
| 3652 } | |
| 3653 | |
| 3654 private static Exception CreateNoSuchMethodException(Type type, string methodName) | |
| 3655 { | |
| 3656 return new InvalidOperationException( | |
| 3657 string.Format(Resources.EmitHelper_NoSuchMethod, type.FullName, methodName)); | |
| 3658 } | |
| 3659 | |
| 3660 private static Exception CreateNotExpectedTypeException(Type type) | |
| 3661 { | |
| 3662 return new ArgumentException( | |
| 3663 string.Format(Resources.EmitHelper_NotExpectedType, type.FullName)); | |
| 3664 } | |
| 3665 } | |
| 3666 } |
