Search in sources :

Example 1 with Variable

use of com.nextgenactionscript.vscode.debug.responses.Variable in project vscode-nextgenas by BowlerHatLLC.

the class SWFDebugSession method variables.

public void variables(Response response, VariablesRequest.VariablesArguments arguments) {
    List<Variable> variables = new ArrayList<>();
    try {
        Value swfValue = null;
        long variablesReference = arguments.variablesReference;
        int frameId = -1;
        if (variablesReference < 1000) {
            frameId = (int) variablesReference / 10;
            variablesReference -= frameId * 10;
        }
        flash.tools.debugger.Variable[] members = null;
        if (variablesReference == LOCAL_VARIABLES_REFERENCE) {
            Frame[] swfFrames = swfSession.getFrames();
            if (frameId >= 0 && frameId < swfFrames.length) {
                Frame swfFrame = swfFrames[frameId];
                flash.tools.debugger.Variable[] args = swfFrame.getArguments(swfSession);
                flash.tools.debugger.Variable[] locals = swfFrame.getLocals(swfSession);
                flash.tools.debugger.Variable swfThis = swfFrame.getThis(swfSession);
                int memberCount = locals.length + args.length;
                int offset = 0;
                if (swfThis != null) {
                    offset = 1;
                }
                members = new flash.tools.debugger.Variable[memberCount + offset];
                if (swfThis != null) {
                    members[0] = swfThis;
                }
                System.arraycopy(args, 0, members, offset, args.length);
                System.arraycopy(locals, 0, members, args.length + offset, locals.length);
            } else {
                members = new flash.tools.debugger.Variable[0];
            }
        } else {
            swfValue = swfSession.getValue(arguments.variablesReference);
            members = swfValue.getMembers(swfSession);
        }
        for (flash.tools.debugger.Variable member : members) {
            Value memberValue = member.getValue();
            Variable variable = new Variable();
            variable.name = member.getName();
            variable.type = memberValue.getTypeName();
            long id = memberValue.getId();
            if (id != Value.UNKNOWN_ID) {
                variable.value = memberValue.getTypeName();
                variable.variablesReference = memberValue.getId();
            } else {
                if (memberValue.getType() == VariableType.STRING) {
                    variable.value = "\"" + memberValue.getValueAsString() + "\"";
                } else {
                    variable.value = memberValue.getValueAsString();
                }
            }
            variables.add(variable);
        }
    } catch (PlayerDebugException e) {
    //ignore
    }
    sendResponse(response, new VariablesResponseBody(variables));
}
Also used : StackFrame(com.nextgenactionscript.vscode.debug.responses.StackFrame) Frame(flash.tools.debugger.Frame) Variable(com.nextgenactionscript.vscode.debug.responses.Variable) ArrayList(java.util.ArrayList) PlayerDebugException(flash.tools.debugger.PlayerDebugException) VariablesResponseBody(com.nextgenactionscript.vscode.debug.responses.VariablesResponseBody) SourceBreakpoint(com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint) Breakpoint(com.nextgenactionscript.vscode.debug.responses.Breakpoint) Value(flash.tools.debugger.Value)

Aggregations

SourceBreakpoint (com.nextgenactionscript.vscode.debug.requests.SourceBreakpoint)1 Breakpoint (com.nextgenactionscript.vscode.debug.responses.Breakpoint)1 StackFrame (com.nextgenactionscript.vscode.debug.responses.StackFrame)1 Variable (com.nextgenactionscript.vscode.debug.responses.Variable)1 VariablesResponseBody (com.nextgenactionscript.vscode.debug.responses.VariablesResponseBody)1 Frame (flash.tools.debugger.Frame)1 PlayerDebugException (flash.tools.debugger.PlayerDebugException)1 Value (flash.tools.debugger.Value)1 ArrayList (java.util.ArrayList)1