11package  org .vineflower .kotlin .struct ;
22
33import  kotlin .metadata .internal .metadata .ProtoBuf ;
4+ import  kotlin .metadata .internal .metadata .deserialization .Flags ;
45import  kotlin .metadata .internal .metadata .jvm .JvmProtoBuf ;
56import  org .jetbrains .java .decompiler .main .ClassesProcessor ;
67import  org .jetbrains .java .decompiler .main .DecompilerContext ;
2223import  org .vineflower .kotlin .KotlinWriter ;
2324import  org .vineflower .kotlin .metadata .MetadataNameResolver ;
2425import  org .vineflower .kotlin .util .KUtils ;
25- import  org .vineflower .kotlin .util .ProtobufFlags ;
2626
2727import  java .util .HashMap ;
2828import  java .util .List ;
2929import  java .util .Map ;
3030
3131public  record  KConstructor (
3232  KParameter [] parameters ,
33-   ProtobufFlags . Constructor  flags ,
33+   int  flags ,
3434  MethodWrapper  method ,
3535  boolean  isPrimary ,
3636  DefaultArgsMap  defaultArgs ,
3737  ClassesProcessor .ClassNode  node ,
38-   ProtobufFlags . Class  classFlags 
39- ) {
38+   int  classFlags 
39+ ) implements   Flags   {
4040  private  static  final  VarType  DEFAULT_CONSTRUCTOR_MARKER  = new  VarType ("kotlin/jvm/internal/DefaultConstructorMarker" , true );
4141
4242  public  static  Data  parse (ClassesProcessor .ClassNode  node ) {
@@ -47,8 +47,8 @@ public static Data parse(ClassesProcessor.ClassNode node) {
4747    KotlinDecompilationContext .KotlinType  type  = KotlinDecompilationContext .getCurrentType ();
4848    if  (type  != KotlinDecompilationContext .KotlinType .CLASS ) return  null ;
4949
50-     ProtobufFlags . Class  classFlags  = new   ProtobufFlags . Class ( KotlinDecompilationContext .getCurrentClass ().getFlags () );
51-     if  (classFlags . modality  == ProtoBuf .Modality .ABSTRACT ) return  null ;
50+     int  classFlags  = KotlinDecompilationContext .getCurrentClass ().getFlags ();
51+     if  (MODALITY . get ( classFlags )  == ProtoBuf .Modality .ABSTRACT ) return  null ;
5252
5353    List <ProtoBuf .Constructor > protoConstructors  = KotlinDecompilationContext .getCurrentClass ().getConstructorList ();
5454    if  (protoConstructors .isEmpty ()) return  null ;
@@ -61,21 +61,21 @@ public static Data parse(ClassesProcessor.ClassNode node) {
6161      for  (int  i  = 0 ; i  < parameters .length ; i ++) {
6262        ProtoBuf .ValueParameter  protoParameter  = constructor .getValueParameter (i );
6363        parameters [i ] = new  KParameter (
64-           new   ProtobufFlags . ValueParameter ( protoParameter .getFlags () ),
64+           protoParameter .getFlags (),
6565          resolver .resolve (protoParameter .getName ()),
6666          KType .from (protoParameter .getType (), resolver ),
6767          KType .from (protoParameter .getVarargElementType (), resolver ),
6868          protoParameter .getTypeId ()
6969        );
7070      }
7171
72-       ProtobufFlags . Constructor  flags  = new   ProtobufFlags . Constructor ( constructor .getFlags () );
72+       int  flags  = constructor .getFlags ();
7373
7474      JvmProtoBuf .JvmMethodSignature  signature  = constructor .getExtension (JvmProtoBuf .constructorSignature );
7575      String  desc  = resolver .resolve (signature .getDesc ());
7676      MethodWrapper  method  = wrapper .getMethodWrapper ("<init>" , desc );
7777      if  (method  == null ) {
78-         if  (classFlags . kind  == ProtoBuf .Class .Kind .ANNOTATION_CLASS ) {
78+         if  (CLASS_KIND . get ( classFlags )  == ProtoBuf .Class .Kind .ANNOTATION_CLASS ) {
7979          // Annotation classes are very odd and don't actually have a constructor under the hood 
8080          KConstructor  kConstructor  = new  KConstructor (parameters , flags , null , false , null , node , classFlags );
8181          return  new  Data (null , kConstructor );
@@ -85,10 +85,10 @@ public static Data parse(ClassesProcessor.ClassNode node) {
8585        continue ;
8686      }
8787
88-       boolean  isPrimary  = !flags . isSecondary ;
88+       boolean  isPrimary  = !IS_SECONDARY . get ( flags ) ;
8989
9090      StringBuilder  defaultArgsDesc  = new  StringBuilder ("(" );
91-       if  (classFlags . kind  == ProtoBuf .Class .Kind .ENUM_CLASS ) {
91+       if  (CLASS_KIND . get ( classFlags )  == ProtoBuf .Class .Kind .ENUM_CLASS ) {
9292        // Kotlin drops hidden name/ordinal parameters for enum constructors in its metadata 
9393        defaultArgsDesc .append ("Ljava/lang/String;" ).append ("I" );
9494      }
@@ -124,15 +124,15 @@ public boolean stringify(TextBuffer buffer, int indent) {
124124    String  methodKey  = InterpreterUtil .makeUniqueKey (method .methodStruct .getName (), method .methodStruct .getDescriptor ());
125125
126126    if  (!isPrimary ) {
127-       if  (flags . hasAnnotations ) {
127+       if  (HAS_ANNOTATIONS . get ( flags ) ) {
128128        KotlinWriter .appendAnnotations (buf , indent , method .methodStruct , TypeAnnotation .METHOD_RETURN_TYPE );
129129        KotlinWriter .appendJvmAnnotations (buf , indent , method .methodStruct , false , method .classStruct .getPool (), TypeAnnotation .METHOD_RETURN_TYPE );
130130      }
131131
132132      buf .appendIndent (indent );
133133
134-       if  (flags . visibility  != ProtoBuf .Visibility .PUBLIC  || DecompilerContext .getOption (KotlinOptions .SHOW_PUBLIC_VISIBILITY )) {
135-         KUtils .appendVisibility (buf , flags . visibility );
134+       if  (VISIBILITY . get ( flags )  != ProtoBuf .Visibility .PUBLIC  || DecompilerContext .getOption (KotlinOptions .SHOW_PUBLIC_VISIBILITY )) {
135+         KUtils .appendVisibility (buf , VISIBILITY . get ( flags ) );
136136      }
137137
138138      buf .append ("constructor" );
@@ -149,7 +149,7 @@ public boolean stringify(TextBuffer buffer, int indent) {
149149
150150        parameter .stringify (indent  + 1 , buf );
151151
152-         if  (parameter .flags (). declaresDefault ) {
152+         if  (DECLARES_DEFAULT_VALUE . get ( parameter .flags ()) ) {
153153          buf .append (defaultArgs .toJava (parameter , indent  + 1 ), node .classStruct .qualifiedName , methodKey );
154154        }
155155      }
@@ -213,8 +213,8 @@ public boolean writePrimaryConstructor(TextBuffer buffer, int indent) {
213213
214214    String  methodKey  = InterpreterUtil .makeUniqueKey (method .methodStruct .getName (), method .methodStruct .getDescriptor ());
215215
216-     if  (classFlags . kind  != ProtoBuf .Class .Kind .OBJECT  && classFlags . kind  != ProtoBuf .Class .Kind .COMPANION_OBJECT ) {
217-       if  (flags . hasAnnotations ) {
216+     if  (CLASS_KIND . get ( classFlags )  != ProtoBuf .Class .Kind .OBJECT  && CLASS_KIND . get ( classFlags )  != ProtoBuf .Class .Kind .COMPANION_OBJECT ) {
217+       if  (HAS_ANNOTATIONS . get ( flags ) ) {
218218        buf .append (" " );
219219        // -1 for indent indicates inline 
220220        KotlinWriter .appendAnnotations (buf , -1 , method .methodStruct , TypeAnnotation .METHOD_RETURN_TYPE );
@@ -223,11 +223,11 @@ public boolean writePrimaryConstructor(TextBuffer buffer, int indent) {
223223      }
224224
225225      // For cleanliness, public primary constructors are not forced public by the config option 
226-       if  ((flags . visibility  != ProtoBuf .Visibility .PUBLIC  || (appended  && DecompilerContext .getOption (KotlinOptions .SHOW_PUBLIC_VISIBILITY ))) &&
227-         classFlags . kind  != ProtoBuf .Class .Kind .ENUM_CLASS  // Enum constructors are always private implicitly 
226+       if  ((VISIBILITY . get ( flags )  != ProtoBuf .Visibility .PUBLIC  || (appended  && DecompilerContext .getOption (KotlinOptions .SHOW_PUBLIC_VISIBILITY ))) &&
227+         CLASS_KIND . get ( classFlags )  != ProtoBuf .Class .Kind .ENUM_CLASS  // Enum constructors are always private implicitly 
228228      ) {
229229        buf .append (" " );
230-         KUtils .appendVisibility (buf , flags . visibility );
230+         KUtils .appendVisibility (buf , VISIBILITY . get ( flags ) );
231231        appended  = true ;
232232      }
233233
@@ -248,7 +248,7 @@ public boolean writePrimaryConstructor(TextBuffer buffer, int indent) {
248248
249249          parameter .stringify (indent  + 1 , buf );
250250
251-           if  (parameter .flags (). declaresDefault ) {
251+           if  (DECLARES_DEFAULT_VALUE . get ( parameter .flags ()) ) {
252252            buf .append (defaultArgs .toJava (parameter , indent  + 1 ), node .classStruct .qualifiedName , methodKey );
253253          }
254254        }
@@ -271,7 +271,7 @@ public boolean writePrimaryConstructor(TextBuffer buffer, int indent) {
271271//      throw new IllegalStateException("First expression of constructor is not InvocationExprent"); 
272272    }
273273
274-     if  (invocation .getClassname ().equals ("java/lang/Object" ) || classFlags . kind  == ProtoBuf .Class .Kind .ENUM_CLASS ) {
274+     if  (invocation .getClassname ().equals ("java/lang/Object" ) || CLASS_KIND . get ( classFlags )  == ProtoBuf .Class .Kind .ENUM_CLASS ) {
275275      // No need to declare super constructor call 
276276      buffer .append (buf );
277277      return  false ;
0 commit comments