|
| 1 | +using System; |
| 2 | + |
| 3 | +namespace BinaryNinja |
| 4 | +{ |
| 5 | + public sealed partial class MediumLevelILFunction |
| 6 | + { |
| 7 | + /// <summary> |
| 8 | + /// Creates a floating-point constant from its raw binary representation. |
| 9 | + /// </summary> |
| 10 | + public MediumLevelILExpressionIndex EmitFloatConstRaw( |
| 11 | + ulong size, |
| 12 | + ulong value, |
| 13 | + SourceLocation? location = null) |
| 14 | + { |
| 15 | + return this.AddExpression( |
| 16 | + MediumLevelILOperation.MLIL_FLOAT_CONST, |
| 17 | + location, |
| 18 | + size, |
| 19 | + value); |
| 20 | + } |
| 21 | + |
| 22 | + /// <summary> |
| 23 | + /// Creates a single-precision floating-point constant. |
| 24 | + /// </summary> |
| 25 | + public MediumLevelILExpressionIndex EmitFloatConstSingle( |
| 26 | + float value, |
| 27 | + SourceLocation? location = null) |
| 28 | + { |
| 29 | + uint bits = BitConverter.SingleToUInt32Bits(value); |
| 30 | + |
| 31 | + return this.EmitFloatConstRaw(4, bits, location); |
| 32 | + } |
| 33 | + |
| 34 | + /// <summary> |
| 35 | + /// Creates a double-precision floating-point constant. |
| 36 | + /// </summary> |
| 37 | + public MediumLevelILExpressionIndex EmitFloatConstDouble( |
| 38 | + double value, |
| 39 | + SourceLocation? location = null) |
| 40 | + { |
| 41 | + ulong bits = BitConverter.DoubleToUInt64Bits(value); |
| 42 | + |
| 43 | + return this.EmitFloatConstRaw(8, bits, location); |
| 44 | + } |
| 45 | + |
| 46 | + /// <summary> |
| 47 | + /// Creates a helper expression holding a separately allocated parameter list. |
| 48 | + /// </summary> |
| 49 | + public MediumLevelILExpressionIndex EmitSeparateParamList( |
| 50 | + MediumLevelILExpressionIndex[] parameters, |
| 51 | + SourceLocation? location = null) |
| 52 | + { |
| 53 | + if (null == parameters) |
| 54 | + { |
| 55 | + throw new ArgumentNullException(nameof(parameters)); |
| 56 | + } |
| 57 | + |
| 58 | + return this.AddExpression( |
| 59 | + MediumLevelILOperation.MLIL_SEPARATE_PARAM_LIST, |
| 60 | + location, |
| 61 | + 0, |
| 62 | + (ulong)parameters.Length, |
| 63 | + (ulong)this.AddOperandList(parameters)); |
| 64 | + } |
| 65 | + |
| 66 | + /// <summary> |
| 67 | + /// Creates a helper expression holding parameters that share a parameter slot. |
| 68 | + /// </summary> |
| 69 | + public MediumLevelILExpressionIndex EmitSharedParamSlot( |
| 70 | + MediumLevelILExpressionIndex[] parameters, |
| 71 | + SourceLocation? location = null) |
| 72 | + { |
| 73 | + if (null == parameters) |
| 74 | + { |
| 75 | + throw new ArgumentNullException(nameof(parameters)); |
| 76 | + } |
| 77 | + |
| 78 | + return this.AddExpression( |
| 79 | + MediumLevelILOperation.MLIL_SHARED_PARAM_SLOT, |
| 80 | + location, |
| 81 | + 0, |
| 82 | + (ulong)parameters.Length, |
| 83 | + (ulong)this.AddOperandList(parameters)); |
| 84 | + } |
| 85 | + } |
| 86 | +} |
0 commit comments