Example #1
0
 internal CompilerContext(ILGenerator il, bool isStatic, bool isWriter, RuntimeTypeModel.SerializerPair[] methodPairs, TypeModel model, ILVersion metadataVersion, string assemblyName, Type inputType)
 {
     this.locals = new MutableList();
     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(null, inputType);
     }
 }
Example #2
0
        private CompilerContext(Type associatedType, bool isWriter, bool isStatic, TypeModel model, Type inputType)
        {
            Type[] typeArray;
            Type   type;

            this.locals = new MutableList();
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            this.metadataVersion = ILVersion.Net2;
            this.isStatic        = isStatic;
            this.isWriter        = isWriter;
            this.model           = model;
            this.nonPublic       = true;
            if (isWriter)
            {
                type      = typeof(void);
                typeArray = new Type[] { typeof(object), typeof(ProtoWriter) };
            }
            else
            {
                type      = typeof(object);
                typeArray = new Type[] { typeof(object), typeof(ProtoReader) };
            }
            int num = Interlocked.Increment(ref next);

            this.method = new DynamicMethod("proto_" + num.ToString(), type, typeArray, associatedType.IsInterface ? typeof(object) : associatedType, true);
            this.il     = this.method.GetILGenerator();
            if (inputType != null)
            {
                this.inputValue = new Local(null, inputType);
            }
        }
Example #3
0
 private CompilerContext(Type associatedType, bool isWriter, bool isStatic, TypeModel model, Type inputType)
 {
     if (model == null) throw new ArgumentNullException("model");
     #if FX11
     metadataVersion = ILVersion.Net1;
     #else
     metadataVersion = ILVersion.Net2;
     #endif
     this.isStatic = isStatic;
     this.isWriter = isWriter;
     this.model = model;
     nonPublic = true;
     Type[] paramTypes;
     Type returnType;
     if (isWriter)
     {
         returnType = typeof(void);
         paramTypes = new Type[] { typeof(object), typeof(ProtoWriter) };
     }
     else
     {
         returnType = typeof(object);
         paramTypes = new Type[] { typeof(object), typeof(ProtoReader) };
     }
     int uniqueIdentifier;
     #if PLAT_NO_INTERLOCKED
     uniqueIdentifier = ++next;
     #else
     uniqueIdentifier = Interlocked.Increment(ref next);
     #endif
     method = new DynamicMethod("proto_" + uniqueIdentifier.ToString(), returnType, paramTypes, associatedType.IsInterface ? typeof(object) : associatedType, true);
     this.il = method.GetILGenerator();
     if (inputType != null) this.inputValue = new Local(null, inputType);
 }
Example #4
0
 internal CompilerContext(ILGenerator il, bool isStatic, bool isWriter, RuntimeTypeModel.SerializerPair[] methodPairs, TypeModel model, 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;
     nonPublic = false;
     this.isWriter = isWriter;
     this.model = model;
     this.metadataVersion = metadataVersion;
     if (inputType != null) this.inputValue = new Local(null, inputType);
 }
Example #5
0
 internal CompilerContext(ILGenerator il, bool isStatic, bool isWriter, RuntimeTypeModel.SerializerPair[] methodPairs, TypeModel model, ILVersion metadataVersion, string assemblyName)
 {
     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;
     nonPublic            = false;
     this.isWriter        = isWriter;
     this.model           = model;
     this.metadataVersion = metadataVersion;
 }