Example #1
0
        public MethodDef
            (IImSeq <Annotation> annotations,
            ISeq <CustomAttribute> customAttributes,
            string name,
            bool isStatic,
            IImSeq <ParameterTypeDef> typeParameters,
            IImSeq <ParameterOrLocalOrResult> valueParameters,
            ParameterOrLocalOrResult result,
            MethodStyle methodStyle,
            bool hasNewSlot,
            MethodCodeFlavor codeFlavor,
            bool isSyncronized,
            bool noInlining,
            bool isInitLocals,
            IImSeq <ParameterOrLocalOrResult> locals,
            PE.MethodBody methodBody)
            : base(annotations, customAttributes, name, isStatic)
        {
            TypeParameters   = typeParameters ?? Constants.EmptyParameterTypeDefs;
            ValueParameters  = valueParameters ?? Constants.EmptyParameterOrLocals;
            Result           = result;
            this.methodStyle = methodStyle;
            HasNewSlot       = hasNewSlot;
            CodeFlavor       = codeFlavor;
            var noBody = methodStyle == MethodStyle.Abstract || CodeFlavor != MethodCodeFlavor.Managed;

            IsSyncronized = isSyncronized;
            NoInlining    = noInlining;
            IsInitLocals  = isInitLocals;
            if (noBody && locals != null && locals.Count > 0)
            {
                throw new InvalidOperationException("unexpected locals in method");
            }
            Locals = locals ?? Constants.EmptyParameterOrLocals;
            if (noBody && methodBody != null)
            {
                throw new InvalidOperationException("unexpected instructions in extern method definition");
            }
            if (!noBody && methodBody == null)
            {
                throw new InvalidOperationException("missing instructions in method definition");
            }
            MethodBody = methodBody;
        }
Example #2
0
 public MethodDef
     (IImSeq<Annotation> annotations,
      ISeq<CustomAttribute> customAttributes,
      string name,
      bool isStatic,
      IImSeq<ParameterTypeDef> typeParameters,
      IImSeq<ParameterOrLocalOrResult> valueParameters,
      ParameterOrLocalOrResult result,
      MethodStyle methodStyle,
      bool hasNewSlot,
      MethodCodeFlavor codeFlavor,
      bool isSyncronized,
      bool noInlining,
      bool isInitLocals,
      IImSeq<ParameterOrLocalOrResult> locals,
      PE.MethodBody methodBody)
     : base(annotations, customAttributes, name, isStatic)
 {
     TypeParameters = typeParameters ?? Constants.EmptyParameterTypeDefs;
     ValueParameters = valueParameters ?? Constants.EmptyParameterOrLocals;
     Result = result;
     this.methodStyle = methodStyle;
     HasNewSlot = hasNewSlot;
     CodeFlavor = codeFlavor;
     var noBody = methodStyle == MethodStyle.Abstract || CodeFlavor != MethodCodeFlavor.Managed;
     IsSyncronized = isSyncronized;
     NoInlining = noInlining;
     IsInitLocals = isInitLocals;
     if (noBody && locals != null && locals.Count > 0)
         throw new InvalidOperationException("unexpected locals in method");
     Locals = locals ?? Constants.EmptyParameterOrLocals;
     if (noBody && methodBody != null)
         throw new InvalidOperationException("unexpected instructions in extern method definition");
     if (!noBody && methodBody == null)
         throw new InvalidOperationException("missing instructions in method definition");
     MethodBody = methodBody;
 }