提交 b9521991 编写于 作者: D Dmitry Jemerov

namespace property initializers are written directly to backing fields

上级 8b823d83
......@@ -49,7 +49,7 @@ public class ClassFileFactory {
String fqName = namespace.getFQName();
NamespaceCodegen codegen = ns2codegen.get(fqName);
if (codegen == null) {
codegen = new NamespaceCodegen(project, newVisitor(NamespaceCodegen.getJVMClassName(fqName) + ".class"), fqName, state);
codegen = new NamespaceCodegen(newVisitor(NamespaceCodegen.getJVMClassName(fqName) + ".class"), fqName, state);
ns2codegen.put(fqName, codegen);
}
......
package org.jetbrains.jet.codegen;
import com.intellij.openapi.project.Project;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.objectweb.asm.ClassVisitor;
......@@ -13,12 +12,10 @@ import org.objectweb.asm.commons.InstructionAdapter;
* @author max
*/
public class NamespaceCodegen {
private final Project project;
private final ClassVisitor v;
private final GenerationState state;
public NamespaceCodegen(Project project, ClassVisitor v, String fqName, GenerationState state) {
this.project = project;
public NamespaceCodegen(ClassVisitor v, String fqName, GenerationState state) {
this.v = v;
this.state = state;
......@@ -80,7 +77,7 @@ public class NamespaceCodegen {
if (initializer != null && !(initializer instanceof JetConstantExpression)) {
final PropertyDescriptor descriptor = (PropertyDescriptor) state.getBindingContext().getVariableDescriptor((JetProperty) declaration);
codegen.genToJVMStack(initializer);
codegen.intermediateValueForProperty(descriptor, false, false).store(new InstructionAdapter(mv));
codegen.intermediateValueForProperty(descriptor, true, false).store(new InstructionAdapter(mv));
}
}
}
......
......@@ -80,6 +80,9 @@ public class PropertyGenTest extends CodegenTestCase {
final Method method = generateFunction("append");
method.invoke(null, "IntelliJ ");
String value = (String) method.invoke(null, "IDEA");
if (!value.equals("IntelliJ IDEA")) {
System.out.println(generateToText());
}
assertEquals("IntelliJ IDEA", value);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册