soywiz-archive / jtransc

Bytecode to source converting Java & Kotlin code into JavaScript, C++, D, C#, PHP, AS3, Dart and Haxe and run it everywhere. Also use JVM code in your favourite language as a library.
https://jtransc.soywiz.com/
Apache License 2.0
632 stars 67 forks source link

Annotation duplicates #231

Open ghost opened 7 years ago

ghost commented 7 years ago

my getClassAnnotations see as

case 6566:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(true)); 
case 6567:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(false)); 
case 6576:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(true)); 
case 6758:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(false)); 
case 6851:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(false)); 
case 6954:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(false)); 
case 6973:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(true)); 
case 6974:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(false)); 
case 6975:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(false)); 
case 7016:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(true)); 
case 7017:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(true)); 
case 7018:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(false)); 
case 7020:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(false)); 
case 7022:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(true)); 

I not found solution for detect duplicates in kotlin. Best solution if create function for any unique case, and re-use in other, size function will be 10x smaller. Also same case for getFieldAnnotations. I think always annotations use multiply.

soywiz commented 7 years ago

Do you mean to reuse cases like this?

case 6566:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(true)); 
case 6567:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(false)); 
case 6576:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(true)); 

-->

case 6567:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(false)); 
case 6566, 6576:return JA_L.T1("[Ljava/lang/annotation/Annotation;", (new my.context.annotations.Bean_Impl_()).my_context_annotations_Bean_Impl_init__Z_V(true)); 
ghost commented 7 years ago

yes, right

soywiz commented 7 years ago

We can have a HashMap of the annotations linked to a case or something. Kotlin data class implement hashCode and equals to compare them and use in maps. I can check it.

ghost commented 7 years ago

Will be great, i try today linked result with starting point, but lose =) For me need more learning kotlin =)