internal CompilerContext(ILGenerator il, bool isStatic, bool isWriter, RuntimeTypeModel.SerializerPair[] methodPairs, TypeModel model, CompilerContext.ILVersion metadataVersion, string assemblyName, Type inputType) { if (il == null) { throw new ArgumentNullException("il"); } if (methodPairs == null) { throw new ArgumentNullException("methodPairs"); } if (model == null) { throw new ArgumentNullException("model"); } if (Helpers.IsNullOrEmpty(assemblyName)) { throw new ArgumentNullException("assemblyName"); } this.assemblyName = assemblyName; this.isStatic = isStatic; this.methodPairs = methodPairs; this.il = il; this.isWriter = isWriter; this.model = model; this.metadataVersion = metadataVersion; if (inputType != null) { this.inputValue = new Local((CompilerContext)null, inputType); } }
private CompilerContext(Type associatedType, bool isWriter, bool isStatic, TypeModel model, Type inputType) { Type[] typeArray; Type type; if (model == null) { throw new ArgumentNullException("model"); } this.metadataVersion = CompilerContext.ILVersion.Net2; this.isStatic = isStatic; this.isWriter = isWriter; this.model = model; this.nonPublic = true; if (!isWriter) { type = typeof(object); typeArray = new Type[] { typeof(object), typeof(ProtoReader) }; } else { type = typeof(void); typeArray = new Type[] { typeof(object), typeof(ProtoWriter) }; } int num = CompilerContext.next + 1; CompilerContext.next = num; int num1 = num; this.method = new DynamicMethod(string.Concat("proto_", num1.ToString()), type, typeArray, (associatedType.IsInterface ? typeof(object) : associatedType), true); this.il = this.method.GetILGenerator(); if (inputType != null) { this.inputValue = new Local((CompilerContext)null, inputType); } }
private void WriteDeserializePair(string assemblyName, TypeBuilder type, SerializerPair[] methodPairs, CompilerContext.ILVersion ilVersion, ILGenerator il, SerializerPair pair, int i, CompilerContext ctx) { Type keyType = pair.Type.Type; if (keyType.IsValueType) { il.Emit(OpCodes.Ldarg_2); il.Emit(OpCodes.Ldarg_3); il.EmitCall(OpCodes.Call, EmitBoxedSerializer(type, i, keyType, methodPairs, this, ilVersion, assemblyName).Member, null); ctx.Return(); } else { il.Emit(OpCodes.Ldarg_2); ctx.CastFromObject(keyType); il.Emit(OpCodes.Ldarg_3); il.EmitCall(OpCodes.Call, pair.Deserialize, null); ctx.Return(); } }