Пример #1
0
 private void setFieldModifiers(FieldDeclarationNode fieldDeclaration, FieldBuilder fieldBuilder) {
     foreach (var modifier in fieldDeclaration.Modifiers) {
         switch (modifier) {
         case Public:
             if (fieldBuilder.IsPrivate || fieldBuilder.IsProtected) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, fieldDeclaration);
             } else {
                 fieldBuilder.setPublic(true);
             }
             break;
             
         case Protected:
             if (fieldBuilder.IsPrivate || fieldBuilder.IsPublic) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, fieldDeclaration);
             } else {
                 fieldBuilder.setProtected(true);
             }
             break;
             
         case Private:
             if (fieldBuilder.IsProtected || fieldBuilder.IsPublic) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, fieldDeclaration);
             } else {
                 fieldBuilder.setPrivate(true);
             }
             break;
             
         case Final:
             if (fieldBuilder.IsVolatile) {
                 context.addError(CompileErrorId.FinalVolatile, fieldDeclaration);
             } else {
                 fieldBuilder.setFinal(true);
             }
             break;
             
         case Static:
             fieldBuilder.setStatic(true);
             break;
             
         case Transient:
             fieldBuilder.setTransient(true);
             break;
             
         case Volatile:
             if (fieldBuilder.IsFinal) {
                 context.addError(CompileErrorId.FinalVolatile, fieldDeclaration);
             } else {
                 fieldBuilder.setVolatile(true);
             }
             break;
             
         default:
             context.addError(CompileErrorId.UnexpectedModifier, fieldDeclaration, modifier.toString().toLowerCase());
             break;
         }
     }
 }