Exemplo n.º 1
0
  /**
   * Only local reads are effectively analyzed.<br>
   * Since any local write is a statement by it self, and the recursive call to
   * escapesCurrentFrame() always return false.
   */
  private boolean escapesCurrentFrame(FrameSlot slot) {
    if (slot.getIdentifier().equals("<return_val>")) {
      return true;
    }

    for (FrameSlotNode slotNode : NodeUtil.findAllNodeInstances(root, FrameSlotNode.class)) {
      if (!slotNode.getSlot().equals(slot)) {
        continue;
      }

      boolean escapse = escapesCurrentFrame(slotNode);
      if (escapse) {
        return true;
      }
    }

    return false;
  }
Exemplo n.º 2
0
 @Override
 public void execute(VirtualFrame frame, Object value, MaterializedFrame enclosingFrame) {
   CompilerDirectives.transferToInterpreterAndInvalidate();
   if (getName().isEmpty()) {
     throw RError.error(this, RError.Message.ZERO_LENGTH_VARIABLE);
   }
   final WriteSuperFrameVariableNodeHelper 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 =
         WriteSuperFrameVariableNodeGen.create(
             getRhs(),
             enclosingFrameNode,
             FrameSlotNode.create(
                 findOrAddFrameSlot(
                     enclosingFrame.getFrameDescriptor(), symbol, FrameSlotKind.Illegal)),
             getName(),
             mode);
   } else {
     WriteSuperFrameVariableNode actualWriteNode =
         WriteSuperFrameVariableNodeGen.create(
             null, null, FrameSlotNode.create(symbol), this.getName(), mode);
     writeNode =
         new WriteSuperFrameVariableConditionalNode(
             actualWriteNode,
             new UnresolvedWriteSuperFrameVariableNode(symbol, null, mode),
             getRhs());
   }
   replace(writeNode).execute(frame, value, enclosingFrame);
 }