Ejemplo n.º 1
0
 @Specialization(guards = {"each > 1", "hasNames(x)"})
 protected RAbstractVector repEachNames(
     RAbstractVector x,
     RAbstractIntVector times,
     int lengthOut,
     int each,
     @Cached("create()") InitAttributesNode initAttributes,
     @Cached("createNames()") SetFixedAttributeNode putNames) {
   if (times.getLength() > 1) {
     errorBranch.enter();
     throw invalidTimes();
   }
   RAbstractVector input = handleEach(x, each);
   RStringVector names = (RStringVector) handleEach(getNames.getNames(x), each);
   RVector<?> r;
   if (lengthOutOrTimes.profile(!RRuntime.isNA(lengthOut))) {
     names = (RStringVector) handleLengthOut(names, lengthOut, false);
     r = handleLengthOut(input, lengthOut, false);
   } else {
     names = (RStringVector) handleTimes(names, times, false);
     r = handleTimes(input, times, false);
   }
   putNames.execute(initAttributes.execute(r), names);
   return r;
 }
Ejemplo n.º 2
0
 @Specialization(guards = {"each <= 1", "hasNames(x)"})
 protected RAbstractVector repNoEachNames(
     RAbstractVector x,
     RAbstractIntVector times,
     int lengthOut,
     @SuppressWarnings("unused") int each,
     @Cached("create()") InitAttributesNode initAttributes,
     @Cached("createNames()") SetFixedAttributeNode putNames) {
   RStringVector names;
   RVector<?> r;
   if (lengthOutOrTimes.profile(!RRuntime.isNA(lengthOut))) {
     names = (RStringVector) handleLengthOut(getNames.getNames(x), lengthOut, true);
     r = handleLengthOut(x, lengthOut, true);
   } else {
     names = (RStringVector) handleTimes(getNames.getNames(x), times, true);
     r = handleTimes(x, times, true);
   }
   putNames.execute(initAttributes.execute(r), names);
   return r;
 }