示例#1
0
        public ConstructorGen Constructor()
        {
            if (TypeBuilder.IsInterface)
            {
                throw new InvalidOperationException(Messages.ErrInterfaceNoCtor);
            }

            ConstructorGen cg = new ConstructorGen(this, _mthVis, _implFlags);

            ResetAttrs();
            return(cg);
        }
示例#2
0
        public ConstructorGen Constructor()
        {
            if (tb.IsInterface)
            {
                throw new InvalidOperationException(Properties.Messages.ErrInterfaceNoCtor);
            }

            ConstructorGen cg = new ConstructorGen(this, mthVis, implFlags);

            ResetAttrs();
            return(cg);
        }
示例#3
0
        public ConstructorGen Constructor()
        {
            if (tb.IsInterface)
            {
                throw new InvalidOperationException("Interface cannot define a constructor");
            }

            ConstructorGen cg = new ConstructorGen(this, mthVis, implFlags);

            ResetAttrs();
            return(cg);
        }
示例#4
0
        internal CodeGen(ICodeGenContext context)
        {
            this.context = context;
            this.cg      = context as ConstructorGen;

            if (cg != null && cg.IsStatic)
            {
                // #14 - cg is relevant for instance constructors - it wreaks havoc in a static constructor
                cg = null;
            }

            il = context.GetILGenerator();
        }
示例#5
0
        internal void Register(ConstructorGen constructor)
        {
            if (constructor.IsStatic)
            {
                return;
            }

            if (constructor.ParameterCount == 0 && tb.IsValueType)
            {
                throw new InvalidOperationException(Properties.Messages.ErrStructNoDefaultCtor);
            }

            constructors.Add(constructor);
        }
示例#6
0
        public ConstructorGen StaticConstructor()
        {
            if (tb.IsInterface)
            {
                throw new InvalidOperationException(Properties.Messages.ErrInterfaceNoCtor);
            }

            if (staticCtor == null)
            {
                staticCtor = new ConstructorGen(this, MethodAttributes.Static, 0).LockSignature();
            }

            return(staticCtor);
        }
示例#7
0
        public ConstructorGen StaticConstructor()
        {
            if (tb.IsInterface)
            {
                throw new InvalidOperationException("Interface cannot define a constructor");
            }

            if (staticCtor == null)
            {
                staticCtor = new ConstructorGen(this, MethodAttributes.Static, 0).LockSignature();
            }

            return(staticCtor);
        }
示例#8
0
        public void Register(ConstructorGen constructor)
        {
            if (constructor.IsStatic)
            {
                return;
            }

            if (constructor.ParameterCount == 0 && tb.IsValueType)
            {
                throw new InvalidOperationException("Value types cannot have default constructors");
            }

            constructors.Add(constructor);
        }
示例#9
0
        public ConstructorGen StaticConstructor()
        {
            if (TypeBuilder.IsInterface)
            {
                throw new InvalidOperationException(Messages.ErrInterfaceNoCtor);
            }

            if (_staticCtor == null)
            {
                _staticCtor = new ConstructorGen(this, MethodAttributes.Static, 0).LockSignature();
            }

            return(_staticCtor);
        }
示例#10
0
        public CodeGen(ICodeGenContext context, bool isOwner = true)
        {
            _isOwner = isOwner;
            Context  = context;
#if !PHONE8
            _cg = context as ConstructorGen;

            if (_cg != null && _cg.IsStatic)
            {
                // #14 - cg is relevant for instance constructors - it wreaks havoc in a static constructor
                _cg = null;
            }
#endif
            IL = context.GetILGenerator();
        }
示例#11
0
 public CodeGen(ICodeGenContext context)
 {
     this.context = context;
     this.cg      = context as ConstructorGen;
     il           = context.GetILGenerator();
 }