blob: 29004917fb298f0f00ff12960db29fee33c31774 [file] [log] [blame]
// Copyright (c) 2017, the R8 project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.ir.code;
import com.android.tools.r8.graph.DexField;
import java.util.Collections;
import java.util.List;
public abstract class FieldInstruction extends Instruction {
private MemberType type;
private final DexField field;
protected FieldInstruction(DexField field, Value dest, Value value) {
this(field, dest, Collections.singletonList(value));
}
protected FieldInstruction(DexField field, Value dest, List<Value> inValues) {
super(dest, inValues);
assert field != null;
this.field = field;
this.type = MemberType.fromDexType(field.type);
}
public MemberType getType() {
return type;
}
public DexField getField() {
return field;
}
@Override
public boolean isFieldInstruction() {
return true;
}
@Override
public FieldInstruction asFieldInstruction() {
return this;
}
@Override
public boolean hasInvariantOutType() {
// TODO(jsjeon): what if the target field is known to be non-null?
return true;
}
}