Skip to content

Commit

Permalink
JACOBIN-608 Initial implementation of <clinit> for java/util/HexFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
platypusguy committed Nov 16, 2024
1 parent 6b36b75 commit 93403b0
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gfunction/gfunction.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func MTableLoadGFunctions(MTable *classloader.MT) {
Load_Util_Concurrent_Atomic_AtomicInteger()
Load_Util_Concurrent_Atomic_Atomic_Long()
Load_Util_HashMap()
Load_Util_HexFormat()
Load_Util_Locale()
Load_Util_Random()

Expand Down
61 changes: 61 additions & 0 deletions src/gfunction/javaUtilHexFormat.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Jacobin VM - A Java virtual machine
* Copyright (c) 2024 by the Jacobin authors. Consult jacobin.org.
* Licensed under Mozilla Public License 2.0 (MPL 2.0) All rights reserved.
*/

package gfunction

import "jacobin/statics"

// Implementation of some of the functions in in Java/lang/Class.

func Load_Util_HexFormat() {

MethodSignatures["java/util/HexFormat.<clinit>()V"] =
GMeth{
ParamSlots: 0,
GFunction: hexMapClinit,
}
}

// hashMapHash accepts a pointer to an object and returns
// a uint64 MD5 hash value of the pointed-to thing
func hexMapClinit(params []interface{}) interface{} {
DIGITS := [256]int8{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
}
sDigits := statics.Static{Type: "[B", Value: DIGITS}
statics.AddStatic("java/util/HexFormat.DIGITS", sDigits)

UPPERCASE_DIGITS := [16]int8{
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
}
sUppercaseDigits := statics.Static{Type: "[B", Value: UPPERCASE_DIGITS}
statics.AddStatic("java/util/HexFormat.UPPERCASE_DIGITS", sUppercaseDigits)

LOWERCASE_DIGITS := [16]int8{
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
}
sLowercaseDigits := statics.Static{Type: "[B", Value: LOWERCASE_DIGITS}
statics.AddStatic("java/util/HexFormat.LOWERCASE_DIGITS", sLowercaseDigits)

return nil
}

0 comments on commit 93403b0

Please sign in to comment.