Cleanups from tlundeen@webcrossing.com, plus fun->call=>native renaming.

git-svn-id: svn://10.0.0.236/trunk@69736 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
brendan%mozilla.org
2000-05-15 03:54:50 +00:00
parent bcfe1cd20b
commit d2bc829802
9 changed files with 45 additions and 38 deletions

View File

@@ -408,7 +408,7 @@ MakeDay(jsdouble year, jsdouble month, jsdouble date)
year += floor(month / 12);
month = fmod(month, 12);
month = fmod(month, 12.0);
if (month < 0)
month += 12;

View File

@@ -608,7 +608,7 @@ JS_GetFramePrincipalArray(JSContext *cx, JSStackFrame *fp)
JS_PUBLIC_API(JSBool)
JS_IsNativeFrame(JSContext *cx, JSStackFrame *fp)
{
return fp->fun && fp->fun->call;
return fp->fun && fp->fun->native;
}
/* this is deprecated, use JS_GetFrameScopeChain instead */

View File

@@ -111,7 +111,7 @@
#define STDOUTPUT_NAME "Standard output stream"
#define STDERROR_NAME "Standard error stream"
#define RESOLVE_PATH js_canonicalPath //js_absolutePath
#define RESOLVE_PATH js_canonicalPath /* js_absolutePath */
/* Error handling */
typedef enum JSFileErrNum {

View File

@@ -1025,7 +1025,8 @@ fun_hasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp)
if (JSVAL_IS_FUNCTION(cx, cval)) {
cfun = (JSFunction *) JS_GetPrivate(cx, JSVAL_TO_OBJECT(cval));
ofun = (JSFunction *) JS_GetPrivate(cx, obj);
if (cfun->call == ofun->call && cfun->script == ofun->script) {
if (cfun->native == ofun->native &&
cfun->script == ofun->script) {
*bp = JS_TRUE;
break;
}
@@ -1596,7 +1597,7 @@ js_InitArgsAndCallClasses(JSContext *cx, JSObject *obj)
}
JSFunction *
js_NewFunction(JSContext *cx, JSObject *funobj, JSNative call, uintN nargs,
js_NewFunction(JSContext *cx, JSObject *funobj, JSNative native, uintN nargs,
uintN flags, JSObject *parent, JSAtom *atom)
{
JSFunction *fun;
@@ -1620,14 +1621,14 @@ js_NewFunction(JSContext *cx, JSObject *funobj, JSNative call, uintN nargs,
/* Initialize all function members. */
fun->nrefs = 0;
fun->object = NULL;
fun->call = call;
fun->native = native;
fun->script = NULL;
fun->nargs = nargs;
fun->extra = 0;
fun->nvars = 0;
fun->flags = flags & JSFUN_FLAGS_MASK;
fun->spare = 0;
fun->atom = atom;
fun->script = NULL;
fun->clasp = NULL;
/* Link fun to funobj and vice versa. */
@@ -1669,12 +1670,12 @@ js_LinkFunctionObject(JSContext *cx, JSFunction *fun, JSObject *funobj)
}
JSFunction *
js_DefineFunction(JSContext *cx, JSObject *obj, JSAtom *atom, JSNative call,
js_DefineFunction(JSContext *cx, JSObject *obj, JSAtom *atom, JSNative native,
uintN nargs, uintN attrs)
{
JSFunction *fun;
fun = js_NewFunction(cx, NULL, call, nargs, attrs, obj, atom);
fun = js_NewFunction(cx, NULL, native, nargs, attrs, obj, atom);
if (!fun)
return NULL;
if (!OBJ_DEFINE_PROPERTY(cx, obj, (jsid)atom, OBJECT_TO_JSVAL(fun->object),

View File

@@ -18,7 +18,7 @@
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the
* terms of the GNU Public License (the "GPL"), in which case the
@@ -45,16 +45,15 @@ JS_BEGIN_EXTERN_C
struct JSFunction {
jsrefcount nrefs; /* number of referencing objects */
JSObject *object; /* back-pointer to GC'ed object header */
JSNative call; /* native method pointer or null */
JSNative native; /* native method pointer or null */
JSScript *script; /* interpreted bytecode descriptor or null */
uint16 nargs; /* minimum number of actual arguments */
uint16 extra; /* number of arg slots for local GC roots */
uint16 nvars; /* number of local variables */
uint8 flags; /* bound method and other flags, see jsapi.h */
uint8 spare; /* reserved for future use */
JSAtom *atom; /* name for diagnostics and decompiling */
JSScript *script; /* interpreted bytecode descriptor or null */
JSClass *clasp; /* this function is a constructor for objects
* of this class */
JSClass *clasp; /* if non-null, constructor for this class */
};
extern JSClass js_ArgumentsClass;
@@ -80,7 +79,7 @@ extern JSBool
js_InitArgsAndCallClasses(JSContext *cx, JSObject *obj);
extern JSFunction *
js_NewFunction(JSContext *cx, JSObject *funobj, JSNative call, uintN nargs,
js_NewFunction(JSContext *cx, JSObject *funobj, JSNative native, uintN nargs,
uintN flags, JSObject *parent, JSAtom *atom);
extern JSObject *
@@ -90,7 +89,7 @@ extern JSBool
js_LinkFunctionObject(JSContext *cx, JSFunction *fun, JSObject *object);
extern JSFunction *
js_DefineFunction(JSContext *cx, JSObject *obj, JSAtom *atom, JSNative call,
js_DefineFunction(JSContext *cx, JSObject *obj, JSAtom *atom, JSNative native,
uintN nargs, uintN flags);
extern JSFunction *

View File

@@ -331,7 +331,7 @@ js_GetArgument(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
fun = (JSFunction *) JS_GetPrivate(cx, obj);
for (fp = cx->fp; fp; fp = fp->down) {
/* Find most recent non-native function frame. */
if (fp->fun && !fp->fun->call) {
if (fp->fun && !fp->fun->native) {
if (fp->fun == fun) {
JS_ASSERT((uintN)JSVAL_TO_INT(id) < fp->fun->nargs);
*vp = fp->argv[JSVAL_TO_INT(id)];
@@ -352,7 +352,7 @@ js_SetArgument(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
fun = (JSFunction *) JS_GetPrivate(cx, obj);
for (fp = cx->fp; fp; fp = fp->down) {
/* Find most recent non-native function frame. */
if (fp->fun && !fp->fun->call) {
if (fp->fun && !fp->fun->native) {
if (fp->fun == fun) {
JS_ASSERT((uintN)JSVAL_TO_INT(id) < fp->fun->nargs);
fp->argv[JSVAL_TO_INT(id)] = *vp;
@@ -374,7 +374,7 @@ js_GetLocalVariable(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
fun = (JSFunction *) JS_GetPrivate(cx, obj);
for (fp = cx->fp; fp; fp = fp->down) {
/* Find most recent non-native function frame. */
if (fp->fun && !fp->fun->call) {
if (fp->fun && !fp->fun->native) {
if (fp->fun == fun) {
slot = JSVAL_TO_INT(id);
JS_ASSERT((uintN)slot < fp->fun->nvars);
@@ -398,7 +398,7 @@ js_SetLocalVariable(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
fun = (JSFunction *) JS_GetPrivate(cx, obj);
for (fp = cx->fp; fp; fp = fp->down) {
/* Find most recent non-native function frame. */
if (fp->fun && !fp->fun->call) {
if (fp->fun && !fp->fun->native) {
if (fp->fun == fun) {
slot = JSVAL_TO_INT(id);
JS_ASSERT((uintN)slot < fp->fun->nvars);
@@ -559,7 +559,7 @@ js_Invoke(JSContext *cx, uintN argc, uintN flags)
/* Get private data and set derived locals from it. */
fun = (JSFunction *) JS_GetPrivate(cx, funobj);
have_fun:
native = fun->call;
native = fun->native;
script = fun->script;
minargs = fun->nargs + fun->extra;
nvars = fun->nvars;
@@ -2390,7 +2390,7 @@ js_Interpret(JSContext *cx, jsval *result)
if (JSVAL_IS_FUNCTION(cx, lval) &&
(obj = JSVAL_TO_OBJECT(lval),
fun = (JSFunction *) JS_GetPrivate(cx, obj),
fun->script &&
!fun->native &&
fun->flags == 0 &&
argc >= (uintN)(fun->nargs + fun->extra)))
/* inline_call: */

View File

@@ -704,7 +704,7 @@ js_ValueToUint16(JSContext *cx, jsval v, uint16 *ip)
d = floor(neg ? -d : d);
d = neg ? -d : d;
m = JS_BIT(16);
d = fmod(d, m);
d = fmod(d, (double)m);
if (d < 0)
d += m;
*ip = (uint16) d;

View File

@@ -238,9 +238,11 @@ MarkSharpObjects(JSContext *cx, JSObject *obj, JSIdArray **idap)
JSBool ok;
jsint i, length;
jsid id;
#if JS_HAS_GETTER_SETTER
JSObject *obj2;
JSProperty *prop;
uintN attrs;
#endif
jsval val;
map = &cx->sharpObjectMap;
@@ -444,13 +446,13 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
char *comma;
jsint i, j, length, valcnt;
jsid id;
#if JS_HAS_GETTER_SETTER
JSObject *obj2;
JSProperty *prop;
uintN attrs;
jsval val[2];
#if JS_HAS_GETTER_SETTER
JSString *gsop[2];
#endif
jsval val[2];
JSString *gsop[2];
JSString *idstr, *valstr, *str;
/*
@@ -503,7 +505,9 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
for (i = 0, length = ida->length; i < length; i++) {
/* Get strings for id and value and GC-root them via argv. */
id = ida->vector[i];
#if JS_HAS_GETTER_SETTER
ok = OBJ_LOOKUP_PROPERTY(cx, obj, id, &obj2, &prop);
if (!ok)
goto error;
@@ -545,10 +549,15 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
}
if (prop)
OBJ_DROP_PROPERTY(cx, obj2, prop);
#else
#else /* !JS_HAS_GETTER_SETTER */
valcnt = 1;
gsop[0] = NULL;
ok = OBJ_GET_PROPERTY(cx, obj, id, &val[0]);
#endif
#endif /* !JS_HAS_GETTER_SETTER */
if (!ok)
goto error;
@@ -583,7 +592,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
vlength = valstr->length;
#ifndef OLD_GETTER_SETTER
/* Remove 'function ' from beginning of valstr*/
/* Remove 'function ' from beginning of valstr. */
if (gsop[j]) {
int n = strlen(js_function_str) + 1;
vchars += n;
@@ -620,9 +629,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
realloc((ochars = chars),
(nchars + (comma ? 2 : 0) +
idstr->length + 1 +
#if JS_HAS_GETTER_SETTER
(gsop[j] ? 1 + gsop[j]->length : 0) +
#endif
vsharplength + vlength +
(outermost ? 2 : 1) + 1) * sizeof(jschar));
if (!chars) {
@@ -641,13 +648,11 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
#ifdef OLD_GETTER_SETTER
js_strncpy(&chars[nchars], idstr->chars, idstr->length);
nchars += idstr->length;
#if JS_HAS_GETTER_SETTER
if (gsop[j]) {
chars[nchars++] = ' ';
js_strncpy(&chars[nchars], gsop[j]->chars, gsop[j]->length);
nchars += gsop[j]->length;
}
#endif
chars[nchars++] = ':';
#else
if (gsop[j]) {
@@ -2607,15 +2612,15 @@ js_Call(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
clasp = OBJ_GET_CLASS(cx, JSVAL_TO_OBJECT(argv[-2]));
if (!clasp->call) {
/*
* The decompiler may need to access the args of the function
* in progress, so we switch the function pointer in the
* frame to the function below us, rather than the one we had
* hoped to call.
* The decompiler may need to access the args of the function in
* progress, so we switch the function pointer in the frame to the
* function below us, rather than the one we had hoped to call.
* XXXbe doesn't this case arise for js_Construct too?
*/
JSStackFrame *fp = cx->fp;
JSFunction *fun = fp->fun;
if (fp->down) /* guaranteed ? */
fp->fun = fp->down->fun;
fp->fun = fp->down->fun;
js_ReportIsNotFunction(cx, &argv[-2], JS_FALSE);
fp->fun = fun;
return JS_FALSE;

View File

@@ -2366,8 +2366,10 @@ PrimaryExpr(JSContext *cx, JSTokenStream *ts, JSTreeContext *tc)
JSTokenType tt;
JSParseNode *pn, *pn2, *pn3;
char *badWord;
#if JS_HAS_GETTER_SETTER
JSAtom *atom;
JSRuntime *rt;
#endif
#if JS_HAS_SHARP_VARS
JSParseNode *defsharp;