private void setConstructorModifiers(ConstructorDeclarationNode constructorDeclaration, MethodBuilder methodBuilder) {
     foreach (var modifier in constructorDeclaration.Modifiers) {
         switch (modifier) {
         case Public:
             if (methodBuilder.IsPrivate || methodBuilder.IsProtected) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, constructorDeclaration);
             } else {
                 methodBuilder.setPublic(true);
             }
             break;
             
         case Protected:
             if (methodBuilder.IsPrivate || methodBuilder.IsPublic) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, constructorDeclaration);
             } else {
                 methodBuilder.setProtected(true);
             }
             break;
             
         case Private:
             if (methodBuilder.IsProtected || methodBuilder.IsPublic) {
                 context.addError(CompileErrorId.PublicProtectedPrivate, constructorDeclaration);
             } else {
                 methodBuilder.setPrivate(true);
             }
             break;
             
         case Synchronized:
             methodBuilder.setSynchronized(true);
             break;
             
         case Native:
             methodBuilder.setNative(true);
             break;
             
         case Strictfp:
             methodBuilder.setStrict(true);
             break;
             
         default:
             context.addError(CompileErrorId.UnexpectedModifier, constructorDeclaration, modifier.toString().toLowerCase());
             break;
         }
     }
 }
		public void enterConstructor(ConstructorDeclarationNode declaration) {
			methodInfos.add(declaration.getUserData(typeof(MethodInfo)));
		}
        private void defineClassConstructor(ConstructorDeclarationNode constructorDeclaration, TypeBuilder typeBuilder) {
            var name = context.getIdentifier(constructorDeclaration.NameOffset, constructorDeclaration.NameLength);
            if (!name.equals(typeBuilder.Name)) {
                context.addError(CompileErrorId.MethodWithoutReturnType, constructorDeclaration, name);
            }
            if (constructorDeclaration.Modifiers.contains(Modifier.Static)) {
                // TODO: check that modifiers.size() == 1
                var clinit = (MethodBuilder)typeBuilder.getMethod("<clinit>", Query.empty<TypeInfo>());
                if (clinit != null) {
                    context.addError(CompileErrorId.AlreadyDefinedStaticInitializer, constructorDeclaration,
                        BytecodeHelper.getDisplayName(typeBuilder));
                }
                clinit = typeBuilder.defineMethod("<clinit>");
                clinit.setStatic(true);
                clinit.setReturnType(context.TypeSystem.VoidType);
                constructorDeclaration.addUserData(clinit);
            } else {
				if (typeBuilder.IsEnum) {
					// TODO: check if the contructor is private
				}
                var methodBuilder = lookupMethod(typeBuilder, constructorDeclaration.TypeParameters, constructorDeclaration.Parameters, "<init>");
                if (methodBuilder != null) {
                    context.addError(CompileErrorId.AlreadyDefinedConstructor, constructorDeclaration,
                            BytecodeHelper.getDisplayName(typeBuilder));
                }
                methodBuilder = typeBuilder.defineMethod("<init>");
                methodBuilder.setReturnType(context.TypeSystem.VoidType);
                constructorDeclaration.addUserData(methodBuilder);
                setTypeParameters(methodBuilder, constructorDeclaration.getTypeParameters(), constructorDeclaration);
                context.MemberResolver.enterMethod(methodBuilder);
                try {
                    setConstructorModifiers(constructorDeclaration, methodBuilder);
                    if (typeBuilder.IsEnum) {
                        var pb = methodBuilder.addParameter(context.TypeSystem.StringType);
                        pb.setName("name$0");
                        pb = methodBuilder.addParameter(context.TypeSystem.IntType);
                        pb.setName("ordinal$0");
                    }
                    foreach (var p in constructorDeclaration.Parameters) {
                        var t = CompilerHelper.resolveTypeReference(context, typeBuilder.PackageName, p.Type);
                        var pb = methodBuilder.addParameter(t);
                        pb.setName(context.getIdentifier(p.NameOffset, p.NameLength));
                        if (p.Modifier == ParameterModifier.Params) {
                            methodBuilder.setVarargs(true);
                        }
                    }
                    setMethodConstraints(constructorDeclaration.ConstraintsClauses, methodBuilder);
                } finally {
                    context.MemberResolver.leaveMethod();
                }
            }
        }
        private ITypeMember parseConstructorDeclaration(List<AnnotationSectionNode> annotations, EnumSet<Modifier> modifiers,
                bool partial, int position, int length, List<SimpleNameTypeReferenceNode> typeParameters, int startPosition) {
            var declaration = new ConstructorDeclarationNode { NameOffset = position, NameLength = length, StartPosition = startPosition };
            if (docCommentEndPosition > 0) {
                declaration.DocumentationOffset = docCommentStartPosition;
                declaration.DocumentationLength = docCommentEndPosition - docCommentStartPosition;
                docCommentEndPosition = 0;
            }
            setSavedScannerState(declaration);
            declaration.Modifiers.addAll(modifiers);
            declaration.Annotations.addAll(annotations);
            declaration.TypeParameters.addAll(typeParameters);
            if (lexicalUnit != LexicalUnit.CloseParenthesis) {
                parseFormalParameters(declaration.Parameters, LexicalUnit.CloseParenthesis);
            } else {
                nextLexicalUnit(true);
            }
            if (lexicalUnit == LexicalUnit.Colon) {
                if (modifiers.contains(Modifier.Static)) {
                    throw error(ParseErrorId.UnexpectedLexicalUnit);
                }
                bool isSuper = false;
                switch (nextLexicalUnit(true)) {
                case Keyword:
                    switch (scanner.Keyword) {
                    case Super:
                        isSuper = true;
                        break;

                    case This:
                        break;

                    default:
                        throw error(ParseErrorId.SuperOrThisExpected);
                    }
                    break;

                default:
                    throw error(ParseErrorId.SuperOrThisExpected);
                }
                saveScannerState();
                if (nextLexicalUnit(true) != LexicalUnit.OpenParenthesis) {
                    throw error(ParseErrorId.OpenParenthesisExpected);
                }
                var initializer = new ConstructorInitializerNode();
                setSavedScannerState(initializer);
                initializer.IsSuper = isSuper;
                declaration.Initializer = initializer;
                nextLexicalUnit(true);
                initializer.EndPosition = parseArguments(initializer.Arguments);
            }
            parseTypeParameterConstraintsClauses(declaration.ConstraintsClauses);
            switch (lexicalUnit) {
            case OpenBrace:
                declaration.Body = parseBlockStatement();
				declaration.EndPosition = declaration.Body.EndPosition;
                break;

            case SemiColon:
				declaration.EndPosition = scanner.StartPosition;
                docCommentEndPosition = 0;
                nextLexicalUnit(true);
                break;

            default:
                throw error(ParseErrorId.OpenBraceExpected);
            }
            return declaration;
        }