Optimize KProperty objects for delegated properties
Don't generate anonymous classes with a lot of methods because this hurts Android. Add special classes to the runtime instead (also add FunctionReferenceImpl, to be used later) and just create their instances in the static initializer of each class
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* 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 kotlin.jvm.internal;
|
||||
|
||||
import kotlin.reflect.KDeclarationContainer;
|
||||
|
||||
public class FunctionReferenceImpl extends FunctionReference {
|
||||
private final KDeclarationContainer owner;
|
||||
private final String name;
|
||||
private final String signature;
|
||||
|
||||
public FunctionReferenceImpl(int arity, KDeclarationContainer owner, String name, String signature) {
|
||||
super(arity);
|
||||
this.owner = owner;
|
||||
this.name = name;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KDeclarationContainer getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* 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 kotlin.jvm.internal;
|
||||
|
||||
import kotlin.reflect.KDeclarationContainer;
|
||||
|
||||
public class MutablePropertyReference0Impl extends MutablePropertyReference0 {
|
||||
private final KDeclarationContainer owner;
|
||||
private final String name;
|
||||
private final String signature;
|
||||
|
||||
public MutablePropertyReference0Impl(KDeclarationContainer owner, String name, String signature) {
|
||||
this.owner = owner;
|
||||
this.name = name;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KDeclarationContainer getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get() {
|
||||
return getGetter().call();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(Object value) {
|
||||
getSetter().call(value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* 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 kotlin.jvm.internal;
|
||||
|
||||
import kotlin.reflect.KDeclarationContainer;
|
||||
|
||||
public class MutablePropertyReference1Impl extends MutablePropertyReference1 {
|
||||
private final KDeclarationContainer owner;
|
||||
private final String name;
|
||||
private final String signature;
|
||||
|
||||
public MutablePropertyReference1Impl(KDeclarationContainer owner, String name, String signature) {
|
||||
this.owner = owner;
|
||||
this.name = name;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KDeclarationContainer getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(Object receiver) {
|
||||
return getGetter().call(receiver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(Object receiver, Object value) {
|
||||
getSetter().call(receiver, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* 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 kotlin.jvm.internal;
|
||||
|
||||
import kotlin.reflect.KDeclarationContainer;
|
||||
|
||||
public class MutablePropertyReference2Impl extends MutablePropertyReference2 {
|
||||
private final KDeclarationContainer owner;
|
||||
private final String name;
|
||||
private final String signature;
|
||||
|
||||
public MutablePropertyReference2Impl(KDeclarationContainer owner, String name, String signature) {
|
||||
this.owner = owner;
|
||||
this.name = name;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KDeclarationContainer getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(Object receiver1, Object receiver2) {
|
||||
return getGetter().call(receiver1, receiver2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(Object receiver1, Object receiver2, Object value) {
|
||||
getSetter().call(receiver1, receiver2, value);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* 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 kotlin.jvm.internal;
|
||||
|
||||
import kotlin.reflect.KDeclarationContainer;
|
||||
|
||||
public class PropertyReference0Impl extends PropertyReference0 {
|
||||
private final KDeclarationContainer owner;
|
||||
private final String name;
|
||||
private final String signature;
|
||||
|
||||
public PropertyReference0Impl(KDeclarationContainer owner, String name, String signature) {
|
||||
this.owner = owner;
|
||||
this.name = name;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KDeclarationContainer getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get() {
|
||||
return getGetter().call();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* 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 kotlin.jvm.internal;
|
||||
|
||||
import kotlin.reflect.KDeclarationContainer;
|
||||
|
||||
public class PropertyReference1Impl extends PropertyReference1 {
|
||||
private final KDeclarationContainer owner;
|
||||
private final String name;
|
||||
private final String signature;
|
||||
|
||||
public PropertyReference1Impl(KDeclarationContainer owner, String name, String signature) {
|
||||
this.owner = owner;
|
||||
this.name = name;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KDeclarationContainer getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(Object receiver) {
|
||||
return getGetter().call(receiver);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* 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 kotlin.jvm.internal;
|
||||
|
||||
import kotlin.reflect.KDeclarationContainer;
|
||||
|
||||
public class PropertyReference2Impl extends PropertyReference2 {
|
||||
private final KDeclarationContainer owner;
|
||||
private final String name;
|
||||
private final String signature;
|
||||
|
||||
public PropertyReference2Impl(KDeclarationContainer owner, String name, String signature) {
|
||||
this.owner = owner;
|
||||
this.name = name;
|
||||
this.signature = signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KDeclarationContainer getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(Object receiver1, Object receiver2) {
|
||||
return getGetter().call(receiver1, receiver2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user