File tree 5 files changed +23
-11
lines changed
idris-jvm-ffi/src/main/idris/IdrisJvm
idris-jvm-server/src/main/java/io/github/mmhelloworld/idrisjvm/model
5 files changed +23
-11
lines changed Original file line number Diff line number Diff line change @@ -548,6 +548,13 @@ mutual
548
548
paramAnns = parseParamAnnotations paramAnnDescs
549
549
in exportFun types cname mname sourceCname sourceMname ExportCallInstance parent returns args anns paramAnns
550
550
551
+ cgExport types cname parent
552
+ (ExportFun n (FApp " ExportStaticWithAnn" [FStr mname, FApp " ::" annDescs, paramAnnDescs]) returns args)
553
+ = let MkJMethodName sourceCname sourceMname = jname n
554
+ anns = join $ parseAnnotations <$> annDescs
555
+ paramAnns = parseParamAnnotations paramAnnDescs
556
+ in exportFun types cname mname sourceCname sourceMname ExportCallStatic parent returns args anns paramAnns
557
+
551
558
cgExport _ _ _ exportDef = jerror $ " Unsupported export definition: " ++ show exportDef
552
559
553
560
parseClassAnnotations : List Export -> (List Annotation, List Export)
@@ -843,6 +850,7 @@ mutual
843
850
844
851
parseAnnotationValue : FDesc -> AnnotationValue
845
852
parseAnnotationValue (FApp " AnnString" [FStr value]) = AnnString value
853
+ parseAnnotationValue (FApp " AnnInt" [FStr value]) = AnnInt $ cast value
846
854
parseAnnotationValue (FApp " AnnEnum" [FStr enum, FStr value]) = AnnEnum (asmRefTyDesc (ClassDesc enum)) value
847
855
parseAnnotationValue (FApp " AnnArray" values) = AnnArray (parseAnnArrayElements values)
848
856
parseAnnotationValue desc = jerror $ " Invalid or unsupported annotation value: " ++ show desc
Original file line number Diff line number Diff line change 1
1
package IdrisJvm .Core ;
2
2
3
- class AnnotationProperty {
3
+ public class AnnotationProperty {
4
4
private final String name ;
5
5
private final AnnotationValue value ;
6
6
@@ -17,4 +17,4 @@ public AnnotationValue getValue() {
17
17
public String getName () {
18
18
return name ;
19
19
}
20
- }
20
+ }
Original file line number Diff line number Diff line change 4
4
5
5
import java .util .List ;
6
6
7
- abstract class AnnotationValue {
7
+ public abstract class AnnotationValue {
8
8
private final AnnotationValueType type ;
9
9
10
10
private AnnotationValue (final AnnotationValueType type ) {
@@ -83,4 +83,4 @@ public List<AnnotationValue> getValues() {
83
83
return values ;
84
84
}
85
85
}
86
- }
86
+ }
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ data IORef a = MkIORef a
8
8
AnnotationTypeName : Type
9
9
AnnotationTypeName = String
10
10
11
- data AnnotationValue = AnnInt Int
11
+ data AnnotationValue = AnnInt String -- FFI Descriptor can only take String
12
12
| AnnString String
13
13
| AnnEnum String String
14
14
| AnnArray (List AnnotationValue )
@@ -57,7 +57,11 @@ mutual
57
57
| ExportInstance String
58
58
| ExportDefault -- Export an instance method with idris function name
59
59
| Anns (List Annotation )
60
+
61
+ -- Export a static method with method annotations and parameter annotations
60
62
| ExportStaticWithAnn String (List Annotation ) (List (List Annotation ))
63
+
64
+ -- Export an instance method with method annotations and parameter annotations
61
65
| ExportInstanceWithAnn String (List Annotation ) (List (List Annotation ))
62
66
63
67
data JVM_IntTypes : Type -> Type where
@@ -353,5 +357,6 @@ term syntax "<@@>" [anns] = Fun classWith (Anns anns)
353
357
term syntax " <@>" [name] [attrs] = Ann name attrs
354
358
term syntax " <@..>" [values] = AnnArray values
355
359
term syntax " <@s>" [value] = AnnString value
360
+ term syntax " <@i>" [value] = AnnInt value -- Descriptor can only take string
356
361
term syntax " <@enum>" [ty] [value] = AnnEnum ty value
357
362
term syntax [name] " <@:>" [value] = (name, value)
Original file line number Diff line number Diff line change 1
1
package io .github .mmhelloworld .idrisjvm .model ;
2
2
3
+ import IdrisJvm .Core .export .Codegen ;
4
+ import IdrisJvm .IR .export .Const ;
5
+ import IdrisJvm .IR .export .SAlt ;
6
+ import IdrisJvm .IR .export .SExp ;
3
7
import com .fasterxml .jackson .core .JsonParser ;
4
- import com .fasterxml .jackson .core .JsonProcessingException ;
5
8
import com .fasterxml .jackson .databind .DeserializationContext ;
6
9
import com .fasterxml .jackson .databind .JsonNode ;
7
10
import com .fasterxml .jackson .databind .ObjectMapper ;
8
11
import com .fasterxml .jackson .databind .deser .std .StdDeserializer ;
9
- import IdrisJvm .IR .export .Const ;
10
- import IdrisJvm .Core .export .Codegen ;
11
- import IdrisJvm .IR .export .SAlt ;
12
- import IdrisJvm .IR .export .SExp ;
13
12
14
13
import java .io .IOException ;
15
14
import java .util .List ;
@@ -31,7 +30,7 @@ public SAltDeserializer(final Class<?> vc) {
31
30
32
31
@ Override
33
32
public SAlt deserialize (final JsonParser jsonParser , final DeserializationContext deserializationContext )
34
- throws IOException , JsonProcessingException {
33
+ throws IOException {
35
34
final JsonNode node = jsonParser .getCodec ().readTree (jsonParser );
36
35
final ObjectMapper mapper = Context .getMapper ();
37
36
You can’t perform that action at this time.
0 commit comments