Ejemplo n.º 1
0
 private Object setDataPart(RAttributable object, Object value) {
   // TODO: any way to cache it or use a mechanism similar to overrides?
   REnvironment methodsNamespace = REnvironment.getRegisteredNamespace("methods");
   RFunction dataPart = setDataPartFunction(methodsNamespace);
   return RContext.getEngine()
       .evalFunction(dataPart, methodsNamespace.getFrame(), object, value, RRuntime.LOGICAL_TRUE);
 }
Ejemplo n.º 2
0
 @Override
 public void execute(VirtualFrame frame, Object value, MaterializedFrame enclosingFrame) {
   CompilerDirectives.transferToInterpreterAndInvalidate();
   if (name.isEmpty()) {
     throw RError.error(RError.NO_CALLER, RError.Message.ZERO_LENGTH_VARIABLE);
   }
   final WriteSuperFrameVariableNode writeNode;
   if (REnvironment.isGlobalEnvFrame(enclosingFrame)) {
     /*
      * we've reached the global scope, do unconditional write. if this is the first node
      * in the chain, needs the rhs and enclosingFrame nodes
      */
     AccessEnclosingFrameNode enclosingFrameNode =
         RArguments.getEnclosingFrame(frame) == enclosingFrame
             ? new AccessEnclosingFrameNode()
             : null;
     writeNode =
         ResolvedWriteSuperFrameVariableNodeGen.create(
             mode,
             rhs,
             enclosingFrameNode,
             FrameSlotNode.create(
                 findOrAddFrameSlot(
                     enclosingFrame.getFrameDescriptor(), name, FrameSlotKind.Illegal)),
             name);
   } else {
     ResolvedWriteSuperFrameVariableNode actualWriteNode =
         ResolvedWriteSuperFrameVariableNodeGen.create(
             mode, null, null, FrameSlotNode.create(name), name);
     writeNode =
         new WriteSuperFrameVariableConditionalNode(
             actualWriteNode, new UnresolvedWriteSuperFrameVariableNode(name, null, mode), rhs);
   }
   replace(writeNode).execute(frame, value, enclosingFrame);
 }
Ejemplo n.º 3
0
 @Specialization
 protected REnvironment doList2Env(RList list, REnvironment env) {
   RStringVector names = list.getNames();
   if (names == null) {
     throw RError.error(this, RError.Message.LIST_NAMES_SAME_LENGTH);
   }
   for (int i = list.getLength() - 1; i >= 0; i--) {
     String name = names.getDataAt(i);
     if (name.length() == 0) {
       throw RError.error(this, RError.Message.ZERO_LENGTH_VARIABLE);
     }
     // in case of duplicates, last element in list wins
     if (env.get(name) == null) {
       env.safePut(name, list.getDataAt(i));
     }
   }
   return env;
 }
Ejemplo n.º 4
0
 @Override
 public void execute(VirtualFrame frame, Object value, MaterializedFrame enclosingFrame) {
   MaterializedFrame profiledEnclosingFrame = enclosingFrameProfile.profile(enclosingFrame);
   if (hasValueProfile.profile(writeNode.getFrameSlotNode().hasValue(profiledEnclosingFrame))) {
     writeNode.execute(frame, value, profiledEnclosingFrame);
   } else {
     MaterializedFrame superFrame = RArguments.getEnclosingFrame(profiledEnclosingFrame);
     if (nullSuperFrameProfile.profile(superFrame == null)) {
       // Might be the case if "{ x <<- 42 }": This is in globalEnv!
       superFrame = REnvironment.globalEnv().getFrame();
     }
     nextNode.execute(frame, value, superFrame);
   }
 }
Ejemplo n.º 5
0
 protected RFunction setDataPartFunction(REnvironment methodsNamespace) {
   Object f = methodsNamespace.findFunction("setDataPart");
   return (RFunction) RContext.getRRuntimeASTAccess().forcePromise(f);
 }