Package net.cakenet.jsaton.script.debug

Examples of net.cakenet.jsaton.script.debug.BreakInformation


        super.removeUpdate(documentEvent);
    }

    public String getToolTipText(MouseEvent e) {
        if (script.isDebug()) {
            BreakInformation info = script.getBreakInfo();
            if (info != null) {
                // We're broken, if this is a variable, we can show information about it :D
                // Todo: other context stuff...
                try {
                    int offs = viewToModel(e.getPoint());
View Full Code Here


                    return delegate.interpret(runtime, context, self, aBlock);
                }

                breakContext = context;
                breakSource = delegate;
                BreakInformation info = new BreakInformation();
                info.addVariableConverter(IRubyObject.class, new RubyExtractor());
                step = stepOver = false;

                // Todo: oh god, copying frames is going to be nasty as fuck...
                // popFrame clears the frame before returning, getFrames clones them for backtrace
                // i.e. only name and backtrace data is copied...
                Stack<Frame> frames = new Stack<>();
                Stack<IRubyObject> selfs = new Stack<>();
                for (Frame cur = context.getCurrentFrame(); cur != null; ) {
                    Frame clone = new Frame();
                    clone.updateFrame(cur); // clone...
                    frames.push(clone);
                    selfs.push(context.getFrameSelf());
                    context.popFrame();
                    try {
                        cur = context.getCurrentFrame();
                    } catch (ArrayIndexOutOfBoundsException e) {
                        break;
                    }
                }
                Stack<DynamicScope> scopes = new Stack<>();
                for (DynamicScope scope = context.getCurrentScope(); scopes.size() != frames.size(); ) {
                    scopes.push(scope);
                    context.popScope();
                    try {
                        scope = context.getCurrentScope();
                    } catch (ArrayIndexOutOfBoundsException aioe) {
                        break;
                    }
                }

                RubyStackTraceElement[] trace = TraceType.Gather.NORMAL.getBacktraceData(context, false).getBacktrace(runtime);
                /*int traceEnd = trace.length;
                for (int i = 0; i < traceEnd; i++) {
                    RubyStackTraceElement rste = trace[i];
                    if (!rste.getFileName().equals(getName())) {
                        trace[i] = null;
                        if (i + 1 < traceEnd)
                            System.arraycopy(trace, i + 1, trace, i, (traceEnd - i) - 1);
                        traceEnd--;
                        trace[traceEnd] = null;
                    }
                }*/
                assert frames.size() == scopes.size() : "Frames don't match scopes :S";
                for (int i = 0; i < frames.size(); i++) {
                    Frame frame = frames.get(i);
                    IRubyObject s = selfs.get(i);
                    DynamicScope scope = scopes.get(i);
                    RubyStackTraceElement stackElement = trace[i];
                    StaticScope sScope = scope.getStaticScope();
                    Map<String, Object> var = new HashMap<>();
                    String[] names = sScope.getVariables();
                    IRubyObject[] values = scope.getValues();
                    assert names.length == values.length : "Scope name and value length mismatch";
                    for (int j = 0; j < names.length; j++)
                        var.put(names[j], values[j]);
                    DebugFrame created = info.pushFrame(stackElement.getClassName() + "." + stackElement.getMethodName(),
                            stackElement.getFileName(), stackElement.getLineNumber(), s, var);
                    created.self.setName("self");
                }

                // Restore scopes and frames
View Full Code Here

TOP

Related Classes of net.cakenet.jsaton.script.debug.BreakInformation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.