Annotation of sbbs/javascript/include/mozilla/js/jsscript.h, revision 1.1

1.1     ! root        1: /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
        !             2:  *
        !             3:  * The contents of this file are subject to the Netscape Public
        !             4:  * License Version 1.1 (the "License"); you may not use this file
        !             5:  * except in compliance with the License. You may obtain a copy of
        !             6:  * the License at http://www.mozilla.org/NPL/
        !             7:  *
        !             8:  * Software distributed under the License is distributed on an "AS
        !             9:  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
        !            10:  * implied. See the License for the specific language governing
        !            11:  * rights and limitations under the License.
        !            12:  *
        !            13:  * The Original Code is Mozilla Communicator client code, released
        !            14:  * March 31, 1998.
        !            15:  *
        !            16:  * The Initial Developer of the Original Code is Netscape
        !            17:  * Communications Corporation.  Portions created by Netscape are
        !            18:  * Copyright (C) 1998 Netscape Communications Corporation. All
        !            19:  * Rights Reserved.
        !            20:  *
        !            21:  * Contributor(s): 
        !            22:  *
        !            23:  * Alternatively, the contents of this file may be used under the
        !            24:  * terms of the GNU Public License (the "GPL"), in which case the
        !            25:  * provisions of the GPL are applicable instead of those above.
        !            26:  * If you wish to allow use of your version of this file only
        !            27:  * under the terms of the GPL and not to allow others to use your
        !            28:  * version of this file under the NPL, indicate your decision by
        !            29:  * deleting the provisions above and replace them with the notice
        !            30:  * and other provisions required by the GPL.  If you do not delete
        !            31:  * the provisions above, a recipient may use your version of this
        !            32:  * file under either the NPL or the GPL.
        !            33:  */
        !            34: 
        !            35: #ifndef jsscript_h___
        !            36: #define jsscript_h___
        !            37: /*
        !            38:  * JS script descriptor.
        !            39:  */
        !            40: #include "jsatom.h"
        !            41: #include "jsprvtd.h"
        !            42: 
        !            43: JS_BEGIN_EXTERN_C
        !            44: 
        !            45: /*
        !            46:  * Exception handling runtime information.
        !            47:  *
        !            48:  * All fields except length are code offsets, relative to the beginning of
        !            49:  * the script.  If script->trynotes is not null, it points to a vector of
        !            50:  * these structs terminated by one with catchStart == 0.
        !            51:  */
        !            52: struct JSTryNote {
        !            53:     ptrdiff_t    start;         /* start of try statement */
        !            54:     ptrdiff_t    length;        /* count of try statement bytecodes */
        !            55:     ptrdiff_t    catchStart;    /* start of catch block (0 if end) */
        !            56: };
        !            57: 
        !            58: #define JSTRYNOTE_GRAIN         sizeof(ptrdiff_t)
        !            59: #define JSTRYNOTE_ALIGNMASK     (JSTRYNOTE_GRAIN - 1)
        !            60: 
        !            61: struct JSScript {
        !            62:     jsbytecode   *code;         /* bytecodes and their immediate operands */
        !            63:     uint32       length;        /* length of code vector */
        !            64:     jsbytecode   *main;         /* main entry point, after predef'ing prolog */
        !            65:     JSVersion    version;       /* JS version under which script was compiled */
        !            66:     JSAtomMap    atomMap;       /* maps immediate index to literal struct */
        !            67:     const char   *filename;     /* source filename or null */
        !            68:     uintN        lineno;        /* base line number of script */
        !            69:     uintN        depth;         /* maximum stack depth in slots */
        !            70:     JSTryNote    *trynotes;     /* exception table for this script */
        !            71:     JSPrincipals *principals;   /* principals for this script */
        !            72:     JSObject     *object;       /* optional Script-class object wrapper */
        !            73: };
        !            74: 
        !            75: /* No need to store script->notes now that it is allocated right after code. */
        !            76: #define SCRIPT_NOTES(script)    ((jssrcnote*)((script)->code+(script)->length))
        !            77: 
        !            78: #define SCRIPT_FIND_CATCH_START(script, pc, catchpc)                          \
        !            79:     JS_BEGIN_MACRO                                                            \
        !            80:         JSTryNote *tn_ = (script)->trynotes;                                  \
        !            81:         jsbytecode *catchpc_ = NULL;                                          \
        !            82:         if (tn_) {                                                            \
        !            83:             ptrdiff_t offset_ = PTRDIFF(pc, (script)->main, jsbytecode);      \
        !            84:             while (JS_UPTRDIFF(offset_, tn_->start) >= (jsuword)tn_->length)  \
        !            85:                 ++tn_;                                                        \
        !            86:             if (tn_->catchStart)                                              \
        !            87:                 catchpc_ = (script)->main + tn_->catchStart;                  \
        !            88:         }                                                                     \
        !            89:         catchpc = catchpc_;                                                   \
        !            90:     JS_END_MACRO
        !            91: 
        !            92: extern JS_FRIEND_DATA(JSClass) js_ScriptClass;
        !            93: 
        !            94: extern JSObject *
        !            95: js_InitScriptClass(JSContext *cx, JSObject *obj);
        !            96: 
        !            97: extern JSBool
        !            98: js_InitScriptGlobals();
        !            99: 
        !           100: extern void
        !           101: js_FreeScriptGlobals();
        !           102: 
        !           103: extern const char *
        !           104: js_SaveScriptFilename(JSContext *cx, const char *filename);
        !           105: 
        !           106: extern void
        !           107: js_MarkScriptFilename(const char *filename);
        !           108: 
        !           109: extern void
        !           110: js_SweepScriptFilenames(JSRuntime *rt);
        !           111: 
        !           112: /*
        !           113:  * Two successively less primitive ways to make a new JSScript.  The first
        !           114:  * does *not* call a non-null cx->runtime->newScriptHook -- only the second,
        !           115:  * js_NewScriptFromCG, calls this optional debugger hook.
        !           116:  *
        !           117:  * The js_NewScript function can't know whether the script it creates belongs
        !           118:  * to a function, or is top-level or eval code, but the debugger wants access
        !           119:  * to the newly made script's function, if any -- so callers of js_NewScript
        !           120:  * are responsible for notifying the debugger after successfully creating any
        !           121:  * kind (function or other) of new JSScript.
        !           122:  */
        !           123: extern JSScript *
        !           124: js_NewScript(JSContext *cx, uint32 length, uint32 snlength, uint32 tnlength);
        !           125: 
        !           126: extern JS_FRIEND_API(JSScript *)
        !           127: js_NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg, JSFunction *fun);
        !           128: 
        !           129: /*
        !           130:  * New-script-hook calling is factored from js_NewScriptFromCG so that it
        !           131:  * and callers of js_XDRScript can share this code.  In the case of callers
        !           132:  * of js_XDRScript, the hook should be invoked only after successful decode
        !           133:  * of any owning function (the fun parameter) or script object (null fun).
        !           134:  */
        !           135: extern JS_FRIEND_API(void)
        !           136: js_CallNewScriptHook(JSContext *cx, JSScript *script, JSFunction *fun);
        !           137: 
        !           138: extern void
        !           139: js_DestroyScript(JSContext *cx, JSScript *script);
        !           140: 
        !           141: extern void
        !           142: js_MarkScript(JSContext *cx, JSScript *script, void *arg);
        !           143: 
        !           144: extern jssrcnote *
        !           145: js_GetSrcNote(JSScript *script, jsbytecode *pc);
        !           146: 
        !           147: /* XXX need cx to lock function objects declared by prolog bytecodes. */
        !           148: extern uintN
        !           149: js_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc);
        !           150: 
        !           151: extern jsbytecode *
        !           152: js_LineNumberToPC(JSScript *script, uintN lineno);
        !           153: 
        !           154: extern uintN
        !           155: js_GetScriptLineExtent(JSScript *script);
        !           156: 
        !           157: /*
        !           158:  * If magic is non-null, js_XDRScript succeeds on magic number mismatch but
        !           159:  * returns false in *magic; it reflects a match via a true *magic out param.
        !           160:  * If magic is null, js_XDRScript returns false on bad magic number errors,
        !           161:  * which it reports.
        !           162:  *
        !           163:  * NB: callers must call js_CallNewScriptHook after successful JSXDR_DECODE
        !           164:  * and subsequent set-up of owning function or script object, if any.
        !           165:  */
        !           166: extern JSBool
        !           167: js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *magic);
        !           168: 
        !           169: JS_END_EXTERN_C
        !           170: 
        !           171: #endif /* jsscript_h___ */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.