Ejemplo n.º 1
0
  private static void addBackTraceElement(
      Ruby runtime, RubyArray backtrace, Frame frame, Frame previousFrame) {
    if (frame != previousFrame
        && // happens with native exceptions, should not filter those out
        frame.getLine() == previousFrame.getLine()
        && frame.getName() != null
        && frame.getName().equals(previousFrame.getName())
        && frame.getFile().equals(previousFrame.getFile())) {
      return;
    }

    RubyString traceLine;
    if (previousFrame.getName() != null) {
      traceLine =
          RubyString.newString(
              runtime,
              frame.getFile()
                  + ':'
                  + (frame.getLine() + 1)
                  + ":in `"
                  + previousFrame.getName()
                  + '\'');
    } else if (runtime.is1_9()) {
      // TODO: This probably isn't the best hack, but it works until we can have different
      // root frame setup for 1.9 easily.
      traceLine =
          RubyString.newString(
              runtime, frame.getFile() + ':' + (frame.getLine() + 1) + ":in `<main>'");
    } else {
      traceLine = RubyString.newString(runtime, frame.getFile() + ':' + (frame.getLine() + 1));
    }

    backtrace.append(traceLine);
  }
Ejemplo n.º 2
0
 private String getMethodNameFromFrame(Frame current) {
   String methodName = current.getName();
   if (current.getName() == null) {
     methodName = UNKNOWN_NAME;
   }
   return methodName;
 }
Ejemplo n.º 3
0
  // XXX: Again, screwy evaling under previous frame's scope
  public void preExecuteUnder(RubyModule executeUnderClass, Block block) {
    Frame frame = getCurrentFrame();

    pushRubyClass(executeUnderClass);
    DynamicScope scope = getCurrentScope();
    StaticScope sScope = new BlockStaticScope(scope.getStaticScope());
    sScope.setModule(executeUnderClass);
    pushScope(DynamicScope.newDynamicScope(sScope, scope));
    pushCallFrame(frame.getKlazz(), frame.getName(), frame.getSelf(), block);
    getCurrentFrame().setVisibility(getPreviousFrame().getVisibility());
  }
Ejemplo n.º 4
0
 public void testUndoCreateSlot() {
   Slot slot = createSlot();
   String name = slot.getName();
   assertNotNull("name", name);
   Frame frame = getFrame(name);
   assertEquals("created", slot, frame);
   assertTrue("can undo", _frameStore.canUndo());
   _frameStore.undo();
   frame = getFrame(name);
   assertNull("undone", frame);
   _frameStore.redo();
   frame = getFrame(name);
   assertEquals("recreated", frame.getName(), name);
 }
Ejemplo n.º 5
0
 public void testUndocreateCls() {
   Cls cls = createCls();
   String name = cls.getName();
   assertNotNull("name", name);
   Frame frame = getFrame(name);
   assertEquals("created", cls, frame);
   assertTrue("can undo", _frameStore.canUndo());
   _frameStore.undo();
   frame = getFrame(name);
   assertNull("undone", frame);
   _frameStore.redo();
   frame = getFrame(name);
   assertEquals("recreated", frame.getName(), name);
 }