JS backend: minor: improve call translation for constant receiver
This commit is contained in:
@@ -84,15 +84,21 @@ fun TranslationContext.getCallInfo(resolvedCall: ResolvedCall<out FunctionDescri
|
|||||||
val argumentsInfo = CallArgumentTranslator.translate(resolvedCall, explicitReceivers.receiverOrThisObject, this, argsBlock)
|
val argumentsInfo = CallArgumentTranslator.translate(resolvedCall, explicitReceivers.receiverOrThisObject, this, argsBlock)
|
||||||
val explicitReceiversCorrected =
|
val explicitReceiversCorrected =
|
||||||
if (!argsBlock.isEmpty() && explicitReceivers.receiverOrThisObject != null) {
|
if (!argsBlock.isEmpty() && explicitReceivers.receiverOrThisObject != null) {
|
||||||
val receiverOrThisRefVar = this.declareTemporary(explicitReceivers.receiverOrThisObject)
|
val receiverOrThisRef =
|
||||||
this.addStatementToCurrentBlock(receiverOrThisRefVar.assignmentExpression().makeStmt()!!)
|
if (TranslationUtils.isCacheNeeded(explicitReceivers.receiverOrThisObject)) {
|
||||||
|
val receiverOrThisRefVar = this.declareTemporary(explicitReceivers.receiverOrThisObject)
|
||||||
|
this.addStatementToCurrentBlock(receiverOrThisRefVar.assignmentExpression().makeStmt())
|
||||||
|
receiverOrThisRefVar.reference()
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
explicitReceivers.receiverOrThisObject
|
||||||
|
}
|
||||||
var receiverRef = explicitReceivers.receiverObject
|
var receiverRef = explicitReceivers.receiverObject
|
||||||
if (receiverRef != null) {
|
if (receiverRef != null) {
|
||||||
receiverRef = this.declareTemporary(null).reference()
|
receiverRef = this.declareTemporary(null).reference()
|
||||||
this.addStatementToCurrentBlock(JsAstUtils.assignment(receiverRef!!, explicitReceivers.receiverObject!!).makeStmt()!!)
|
this.addStatementToCurrentBlock(JsAstUtils.assignment(receiverRef!!, explicitReceivers.receiverObject!!).makeStmt())
|
||||||
}
|
}
|
||||||
ExplicitReceivers(receiverOrThisRefVar.reference(), receiverRef)
|
ExplicitReceivers(receiverOrThisRef, receiverRef)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
explicitReceivers
|
explicitReceivers
|
||||||
|
|||||||
Reference in New Issue
Block a user