/** Implements getFrame() in interface org.mozilla.javascript.debug.Debugger */ public DebugFrame getFrame(Context cx, DebuggableScript script) { if (script.isFunction()) { String name = getFunctionName(script); ProfilerFrame frame = (ProfilerFrame) frames.get(name); if (frame == null) { frame = new ProfilerFrame(name); frames.put(name, frame); } return frame; } return null; }
/** * Get a string representation for the given script * * @param script a function or script * @return the file and/or function name of the script */ static String getFunctionName(DebuggableScript script) { if (script.isFunction()) { StringBuffer b = new StringBuffer(script.getSourceName()).append(" #"); b.append(script.getLineNumbers()[0]); String funcName = script.getFunctionName(); if (funcName != null && funcName.length() > 0) { b.append(": ").append(script.getFunctionName()); } return b.toString(); } else { return script.getSourceName(); } }