Skip to content

Commit

Permalink
<fix>(v2,v3): fix struct[][], struct[2][], struct[2][3] cases bug. (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyonRay authored Mar 4, 2024
1 parent 9cc1b17 commit 6325a1b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1648,13 +1648,11 @@ private List<TypeSpec> buildStructTypes(List<ABIDefinition> functionDefinitions)
if (internalType == null || internalType.isEmpty()) {
structName = "Struct" + structCounter;
} else {
if (namedType.getType().equals("tuple[]") && internalType.endsWith("[]")) {
internalType = internalType.substring(0, internalType.lastIndexOf("["));
}
if (namedType.getType().matches("tuple\\[\\d+\\]")
// struct array, such as struct[2], struct[], struct[][], struct[2][]
if (namedType.getType().matches("tuple(\\[\\d*\\])+")
&& internalType.endsWith("]")
&& internalType.matches(".*\\[\\d+\\]")) {
internalType = internalType.substring(0, internalType.lastIndexOf("["));
&& internalType.matches(".*(\\[\\d*\\])+")) {
internalType = internalType.substring(0, internalType.indexOf("["));
}
if (internalType.contains(".")) {
structName = internalType.substring(internalType.lastIndexOf(".") + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,11 @@ private List<TypeSpec> buildStructTypes(List<ABIDefinition> functionDefinitions)
if (internalType == null || internalType.isEmpty()) {
structName = "Struct" + structCounter;
} else {
if (namedType.getType().equals("tuple[]") && internalType.endsWith("[]")) {
internalType = internalType.substring(0, internalType.lastIndexOf("["));
}
if (namedType.getType().matches("tuple\\[\\d+\\]")
// struct array, such as struct[2], struct[], struct[][], struct[2][]
if (namedType.getType().matches("tuple(\\[\\d*\\])+")
&& internalType.endsWith("]")
&& internalType.matches(".*\\[\\d+\\]")) {
internalType = internalType.substring(0, internalType.lastIndexOf("["));
&& internalType.matches(".*(\\[\\d*\\])+")) {
internalType = internalType.substring(0, internalType.indexOf("["));
}
if (isWasm) {
structName = internalType.substring(internalType.lastIndexOf(".") + 1);
Expand Down
Loading

0 comments on commit 6325a1b

Please sign in to comment.