Remove update* calls
This commit is contained in:
+6
-3
@@ -371,18 +371,21 @@ open class SerializerIrGenerator(val irClass: IrClass, final override val compil
|
|||||||
property.type,
|
property.type,
|
||||||
genericIndex = property.genericIndex
|
genericIndex = property.genericIndex
|
||||||
)
|
)
|
||||||
|
val isSerializable = innerSerial != null
|
||||||
// todo: update
|
// todo: update
|
||||||
val decodeFuncToCall =
|
val decodeFuncToCall =
|
||||||
(if (innerSerial != null) "${CallingConventions.decode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}"
|
(if (isSerializable) "${CallingConventions.decode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}"
|
||||||
else "${CallingConventions.decode}${sti.elementMethodPrefix}${CallingConventions.elementPostfix}")
|
else "${CallingConventions.decode}${sti.elementMethodPrefix}${CallingConventions.elementPostfix}")
|
||||||
.let {
|
.let {
|
||||||
inputClass.referenceMethod(it)
|
inputClass.referenceMethod(it) { it.valueParameters.size == if (isSerializable) 4 else 2 }
|
||||||
}
|
}
|
||||||
val typeArgs =
|
val typeArgs =
|
||||||
if (decodeFuncToCall.descriptor.typeParameters.isNotEmpty()) listOf(property.type.toIrType()) else listOf()
|
if (decodeFuncToCall.descriptor.typeParameters.isNotEmpty()) listOf(property.type.toIrType()) else listOf()
|
||||||
val args = mutableListOf<IrExpression>(localSerialDesc.get(), irInt(index))
|
val args = mutableListOf<IrExpression>(localSerialDesc.get(), irInt(index))
|
||||||
if (innerSerial != null)
|
if (innerSerial != null) {
|
||||||
args.add(innerSerial)
|
args.add(innerSerial)
|
||||||
|
args.add(localProps[index].get())
|
||||||
|
}
|
||||||
// local$i = localInput.decode...(...)
|
// local$i = localInput.decode...(...)
|
||||||
+irSetVar(
|
+irSetVar(
|
||||||
localProps[index].symbol,
|
localProps[index].symbol,
|
||||||
|
|||||||
+9
-34
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlinx.serialization.compiler.backend.js
|
package org.jetbrains.kotlinx.serialization.compiler.backend.js
|
||||||
@@ -297,30 +286,16 @@ open class SerializerJsTranslator(
|
|||||||
)
|
)
|
||||||
JsInvocation(JsNameRef(readFunc, inputVar), readArgs)
|
JsInvocation(JsNameRef(readFunc, inputVar), readArgs)
|
||||||
} else {
|
} else {
|
||||||
val notSeenTest = propNotSeenTest(bitMasks[bitMaskOff(i)], i)
|
|
||||||
val readFunc =
|
val readFunc =
|
||||||
inputClass.getFuncDesc("${CallingConventions.decode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}")
|
inputClass.getFuncDesc("${CallingConventions.decode}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}")
|
||||||
.single()
|
.single { it.valueParameters.size == 4 }
|
||||||
.let { context.getNameForDescriptor(it) }
|
.let { context.getNameForDescriptor(it) }
|
||||||
val updateFunc =
|
JsInvocation(
|
||||||
inputClass.getFuncDesc("${CallingConventions.update}${sti.elementMethodPrefix}Serializable${CallingConventions.elementPostfix}")
|
JsNameRef(readFunc, inputVar),
|
||||||
.single()
|
serialClassDescRef,
|
||||||
.let { context.getNameForDescriptor(it) }
|
JsIntLiteral(i),
|
||||||
JsConditional(
|
innerSerial,
|
||||||
notSeenTest,
|
localProps[i]
|
||||||
JsInvocation(
|
|
||||||
JsNameRef(readFunc, inputVar),
|
|
||||||
serialClassDescRef,
|
|
||||||
JsIntLiteral(i),
|
|
||||||
innerSerial
|
|
||||||
),
|
|
||||||
JsInvocation(
|
|
||||||
JsNameRef(updateFunc, inputVar),
|
|
||||||
serialClassDescRef,
|
|
||||||
JsIntLiteral(i),
|
|
||||||
innerSerial,
|
|
||||||
localProps[i]
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// localPropI = ...
|
// localPropI = ...
|
||||||
|
|||||||
+8
-30
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlinx.serialization.compiler.backend.jvm
|
package org.jetbrains.kotlinx.serialization.compiler.backend.jvm
|
||||||
@@ -476,35 +465,24 @@ open class SerializerCodegenImpl(
|
|||||||
AsmUtil.wrapJavaClassIntoKClass(this)
|
AsmUtil.wrapJavaClassIntoKClass(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun produceCall(update: Boolean) {
|
fun produceCall(isUpdatable: Boolean) {
|
||||||
invokeinterface(
|
invokeinterface(
|
||||||
kInputType.internalName,
|
kInputType.internalName,
|
||||||
(if (update) CallingConventions.update else CallingConventions.decode) + sti.elementMethodPrefix + (if (useSerializer) "Serializable" else "") + CallingConventions.elementPostfix,
|
(CallingConventions.decode) + sti.elementMethodPrefix + (if (useSerializer) "Serializable" else "") + CallingConventions.elementPostfix,
|
||||||
"(" + descType.descriptor + "I" +
|
"(" + descType.descriptor + "I" +
|
||||||
(if (useSerializer) kSerialLoaderType.descriptor else "")
|
(if (useSerializer) kSerialLoaderType.descriptor else "")
|
||||||
+ (if (unknownSer) AsmTypes.K_CLASS_TYPE.descriptor else "")
|
+ (if (unknownSer) AsmTypes.K_CLASS_TYPE.descriptor else "")
|
||||||
+ (if (update) sti.type.descriptor else "")
|
+ (if (isUpdatable) sti.type.descriptor else "")
|
||||||
+ ")" + (sti.type.descriptor)
|
+ ")" + (sti.type.descriptor)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useSerializer && propertyAddressInBitMask != -1) {
|
val isUpdatable = useSerializer && propertyAddressInBitMask != -1
|
||||||
// we can choose either it is read or update
|
if (isUpdatable) {
|
||||||
val readLabel = Label()
|
|
||||||
val endL = Label()
|
|
||||||
genValidateProperty(index, propertyAddressInBitMask)
|
|
||||||
ificmpeq(readLabel)
|
|
||||||
load(propertyVar, propertyType)
|
load(propertyVar, propertyType)
|
||||||
StackValue.coerce(propertyType, sti.type, this)
|
StackValue.coerce(propertyType, sti.type, this)
|
||||||
produceCall(true)
|
|
||||||
goTo(endL)
|
|
||||||
visitLabel(readLabel)
|
|
||||||
produceCall(false)
|
|
||||||
visitLabel(endL)
|
|
||||||
} else {
|
|
||||||
// update not supported for primitive types or decodeSequentially
|
|
||||||
produceCall(false)
|
|
||||||
}
|
}
|
||||||
|
produceCall(isUpdatable)
|
||||||
|
|
||||||
StackValue.coerce(sti.type, propertyType, this)
|
StackValue.coerce(sti.type, propertyType, this)
|
||||||
store(propertyVar, propertyType)
|
store(propertyVar, propertyType)
|
||||||
|
|||||||
Reference in New Issue
Block a user