private void defineEnumConstant(EnumConstantDeclarationNode enumConstant, TypeBuilder typeBuilder) { var name = context.getIdentifier(enumConstant.NameOffset, enumConstant.NameLength); if (typeBuilder.getField(name) != null) { context.addError(CompileErrorId.AlreadyDefinedField, enumConstant, BytecodeHelper.getDisplayName(typeBuilder), name); } var fieldBuilder = typeBuilder.defineField(name, typeBuilder); enumConstant.addUserData(fieldBuilder); fieldBuilder.setEnum(true); fieldBuilder.setPublic(true); fieldBuilder.setStatic(true); fieldBuilder.setFinal(true); }
private void defineClassField(FieldDeclarationNode fieldDeclaration, TypeBuilder typeBuilder) { var type = CompilerHelper.resolveTypeReference(context, typeBuilder.PackageName, fieldDeclaration.Type); foreach (var decl in fieldDeclaration.Declarators) { var name = context.getIdentifier(decl.NameOffset, decl.NameLength); if (typeBuilder.getField(name) != null) { context.addError(CompileErrorId.AlreadyDefinedField, fieldDeclaration, BytecodeHelper.getDisplayName(typeBuilder), name); } var fieldBuilder = typeBuilder.defineField(name, type); decl.addUserData(fieldBuilder); setFieldModifiers(fieldDeclaration, fieldBuilder); } }