예제 #1
0
 private void setNestedClassModifiers(ClassDeclarationNode classDeclaration, TypeBuilder typeBuilder) {
     foreach (var modifier in classDeclaration.Modifiers) {
         switch (modifier) {
         case Public:
             if (typeBuilder.IsNestedPrivate || typeBuilder.IsNestedProtected) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, classDeclaration);
             } else {
                 typeBuilder.setPublic(true);
                 typeBuilder.setNestedPublic(true);
             }
             break;
             
         case Protected:
             if (typeBuilder.IsNestedPrivate || typeBuilder.IsNestedPublic) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, classDeclaration);
             } else {
                 typeBuilder.setNestedProtected(true);
             }
             break;
             
         case Private:
             if (typeBuilder.IsNestedProtected || typeBuilder.IsNestedPublic) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, classDeclaration);
             } else {
                 typeBuilder.setNestedPrivate(true);
             }
             break;
             
         case Final:
         case Static:
             if (typeBuilder.IsAbstract || typeBuilder.IsFinal) {
                 context.addError(CompileErrorId.FinalAbstractStaticClass, classDeclaration);
             } else {
                 typeBuilder.setFinal(true);
                 typeBuilder.setNestedFinal(true);
             }
             break;
             
         case Abstract:
             if (typeBuilder.IsFinal) {
                 context.addError(CompileErrorId.FinalAbstractStaticClass, classDeclaration);
             } else {
                 typeBuilder.setAbstract(true);
                 typeBuilder.setNestedAbstract(true);
             }
             break;
             
         default:
             context.addError(CompileErrorId.UnexpectedModifier, classDeclaration, modifier.toString().toLowerCase());
             break;
         }
     }
 }