コード例 #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
ファイル: CodeGen.cs プロジェクト: smartcaveman/runsharp
        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();
 }