Inheritance: Node, ClassElement
Beispiel #1
0
        public override void VisitAttr(AttrDefinition attr)
        {
            ilGenerator = attr.Reader.GetILGenerator();
            ilGenerator.Emit(OpCodes.Ldarg_0);
            ilGenerator.Emit(OpCodes.Ldfld, attr.FieldBuilder);
            ilGenerator.Emit(OpCodes.Ret);

            ilGenerator = attr.Writer.GetILGenerator();
            ilGenerator.Emit(OpCodes.Ldarg_0);
            ilGenerator.Emit(OpCodes.Ldarg_1);
            ilGenerator.Emit(OpCodes.Stfld, attr.FieldBuilder);
            ilGenerator.Emit(OpCodes.Ret);
        }
Beispiel #2
0
 public override void VisitAttr(AttrDefinition attr)
 {
     attr.TypeSpecifier.Accept(this);
     Type attrType = attr.TypeSpecifier.RawType;
     TypeBuilder typeBuilder = currentClass.TypeBuilder;
     MethodAttributes readerAttributes =
         MethodAttributes.Virtual | MethodAttributes.HideBySig;
     MethodAttributes writerAttributes =
         MethodAttributes.Virtual | MethodAttributes.HideBySig;
     switch (attr.Modifier) {
     case AttrModifier.None:
         readerAttributes |= MethodAttributes.Public;
         writerAttributes |= MethodAttributes.Public;
         break;
     case AttrModifier.Private:
         readerAttributes |= MethodAttributes.Private;
         writerAttributes |= MethodAttributes.Private;
         break;
     case AttrModifier.Readonly:
         readerAttributes |= MethodAttributes.Public;
         writerAttributes |= MethodAttributes.Private;
         break;
     }
     attr.FieldBuilder =
         typeBuilder.DefineField("_" + attr.Name,
                                 attrType,
                                 FieldAttributes.Private);
     try {
         attr.Reader = DefineReader(typeBuilder, attr.Name,
                                    readerAttributes,
                                    attr.TypeSpecifier);
         attr.Writer = DefineWriter(typeBuilder, attr.Name,
                                    readerAttributes,
                                    attr.TypeSpecifier);
     }
     catch (MethodConflictionException e) {
         report.Error(attr.Location, e.Message);
     }
 }
Beispiel #3
0
 public virtual void VisitAttr(AttrDefinition attr)
 {
 }