mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Fix codegen for overload resolution. Fixes #6300
This commit is contained in:
parent
96311aa9b7
commit
e5b8e81bf8
1 changed files with 9 additions and 16 deletions
|
@ -177,14 +177,15 @@ class CGMethodCall(CGThing):
|
||||||
requiredArgs -= 1
|
requiredArgs -= 1
|
||||||
return requiredArgs
|
return requiredArgs
|
||||||
|
|
||||||
def getPerSignatureCall(signature, argConversionStartsAt=0, signatureIndex=0):
|
|
||||||
|
signatures = method.signatures()
|
||||||
|
def getPerSignatureCall(signature, argConversionStartsAt=0):
|
||||||
|
signatureIndex = signatures.index(signature)
|
||||||
return CGPerSignatureCall(signature[0], argsPre, signature[1],
|
return CGPerSignatureCall(signature[0], argsPre, signature[1],
|
||||||
nativeMethodName + '_'*signatureIndex,
|
nativeMethodName + '_'*signatureIndex,
|
||||||
static, descriptor,
|
static, descriptor,
|
||||||
method, argConversionStartsAt)
|
method, argConversionStartsAt)
|
||||||
|
|
||||||
|
|
||||||
signatures = method.signatures()
|
|
||||||
if len(signatures) == 1:
|
if len(signatures) == 1:
|
||||||
# Special case: we can just do a per-signature method call
|
# Special case: we can just do a per-signature method call
|
||||||
# here for our one signature and not worry about switching
|
# here for our one signature and not worry about switching
|
||||||
|
@ -215,12 +216,7 @@ class CGMethodCall(CGThing):
|
||||||
if len(possibleSignatures) == 1:
|
if len(possibleSignatures) == 1:
|
||||||
# easy case!
|
# easy case!
|
||||||
signature = possibleSignatures[0]
|
signature = possibleSignatures[0]
|
||||||
|
argCountCases.append(CGCase(str(argCount), getPerSignatureCall(signature)))
|
||||||
|
|
||||||
sigIndex = signatures.index(signature)
|
|
||||||
argCountCases.append(
|
|
||||||
CGCase(str(argCount), getPerSignatureCall(signature,
|
|
||||||
signatureIndex=sigIndex)))
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
distinguishingIndex = method.distinguishingIndexForArgCount(argCount)
|
distinguishingIndex = method.distinguishingIndexForArgCount(argCount)
|
||||||
|
@ -249,15 +245,12 @@ class CGMethodCall(CGThing):
|
||||||
sigs = filter(filterLambda, possibleSignatures)
|
sigs = filter(filterLambda, possibleSignatures)
|
||||||
assert len(sigs) < 2
|
assert len(sigs) < 2
|
||||||
if len(sigs) > 0:
|
if len(sigs) > 0:
|
||||||
|
call = getPerSignatureCall(sigs[0], distinguishingIndex)
|
||||||
if condition is None:
|
if condition is None:
|
||||||
caseBody.append(
|
caseBody.append(call)
|
||||||
getPerSignatureCall(sigs[0], distinguishingIndex,
|
|
||||||
possibleSignatures.index(sigs[0])))
|
|
||||||
else:
|
else:
|
||||||
caseBody.append(CGGeneric("if " + condition + " {"))
|
caseBody.append(CGGeneric("if " + condition + " {"))
|
||||||
caseBody.append(CGIndenter(
|
caseBody.append(CGIndenter(call))
|
||||||
getPerSignatureCall(sigs[0], distinguishingIndex,
|
|
||||||
possibleSignatures.index(sigs[0]))))
|
|
||||||
caseBody.append(CGGeneric("}"))
|
caseBody.append(CGGeneric("}"))
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -318,7 +311,7 @@ class CGMethodCall(CGThing):
|
||||||
# distinguishingIndex + 1, since we already converted
|
# distinguishingIndex + 1, since we already converted
|
||||||
# distinguishingIndex.
|
# distinguishingIndex.
|
||||||
caseBody.append(CGIndenter(
|
caseBody.append(CGIndenter(
|
||||||
getPerSignatureCall(sig, distinguishingIndex + 1, idx), 4))
|
getPerSignatureCall(sig, distinguishingIndex + 1), 4))
|
||||||
caseBody.append(CGIndenter(CGGeneric("}")))
|
caseBody.append(CGIndenter(CGGeneric("}")))
|
||||||
|
|
||||||
caseBody.append(CGGeneric("}"))
|
caseBody.append(CGGeneric("}"))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue