001: /* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
002: *
003: * ***** BEGIN LICENSE BLOCK *****
004: * Version: MPL 1.1/GPL 2.0
005: *
006: * The contents of this file are subject to the Mozilla Public License Version
007: * 1.1 (the "License"); you may not use this file except in compliance with
008: * the License. You may obtain a copy of the License at
009: * http://www.mozilla.org/MPL/
010: *
011: * Software distributed under the License is distributed on an "AS IS" basis,
012: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
013: * for the specific language governing rights and limitations under the
014: * License.
015: *
016: * The Original Code is Rhino code, released
017: * May 6, 1999.
018: *
019: * The Initial Developer of the Original Code is
020: * Netscape Communications Corporation.
021: * Portions created by the Initial Developer are Copyright (C) 1997-2000
022: * the Initial Developer. All Rights Reserved.
023: *
024: * Contributor(s):
025: * Norris Boyd
026: * Igor Bukanov
027: *
028: * Alternatively, the contents of this file may be used under the terms of
029: * the GNU General Public License Version 2 or later (the "GPL"), in which
030: * case the provisions of the GPL are applicable instead of those above. If
031: * you wish to allow use of your version of this file only under the terms of
032: * the GPL and not to allow others to use your version of this file under the
033: * MPL, indicate your decision by deleting the provisions above and replacing
034: * them with the notice and other provisions required by the GPL. If you do
035: * not delete the provisions above, a recipient may use your version of this
036: * file under either the MPL or the GPL.
037: *
038: * ***** END LICENSE BLOCK ***** */
039:
040: // API class
041: package org.mozilla.javascript.debug;
042:
043: /**
044: * This interface exposes debugging information from executable
045: * code (either functions or top-level scripts).
046: */
047: public interface DebuggableScript {
048: public boolean isTopLevel();
049:
050: /**
051: * Returns true if this is a function, false if it is a script.
052: */
053: public boolean isFunction();
054:
055: /**
056: * Get name of the function described by this script.
057: * Return null or an empty string if this script is not a function.
058: */
059: public String getFunctionName();
060:
061: /**
062: * Get number of declared parameters in the function.
063: * Return 0 if this script is not a function.
064: *
065: * @see #getParamAndVarCount()
066: * @see #getParamOrVarName(int index)
067: */
068: public int getParamCount();
069:
070: /**
071: * Get number of declared parameters and local variables.
072: * Return number of declared global variables if this script is not a
073: * function.
074: *
075: * @see #getParamCount()
076: * @see #getParamOrVarName(int index)
077: */
078: public int getParamAndVarCount();
079:
080: /**
081: * Get name of a declared parameter or local variable.
082: * <tt>index</tt> should be less then {@link #getParamAndVarCount()}.
083: * If <tt>index < {@link #getParamCount()}</tt>, return
084: * the name of the corresponding parameter, otherwise return the name
085: * of variable.
086: * If this script is not function, return the name of the declared
087: * global variable.
088: */
089: public String getParamOrVarName(int index);
090:
091: /**
092: * Get the name of the source (usually filename or URL)
093: * of the script.
094: */
095: public String getSourceName();
096:
097: /**
098: * Returns true if this script or function were runtime-generated
099: * from JavaScript using <tt>eval</tt> function or <tt>Function</tt>
100: * or <tt>Script</tt> constructors.
101: */
102: public boolean isGeneratedScript();
103:
104: /**
105: * Get array containing the line numbers that
106: * that can be passed to <code>DebugFrame.onLineChange()<code>.
107: * Note that line order in the resulting array is arbitrary
108: */
109: public int[] getLineNumbers();
110:
111: public int getFunctionCount();
112:
113: public DebuggableScript getFunction(int index);
114:
115: public DebuggableScript getParent();
116:
117: }
|