@@ -116,11 +116,37 @@ metafactoryDesc =
116
116
unrolledConstructorPropsCount : Nat
117
117
unrolledConstructorPropsCount = 10
118
118
119
- idrisObjectProperty : Int -> Int -> Asm ()
120
- idrisObjectProperty object propertyIndex = do
121
- Aload object
122
- Iconst propertyIndex
123
- InvokeMethod InvokeStatic idrisObjectType " getProperty" " (Ljava/lang/Object;I)Ljava/lang/Object;" False
119
+ inferredTypeToFieldTypeDesc : InferredType -> FieldTypeDescriptor
120
+ inferredTypeToFieldTypeDesc IBool = FieldTyDescBoolean
121
+ inferredTypeToFieldTypeDesc IByte = FieldTyDescByte
122
+ inferredTypeToFieldTypeDesc IChar = FieldTyDescChar
123
+ inferredTypeToFieldTypeDesc IShort = FieldTyDescShort
124
+ inferredTypeToFieldTypeDesc IInt = FieldTyDescInt
125
+ inferredTypeToFieldTypeDesc ILong = FieldTyDescLong
126
+ inferredTypeToFieldTypeDesc IFloat = FieldTyDescFloat
127
+ inferredTypeToFieldTypeDesc IDouble = FieldTyDescDouble
128
+ inferredTypeToFieldTypeDesc (Ref refTy) = FieldTyDescReference (ClassDesc refTy)
129
+ inferredTypeToFieldTypeDesc IUnknown = FieldTyDescReference (ClassDesc " java/lang/Object" )
130
+ inferredTypeToFieldTypeDesc (IArray elemTy) = FieldTyDescReference (ArrayDesc $ inferredTypeToFieldTypeDesc elemTy)
131
+
132
+ getInferredTyDesc : InferredType -> String
133
+ getInferredTyDesc = asmFieldTypeDesc . inferredTypeToFieldTypeDesc
134
+
135
+ toFrameLocalVarType : InferredType -> String
136
+ toFrameLocalVarType IBool = " INTEGER"
137
+ toFrameLocalVarType IByte = " INTEGER"
138
+ toFrameLocalVarType IChar = " INTEGER"
139
+ toFrameLocalVarType IShort = " INTEGER"
140
+ toFrameLocalVarType IInt = " INTEGER"
141
+ toFrameLocalVarType ILong = " LONG"
142
+ toFrameLocalVarType IFloat = " FLOAT"
143
+ toFrameLocalVarType IDouble = " DOUBLE"
144
+ toFrameLocalVarType (Ref clsName) = clsName
145
+ toFrameLocalVarType (IArray elemTy) = " [" ++ getInferredTyDesc elemTy
146
+ toFrameLocalVarType _ = " java/lang/Object"
147
+
148
+ toFrameLocalVarTypes : InferredTypeStore -> List String
149
+ toFrameLocalVarTypes types = toFrameLocalVarType <$> (values types)
124
150
125
151
fullFrame : Asm ()
126
152
fullFrame = do
@@ -156,22 +182,6 @@ invokeError x = do
156
182
getPrimitiveClass : String -> Asm ()
157
183
getPrimitiveClass clazz = Field FGetStatic clazz " TYPE" " Ljava/lang/Class;"
158
184
159
- inferredTypeToFieldTypeDesc : InferredType -> FieldTypeDescriptor
160
- inferredTypeToFieldTypeDesc IBool = FieldTyDescBoolean
161
- inferredTypeToFieldTypeDesc IByte = FieldTyDescByte
162
- inferredTypeToFieldTypeDesc IChar = FieldTyDescChar
163
- inferredTypeToFieldTypeDesc IShort = FieldTyDescShort
164
- inferredTypeToFieldTypeDesc IInt = FieldTyDescInt
165
- inferredTypeToFieldTypeDesc ILong = FieldTyDescLong
166
- inferredTypeToFieldTypeDesc IFloat = FieldTyDescFloat
167
- inferredTypeToFieldTypeDesc IDouble = FieldTyDescDouble
168
- inferredTypeToFieldTypeDesc (Ref refTy) = FieldTyDescReference (ClassDesc refTy)
169
- inferredTypeToFieldTypeDesc IUnknown = FieldTyDescReference (ClassDesc " java/lang/Object" )
170
- inferredTypeToFieldTypeDesc (IArray elemTy) = FieldTyDescReference (ArrayDesc $ inferredTypeToFieldTypeDesc elemTy)
171
-
172
- getInferredTyDesc : InferredType -> String
173
- getInferredTyDesc = asmFieldTypeDesc . inferredTypeToFieldTypeDesc
174
-
175
185
getInferredFunDesc : List InferredType -> InferredType -> String
176
186
getInferredFunDesc [] retTy = " ()" ++ getInferredTyDesc retTy
177
187
getInferredFunDesc argTypes retTy =
@@ -513,38 +523,54 @@ storeVar IFloat (Ref _) var = boxStore boxFloat var
513
523
storeVar IDouble IUnknown var = boxStore boxDouble var
514
524
storeVar IDouble (Ref _ ) var = boxStore boxDouble var
515
525
516
- storeVar IUnknown IBool var = storeVarWithWordSize (\ index => do unboxBool ; Istore index) var
517
- storeVar (Ref _ ) IBool var = storeVarWithWordSize (\ index => do unboxBool ; Istore index) var
526
+ storeVar IUnknown IBool var = storeVarWithWordSize (\ index => do cgCast IUnknown IBool ; Istore index) var
527
+ storeVar srcTy@ (Ref _ ) IBool var = storeVarWithWordSize (\ index => do cgCast srcTy IBool ; Istore index) var
518
528
519
- storeVar IUnknown IByte var = storeVarWithWordSize (\ index => do unboxByte ; Istore index) var
520
- storeVar (Ref _ ) IByte var = storeVarWithWordSize (\ index => do unboxByte ; Istore index) var
529
+ storeVar IUnknown IByte var = storeVarWithWordSize (\ index => do cgCast IUnknown IByte ; Istore index) var
530
+ storeVar srcTy@ (Ref _ ) IByte var = storeVarWithWordSize (\ index => do cgCast srcTy IByte ; Istore index) var
521
531
522
- storeVar IUnknown IChar var = storeVarWithWordSize (\ index => do unboxChar ; Istore index) var
523
- storeVar (Ref _ ) IChar var = storeVarWithWordSize (\ index => do unboxChar ; Istore index) var
532
+ storeVar IUnknown IChar var = storeVarWithWordSize (\ index => do cgCast IUnknown IChar ; Istore index) var
533
+ storeVar srcTy@ (Ref _ ) IChar var = storeVarWithWordSize (\ index => do cgCast srcTy IChar ; Istore index) var
524
534
525
- storeVar IUnknown IShort var = storeVarWithWordSize (\ index => do unboxShort ; Istore index) var
526
- storeVar (Ref _ ) IShort var = storeVarWithWordSize (\ index => do unboxShort ; Istore index) var
535
+ storeVar IUnknown IShort var = storeVarWithWordSize (\ index => do cgCast IUnknown IShort ; Istore index) var
536
+ storeVar srcTy@ (Ref _ ) IShort var = storeVarWithWordSize (\ index => do cgCast srcTy IShort ; Istore index) var
527
537
528
- storeVar IUnknown IInt var = storeVarWithWordSize (\ index => do unboxInt ; Istore index) var
529
- storeVar (Ref _ ) IInt var = storeVarWithWordSize (\ index => do unboxInt ; Istore index) var
538
+ storeVar IUnknown IInt var = storeVarWithWordSize (\ index => do cgCast IUnknown IInt ; Istore index) var
539
+ storeVar srcTy@ (Ref _ ) IInt var = storeVarWithWordSize (\ index => do cgCast srcTy IInt ; Istore index) var
530
540
531
- storeVar IUnknown ILong var = storeVarWithWordSize (\ index => do unboxLong ; Lstore index) var
532
- storeVar (Ref _ ) ILong var = storeVarWithWordSize (\ index => do unboxLong ; Lstore index) var
541
+ storeVar IUnknown ILong var = storeVarWithWordSize (\ index => do cgCast IUnknown ILong ; Lstore index) var
542
+ storeVar srcTy@ (Ref _ ) ILong var = storeVarWithWordSize (\ index => do cgCast srcTy ILong ; Lstore index) var
533
543
534
- storeVar IUnknown IFloat var = storeVarWithWordSize (\ index => do unboxFloat ; Fstore index) var
535
- storeVar (Ref _ ) IFloat var = storeVarWithWordSize (\ index => do unboxFloat ; Fstore index) var
544
+ storeVar IUnknown IFloat var = storeVarWithWordSize (\ index => do cgCast IUnknown IFloat ; Fstore index) var
545
+ storeVar srcTy@ (Ref _ ) IFloat var = storeVarWithWordSize (\ index => do cgCast srcTy IFloat ; Fstore index) var
536
546
537
- storeVar IUnknown IDouble var = storeVarWithWordSize (\ index => do unboxDouble ; Dstore index) var
538
- storeVar (Ref _ ) IDouble var = storeVarWithWordSize (\ index => do unboxDouble ; Dstore index) var
547
+ storeVar IUnknown IDouble var = storeVarWithWordSize (\ index => do cgCast IUnknown IDouble ; Dstore index) var
548
+ storeVar srcTy@ (Ref _ ) IDouble var = storeVarWithWordSize (\ index => do cgCast srcTy IDouble ; Dstore index) var
539
549
540
550
storeVar IUnknown arr@(IArray elemTy) var =
541
551
storeVarWithWordSize (\ index => do Checkcast $ getInferredTyDesc arr; Astore index) var
542
552
storeVar (Ref _ ) arr@(IArray elemTy) var =
543
553
storeVarWithWordSize (\ index => do Checkcast $ getInferredTyDesc arr; Astore index) var
544
554
545
- storeVar (Ref _ ) (Ref _ ) var = do types <- GetFunctionLocTypes ; opWithWordSize types Astore var
555
+ storeVar IUnknown targetTy@(Ref _ ) var = do
556
+ types <- GetFunctionLocTypes
557
+ cgCast IUnknown targetTy
558
+ opWithWordSize types Astore var
559
+
560
+ storeVar srcTy@(Ref _ ) targetTy@(Ref _ ) var = do
561
+ types <- GetFunctionLocTypes
562
+ cgCast srcTy targetTy
563
+ opWithWordSize types Astore var
564
+
546
565
storeVar _ _ var = do types <- GetFunctionLocTypes ; opWithWordSize types Astore var
547
566
567
+ idrisObjectProperty : Int -> Int -> Asm ()
568
+ idrisObjectProperty object propertyIndex = do
569
+ locTypes <- GetFunctionLocTypes
570
+ loadVar locTypes inferredObjectType inferredObjectType (Loc object)
571
+ Iconst propertyIndex
572
+ InvokeMethod InvokeStatic idrisObjectType " getProperty" " (Ljava/lang/Object;I)Ljava/lang/Object;" False
573
+
548
574
assign : (lhs : List LVar) -> (rhs : List LVar) -> Asm ()
549
575
assign lhs rhs = do
550
576
locTypes <- GetFunctionLocTypes
@@ -570,4 +596,4 @@ unwrapExportedIO = do
570
596
let desc = getInferredFunDesc argTys retTy
571
597
cgCast inferredObjectType lastArgTy
572
598
InvokeMethod InvokeStatic " main/Main" " call__IO" desc False
573
- InvokeMethod InvokeStatic (rtClass " Runtime" ) " unwrap" (sig 1 ) False
599
+ InvokeMethod InvokeStatic (rtClass " Runtime" ) " unwrap" (sig 1 ) False
0 commit comments