Пример #1
0
 @TruffleBoundary
 protected static Object encodeArgumentPairList(RArgsValuesAndNames args, String symbolName) {
   Object list = RNull.instance;
   for (int i = args.getLength() - 1; i >= 0; i--) {
     String name = args.getSignature().getName(i);
     list =
         RDataFactory.createPairList(
             args.getArgument(i),
             list,
             name == null ? RNull.instance : RDataFactory.createSymbolInterned(name));
   }
   list = RDataFactory.createPairList(symbolName, list);
   return list;
 }
Пример #2
0
 @Specialization
 protected Object castFunction(RFunction f) {
   if (isNonVectorPreserved()) {
     return f;
   } else {
     return RDataFactory.createList();
   }
 }
Пример #3
0
 @Specialization
 protected Object castNull(@SuppressWarnings("unused") RNull rnull) {
   if (isNonVectorPreserved()) {
     return RNull.instance;
   } else {
     return RDataFactory.createList();
   }
 }
Пример #4
0
  @Specialization(
      guards = {
        "!copyAllAttributes || target != source",
        "containsMetadata(source, attrSourceProfiles)"
      })
  public RAbstractVector copySameLength(
      RAbstractVector target,
      RAbstractVector source, //
      @Cached("create()") CopyOfRegAttributesNode copyOfReg, //
      @Cached("createDim()") RemoveAttributeNode removeDim, //
      @Cached("createDimNames()") RemoveAttributeNode removeDimNames, //
      @Cached("create()") InitAttributesNode initAttributes, //
      @Cached("createNames()") PutAttributeNode putNames, //
      @Cached("createDim()") PutAttributeNode putDim, //
      @Cached("createBinaryProfile()") ConditionProfile noDimensions, //
      @Cached("createBinaryProfile()") ConditionProfile hasNamesSource, //
      @Cached("createBinaryProfile()") ConditionProfile hasDimNames) {
    RVector result = target.materialize();

    if (copyAllAttributes) {
      copyOfReg.execute(source, result);
    }

    int[] newDimensions = source.getDimensions();
    if (noDimensions.profile(newDimensions == null)) {
      RAttributes attributes = result.getAttributes();
      if (attributes != null) {
        removeDim.execute(attributes);
        removeDimNames.execute(attributes);
        result.setInternalDimNames(null);
      }
      result.setInternalDimensions(null);

      RStringVector vecNames = source.getNames(attrSourceProfiles);
      if (hasNamesSource.profile(vecNames != null)) {
        putNames.execute(initAttributes.execute(result), vecNames);
        result.setInternalNames(vecNames);
        return result;
      }
      return result;
    }

    putDim.execute(
        initAttributes.execute(result),
        RDataFactory.createIntVector(newDimensions, RDataFactory.COMPLETE_VECTOR));
    result.setInternalDimensions(newDimensions);

    RList newDimNames = source.getDimNames(attrSourceProfiles);
    if (hasDimNames.profile(newDimNames != null)) {
      result.getAttributes().put(RRuntime.DIMNAMES_ATTR_KEY, newDimNames);
      newDimNames.elementNamePrefix = RRuntime.DIMNAMES_LIST_ELEMENT_NAME_PREFIX;
      result.setInternalDimNames(newDimNames);
      return result;
    }
    return result;
  }
Пример #5
0
 @Override
 public Object getRelementImpl(int index) {
   if (index == 0) {
     String name = getBuiltin().getName();
     assert name == name.intern();
     return RDataFactory.createSymbol(name);
   } else {
     throw RInternalError.unimplemented();
   }
 }