public void Emit() { if (Method != null) { return; } Method = new DynamicMethod( Name, typeof(int), Parameters.Select(t => t.Type).ToArray(), typeof(Program)); ILGenerator g = Method.GetILGenerator(); LocalBuilder hashCode = g.DeclareLocal(typeof(HashCode)); if (Config.Verbose) { Program.EmitDumpValues("Callee's incoming args", g, Parameters.Select((t, i) => new ArgValue(t, i))); } g.Emit(OpCodes.Ldloca, hashCode); g.Emit(OpCodes.Initobj, typeof(HashCode)); for (int i = 0; i < Parameters.Count; i++) { TypeEx pm = Parameters[i]; g.Emit(OpCodes.Ldloca, hashCode); g.Emit(OpCodes.Ldarga, checked ((short)i)); g.Emit(OpCodes.Ldc_I4, pm.Size); g.Emit(OpCodes.Call, s_memoryMarshalCreateReadOnlySpanMethod); g.Emit(OpCodes.Call, s_hashCodeAddBytesMethod); } g.Emit(OpCodes.Ldloca, hashCode); g.Emit(OpCodes.Call, s_hashCodeToHashCodeMethod); g.Emit(OpCodes.Ret); }
public Value(TypeEx type) { Type = type; }
public ConstantValue(TypeEx type, object value) : base(type) { Value = value; }
public ArgValue(TypeEx type, int index) : base(type) { Index = index; }