blob: 9939980fcc5cf4377cd63da28691bc91a3d7b534 [file] [log] [blame]
// Copyright (c) 2019, 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.analysis.value;
import com.android.tools.r8.graph.AppView;
import com.android.tools.r8.graph.GraphLense;
import com.android.tools.r8.shaking.AppInfoWithLiveness;
public abstract class AbstractValue {
public abstract boolean isNonTrivial();
public boolean isBottom() {
return false;
}
public boolean isZero() {
return false;
}
/**
* Returns true if this abstract value represents a single concrete value (i.e., the
* concretization of this abstract value has size 1).
*/
public boolean isSingleValue() {
return false;
}
public SingleValue asSingleValue() {
return null;
}
public boolean isSingleConstValue() {
return false;
}
public boolean isSingleConstClassValue() {
return false;
}
public SingleConstClassValue asSingleConstClassValue() {
return null;
}
public boolean isSingleFieldValue() {
return false;
}
public SingleFieldValue asSingleFieldValue() {
return null;
}
public boolean isSingleNumberValue() {
return false;
}
public SingleNumberValue asSingleNumberValue() {
return null;
}
public boolean isSingleStringValue() {
return false;
}
public SingleStringValue asSingleStringValue() {
return null;
}
public boolean isUnknown() {
return false;
}
public AbstractValue join(AbstractValue other) {
if (isBottom() || other.isUnknown()) {
return other;
}
if (isUnknown() || other.isBottom()) {
return this;
}
if (equals(other)) {
return this;
}
return UnknownValue.getInstance();
}
public abstract AbstractValue rewrittenWithLens(
AppView<AppInfoWithLiveness> appView, GraphLense lens);
@Override
public abstract boolean equals(Object o);
@Override
public abstract int hashCode();
@Override
public abstract String toString();
}