19
19
import org .openzen .zenscript .codemodel .ssa .CodeBlockStatement ;
20
20
import org .openzen .zenscript .codemodel .ssa .SSAVariableCollector ;
21
21
import org .openzen .zenscript .codemodel .type .ArrayTypeID ;
22
+ import org .openzen .zenscript .codemodel .type .BasicTypeID ;
22
23
import org .openzen .zenscript .codemodel .type .TypeID ;
23
24
import org .openzen .zenscript .codemodel .type .builtin .BuiltinMethodSymbol ;
24
25
import org .openzen .zenscript .javashared .JavaClass ;
@@ -213,9 +214,9 @@ private void loadMethods() {
213
214
if (class_ .cls .isEnum ()) {
214
215
Stream .of (
215
216
BuiltinMethodSymbol .ENUM_NAME ,
216
- BuiltinMethodSymbol .ENUM_ORDINAL ,
217
+ BuiltinMethodSymbol .ENUM_ORDINAL
217
218
//BuiltinMethodSymbol.ENUM_VALUES,
218
- BuiltinMethodSymbol .ENUM_COMPARE
219
+ // BuiltinMethodSymbol.ENUM_COMPARE
219
220
).forEach (method -> methods
220
221
.computeIfAbsent (method .getID (), x -> new ArrayList <>())
221
222
.add (method )
@@ -232,6 +233,18 @@ private void loadMethods() {
232
233
throw new IllegalStateException ("We found an enum class without values() method: " + class_ .cls .getCanonicalName (), exception );
233
234
}
234
235
236
+ try {
237
+ MethodID id = MethodID .operator (OperatorType .COMPARE );
238
+ FunctionHeader header = new FunctionHeader (BasicTypeID .INT , target );
239
+ Method method = class_ .cls .getMethod ("compareTo" , Enum .class );
240
+ JavaRuntimeMethod runtimeMethod = new JavaRuntimeMethod (class_ , target , method , id , header , false , false );
241
+ methods .computeIfAbsent (id , x -> new ArrayList <>()).add (runtimeMethod );
242
+ class_ .module .getCompiled ().setMethodInfo (runtimeMethod , runtimeMethod );
243
+ } catch (ReflectiveOperationException exception ) {
244
+ throw new IllegalStateException ("Error while registering Enum#compareTo for: " + class_ .cls .getCanonicalName (), exception );
245
+ }
246
+
247
+
235
248
}
236
249
}
237
250
0 commit comments