Exemplo n.º 1
0
  private void initializeProperty(
      @NotNull ExpressionCodegen codegen, @NotNull JetProperty property) {
    PropertyDescriptor propertyDescriptor =
        (PropertyDescriptor) bindingContext.get(VARIABLE, property);
    assert propertyDescriptor != null;

    JetExpression initializer = property.getDelegateExpressionOrInitializer();
    assert initializer != null
        : "shouldInitializeProperty must return false if initializer is null";

    JetType jetType = getPropertyOrDelegateType(property, propertyDescriptor);

    StackValue.Property propValue =
        codegen.intermediateValueForProperty(
            propertyDescriptor, true, null, MethodKind.INITIALIZER);

    if (!propValue.isStatic) {
      codegen.v.load(0, OBJECT_TYPE);
    }

    Type type = codegen.expressionType(initializer);
    if (jetType.isNullable()) {
      type = boxType(type);
    }
    codegen.gen(initializer, type);

    propValue.store(type, codegen.v);
  }
Exemplo n.º 2
0
 @Override
 public StackValue visitWhenExpression(JetWhenExpression expression, StackValue data) {
   return codegen.generateWhenExpression(expression, true);
 }
Exemplo n.º 3
0
 @Override
 public StackValue visitIfExpression(JetIfExpression expression, StackValue receiver) {
   return codegen.generateIfExpression(expression, true);
 }