This commit is contained in:
brendan%mozilla.org 1999-07-28 06:48:44 +00:00
Родитель 710e7dd097
Коммит 2ac2a0d840
12 изменённых файлов: 64 добавлений и 57 удалений

Просмотреть файл

@ -234,8 +234,8 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
if (callback) {
fmtData = (*callback)(userRef, "Mountain View", errorNumber);
if (fmtData != NULL) {
int totalArgsLength = 0;
int argLengths[10]; /* only {0} thru {9} supported */
size_t totalArgsLength = 0;
size_t argLengths[10]; /* only {0} thru {9} supported */
argCount = fmtData->argCount;
JS_ASSERT(argCount <= 10);
if (argCount > 0) {
@ -274,11 +274,12 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
const jschar *arg;
jschar *out;
int expandedArgs = 0;
int expandedLength
size_t expandedLength
= strlen(fmtData->format)
- (3 * argCount) /* exclude the {n} */
+ totalArgsLength;
/* Note - the above calculation assumes that each argument
/*
* Note - the above calculation assumes that each argument
* is used once and only once in the expansion !!!
*/
reportp->ucmessage = out
@ -311,11 +312,15 @@ js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
}
JS_ASSERT(expandedArgs == argCount);
*out = 0;
*messagep = js_DeflateString(cx, reportp->ucmessage,
out - reportp->ucmessage);
*messagep =
js_DeflateString(cx, reportp->ucmessage,
(size_t)(out - reportp->ucmessage));
}
} else { /* 0 arguments, the format string
(if it exists) is the entire message */
} else {
/*
* Zero arguments: the format string (if it exists) is the
* entire message.
*/
if (fmtData->format) {
*messagep = JS_strdup(cx, fmtData->format);
reportp->ucmessage

Просмотреть файл

@ -2530,7 +2530,7 @@ ret1:
** '+' or '-' after the 'e' in scientific notation
*/
JS_FRIEND_API(void)
JS_cnvtf(char *buf,int bufsz, int prcsn,double fval)
JS_cnvtf(char *buf, size_t bufsz, int prcsn, double fval)
{
intN decpt,sign,numdigits;
char *num, *nump;

Просмотреть файл

@ -47,7 +47,7 @@ JS_strtod(const char *s00, char **se);
* point value.
*/
JS_FRIEND_API(void)
JS_cnvtf(char *buf, intN bufsz, intN prcsn, double dval);
JS_cnvtf(char *buf, size_t bufsz, int prcsn, double dval);
JS_END_EXTERN_C

Просмотреть файл

@ -861,7 +861,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
return JS_FALSE;
if (caseNoteIndex >= 0) {
/* off is the previous JSOP_CASE's bytecode offset. */
if (!js_SetSrcNoteOffset(cx, cg, caseNoteIndex, 0,
if (!js_SetSrcNoteOffset(cx, cg, (uintN)caseNoteIndex, 0,
CG_OFFSET(cg) - off)) {
return JS_FALSE;
}
@ -877,10 +877,12 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
pn3->pn_offset = off;
if (pn3 == pn2->pn_head) {
/* Switch note's second offset is to first JSOP_CASE. */
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 1, off - top))
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 1,
off - top)) {
return JS_FALSE;
}
}
}
/* Emit default even if no explicit default statement. */
defaultOffset = js_Emit3(cx, cg, JSOP_DEFAULT, 0, 0);
@ -927,7 +929,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
/* Set the SRC_SWITCH note's offset operand to tell end of switch. */
off = CG_OFFSET(cg) - top;
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 0, off))
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0, off))
return JS_FALSE;
if (switchop == JSOP_TABLESWITCH) {
@ -1138,13 +1140,13 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
SET_STATEMENT_TOP(&stmtInfo, top);
if (!pn2->pn_kid2) {
/* No loop condition: flag this fact in the source notes. */
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 0, 0))
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0, 0))
return JS_FALSE;
beq = 0;
} else {
if (!js_EmitTree(cx, cg, pn2->pn_kid2))
return JS_FALSE;
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 0,
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0,
(ptrdiff_t)(CG_OFFSET(cg) - top))) {
return JS_FALSE;
}
@ -1161,7 +1163,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
if (pn2->pn_type != TOK_IN) {
/* Set the second note offset so we can find the update part. */
JS_ASSERT(noteIndex != -1);
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 1,
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 1,
(ptrdiff_t)(CG_OFFSET(cg) - top))) {
return JS_FALSE;
}
@ -1190,7 +1192,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
}
/* The third note offset helps us find the loop-closing jump. */
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 2,
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 2,
(ptrdiff_t)(CG_OFFSET(cg) - top))) {
return JS_FALSE;
}
@ -1586,7 +1588,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
EMIT_ATOM_INDEX_OP(op, atomIndex);
tmp = CG_OFFSET(cg);
if (noteIndex >= 0) {
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 0, tmp - off))
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0, tmp-off))
return JS_FALSE;
}
if (!pn2->pn_next)
@ -1680,7 +1682,7 @@ js_EmitTree(JSContext *cx, JSCodeGenerator *cg, JSParseNode *pn)
return JS_FALSE;
tmp = CG_OFFSET(cg);
if (noteIndex >= 0) {
if (!js_SetSrcNoteOffset(cx, cg, noteIndex, 0, tmp - off))
if (!js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0, tmp-off))
return JS_FALSE;
}
if (!pn2->pn_next)

Просмотреть файл

@ -1772,8 +1772,8 @@ js_ReportIsNotFunction(JSContext *cx, jsval *vp, JSBool constructing)
}
if (str) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
constructing ? JSMSG_NOT_CONSTRUCTOR
: JSMSG_NOT_FUNCTION,
(uintN)(constructing ? JSMSG_NOT_CONSTRUCTOR
: JSMSG_NOT_FUNCTION),
JS_GetStringBytes(str));
}
}

Просмотреть файл

@ -1916,8 +1916,8 @@ js_Interpret(JSContext *cx, jsval *result)
RESTORE_SP(fp);
if (!ok)
goto out;
i = ~i;
PUSH_NUMBER(cx, i);
d = (jsdouble) ~i;
PUSH_NUMBER(cx, d);
break;
case JSOP_NEG:

Просмотреть файл

@ -108,11 +108,11 @@ static JSPropertySpec object_props[] = {
static JSBool
obj_getSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
jsint slot;
uint32 slot;
JSAccessMode mode;
uintN attrs;
slot = JSVAL_TO_INT(id);
slot = (uint32) JSVAL_TO_INT(id);
if (id == INT_TO_JSVAL(JSSLOT_PROTO)) {
id = (jsid)cx->runtime->atomState.protoAtom;
mode = JSACC_PROTO;
@ -130,12 +130,12 @@ JS_STATIC_DLL_CALLBACK(JSBool)
obj_setSlot(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
JSObject *obj2;
jsint slot;
uint32 slot;
if (!JSVAL_IS_OBJECT(*vp))
return JS_TRUE;
obj2 = JSVAL_TO_OBJECT(*vp);
slot = JSVAL_TO_INT(id);
slot = (uint32) JSVAL_TO_INT(id);
while (obj2) {
if (obj2 == obj) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
@ -426,7 +426,7 @@ js_obj_toSource(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
/* If id is a non-identifier string, it needs to be quoted. */
if (JSVAL_IS_STRING(id) && !js_IsIdentifier(idstr)) {
idstr = js_QuoteString(cx, idstr, '\'');
idstr = js_QuoteString(cx, idstr, (jschar)'\'');
if (!idstr) {
ok = JS_FALSE;
goto error;
@ -1724,7 +1724,7 @@ js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
uintN protoattrs;
JSClass *clasp;
jsval pval;
jsint slot;
uint32 slot;
JSString *str;
rt = cx->runtime;
@ -1750,7 +1750,7 @@ js_SetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
sprop = sym_property(sym);
#if JS_HAS_OBJ_WATCHPOINT
if (!sprop) {
uint32 slot, nslots;
uint32 nslots;
jsval *slots;
/*
@ -2644,7 +2644,7 @@ void printObj(JSObject *jsobj) {
}
void printVal(jsval val) {
fprintf(stderr, "val %d (0x%p) = ", val, (void *)val);
fprintf(stderr, "val %d (0x%p) = ", (int)val, (void *)val);
if (JSVAL_IS_NULL(val)) {
fprintf(stderr, "null\n");
} else if (JSVAL_IS_VOID(val)) {
@ -2666,7 +2666,7 @@ void printVal(jsval val) {
}
void printId(jsid id) {
fprintf(stderr, "id %d (0x%p) is ", id, (void *)id);
fprintf(stderr, "id %d (0x%p) is ", (int)id, (void *)id);
printVal(js_IdToValue(id));
}

Просмотреть файл

@ -665,7 +665,7 @@ DecompileSwitch(SprintStack *ss, TableEntry *table, uintN tableLength,
return JS_FALSE;
jp->indent += 2;
if (JSVAL_IS_STRING(key)) {
rval = QuoteString(&ss->sprinter, str, '"');
rval = QuoteString(&ss->sprinter, str, (jschar)'"');
if (!rval)
return JS_FALSE;
} else {
@ -1619,7 +1619,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb)
todo = Sprint(&ss->sprinter, buf);
} else if (JSVAL_IS_STRING(key)) {
rval = QuoteString(&ss->sprinter, ATOM_TO_STRING(atom),
'"');
(jschar)'"');
if (!rval)
return JS_FALSE;
todo = Sprint(&ss->sprinter, "%s", rval);

Просмотреть файл

@ -88,7 +88,7 @@ typedef enum JSOp {
#define ARGC_HI(argc) ((jsbytecode)((argc) >> 8))
#define ARGC_LO(argc) ((jsbytecode)(argc))
#define GET_ARGC(pc) (((pc)[1] << 8) | (pc)[2])
#define GET_ARGC(pc) ((uintN)(((pc)[1] << 8) | (pc)[2]))
#define ARGC_LIMIT ((uint32)1 << 16)
/* Synonyms for quick JOF_QARG and JOF_QVAR bytecodes. */

Просмотреть файл

@ -117,7 +117,7 @@ static int fill2(SprintfState *ss, const char *src, int srclen, int width,
}
/* Copy out the source data */
rv = (*ss->stuff)(ss, src, srclen);
rv = (*ss->stuff)(ss, src, (JSUint32)srclen);
if (rv < 0) {
return rv;
}
@ -211,7 +211,7 @@ static int fill_n(SprintfState *ss, const char *src, int srclen, int width,
return rv;
}
}
rv = (*ss->stuff)(ss, src, srclen);
rv = (*ss->stuff)(ss, src, (JSUint32)srclen);
if (rv < 0) {
return rv;
}
@ -326,7 +326,7 @@ static int cvt_f(SprintfState *ss, double d, const char *fmt0, const char *fmt1)
/* Totally bogus % command to sprintf. Just ignore it */
return 0;
}
memcpy(fin, fmt0, amount);
memcpy(fin, fmt0, (size_t)amount);
fin[amount] = 0;
/* Convert floating point using the native sprintf code */
@ -906,7 +906,7 @@ static int dosprintf(SprintfState *ss, const char *fmt, va_list ap)
i = fmt - dolPt;
if( i < sizeof( pattern ) ){
pattern[0] = '%';
memcpy( &pattern[1], dolPt, i );
memcpy( &pattern[1], dolPt, (size_t)i );
rv = cvt_f(ss, u.d, pattern, &pattern[i+1] );
}
} else