Пример #1
0
 @Specialization
 protected Object getDimNames(RAbstractContainer container) {
   controlVisibility();
   RList names;
   if (container instanceof RDataFrame) {
     dataframeProfile.enter();
     names = ((RDataFrame) container).getVector().getDimNames();
   } else if (container instanceof RFactor) {
     factorProfile.enter();
     names = ((RFactor) container).getVector().getDimNames();
   } else {
     otherProfile.enter();
     names = container.getDimNames(attrProfiles);
   }
   return nullProfile.profile(names == null) ? RNull.instance : names;
 }
Пример #2
0
@RBuiltin(
    name = "dimnames",
    kind = PRIMITIVE,
    parameterNames = {"x"},
    dispatch = INTERNAL_GENERIC)
public abstract class DimNames extends RBuiltinNode {

  private final RAttributeProfiles attrProfiles = RAttributeProfiles.create();
  private final ConditionProfile nullProfile = ConditionProfile.createBinaryProfile();
  private final BranchProfile dataframeProfile = BranchProfile.create();
  private final BranchProfile factorProfile = BranchProfile.create();
  private final BranchProfile otherProfile = BranchProfile.create();

  @Specialization
  protected RNull getDimNames(@SuppressWarnings("unused") RNull operand) {
    controlVisibility();
    return RNull.instance;
  }

  @Specialization
  protected Object getDimNames(RAbstractContainer container) {
    controlVisibility();
    RList names;
    if (container instanceof RDataFrame) {
      dataframeProfile.enter();
      names = ((RDataFrame) container).getVector().getDimNames();
    } else if (container instanceof RFactor) {
      factorProfile.enter();
      names = ((RFactor) container).getVector().getDimNames();
    } else {
      otherProfile.enter();
      names = container.getDimNames(attrProfiles);
    }
    return nullProfile.profile(names == null) ? RNull.instance : names;
  }
}