-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable type conversions #63
base: main
Are you sure you want to change the base?
Conversation
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success1136 tests passing in 63 suites. Report generated by 🧪jest coverage report action from 2a2cc0b |
if (areClassTypesCompatible(fromType, toType) || fromType === '') { | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will fromType be empty?
const methodInfo = symbolInfos[symbolInfos.length - 1] as MethodInfos | ||
if (!methodInfo || methodInfo.length === 0) { | ||
throw new Error(`No method information found for ${n.identifier}`) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps can rename methodInfo
to methodInfos
, then can remove the methodInfos
in line 796 to remove duplication
const fullDescriptor = methodInfo[0].typeDescriptor // Full descriptor, e.g., "(Ljava/lang/String;C)V" | ||
const paramDescriptor = fullDescriptor.slice(1, fullDescriptor.indexOf(')')) // Extract "Ljava/lang/String;C" | ||
const params = paramDescriptor.match(/(\[+[BCDFIJSZ])|(\[+L[^;]+;)|[BCDFIJSZ]|L[^;]+;/g) | ||
|
||
// Parse individual parameter types | ||
if (params && params.length !== n.argumentList.length) { | ||
throw new Error( | ||
`Parameter mismatch: expected ${params?.length || 0}, got ${n.argumentList.length}` | ||
) | ||
} | ||
|
||
n.argumentList.forEach((x, i) => { | ||
const argCompileResult = compile(x, cg) | ||
maxStack = Math.max(maxStack, i + 1 + argCompileResult.stackSize) | ||
|
||
const expectedType = params?.[i] // Expected parameter type | ||
const stackSizeChange = handleImplicitTypeConversion(argCompileResult.resultType, expectedType ?? '', cg) | ||
maxStack = Math.max(maxStack, i + 1 + argCompileResult.stackSize + stackSizeChange) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i assume your scope are not supporting method overloading? otherwise might have issues of converting type unnecessary because here it's always converted to match the first method in methodInfo
array.
cg.code.push(typeConversionsImplicit[conversionKeyRight]) | ||
finalType = 'D'; | ||
} else if (leftType !== 'F' && rightType === 'F') { | ||
// handleImplicitTypeConversion(leftType, 'F', cg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can remove this commented out line~
Fixes #56