StorageManager for compile-time initializer

This commit is contained in:
Natalia Ukhorskaya
2014-02-12 19:59:35 +04:00
parent 17259a052e
commit df3ed5059c
27 changed files with 75 additions and 89 deletions
@@ -1731,12 +1731,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
JetExpression initializer = property.getDelegateExpressionOrInitializer();
if (initializer == null) return false;
CompileTimeConstant<?> compileTimeValue = ExpressionCodegen.getCompileTimeConstant(initializer, typeMapper.getBindingContext());
if (compileTimeValue == null) return true;
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) typeMapper.getBindingContext().get(BindingContext.VARIABLE, property);
assert propertyDescriptor != null;
CompileTimeConstant<?> compileTimeValue = propertyDescriptor.getCompileTimeInitializer();
if (compileTimeValue == null) return true;
//TODO: OPTIMIZATION: don't initialize static final fields
Object value = compileTimeValue.getValue();
@@ -235,10 +235,9 @@ public class PropertyCodegen extends GenerationStateAware {
Object value = null;
if (ImplementationBodyCodegen.shouldWriteFieldInitializer(propertyDescriptor, typeMapper)) {
JetExpression initializer = p instanceof JetProperty ? ((JetProperty) p).getInitializer() : null;
CompileTimeConstant<?> initializer = propertyDescriptor.getCompileTimeInitializer();
if (initializer != null) {
CompileTimeConstant<?> compileTimeValue = ExpressionCodegen.getCompileTimeConstant(initializer, bindingContext);
value = compileTimeValue != null ? compileTimeValue.getValue() : null;
value = initializer.getValue();
}
}