Fixed Mac build warnings

git-svn-id: svn://10.0.0.236/trunk@117707 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pschwartau%netscape.com 2002-03-28 23:24:47 +00:00
parent b28e758bd2
commit dc3e631e9f
7 changed files with 69 additions and 65 deletions

View File

@ -124,7 +124,7 @@ Collector::collect()
inline bool isForwardingPointer(void* ptr)
{
return (uint32(ptr) & kIsForwardingPointer);
return (bool)(uint32(ptr) & kIsForwardingPointer);
}
void* Collector::copy(void* object, Collector::size_type size)
@ -190,7 +190,7 @@ public:
return gc.allocateObject(n, &owner);
}
void operator delete(void* ptr, Collector& gc) {}
void operator delete(void* /* ptr */, Collector& /* gc */) {}
void* operator new[] (size_t n, Collector& gc)
{

View File

@ -877,7 +877,7 @@ js2val ScopeChain::getCompileTimeValue(Context *cx, const String& name, Namespac
// in the case of duplicate parameter names, pick the last one
// XXX does the namespace handling make any sense here? Can parameters be in a namespace?
Reference *ParameterBarrel::genReference(Context *cx, bool /* hasBase */, const String& name, NamespaceList *names, Access acc, uint32 /*depth*/)
Reference *ParameterBarrel::genReference(Context * /* cx */, bool /* hasBase */, const String& name, NamespaceList *names, Access acc, uint32 /*depth*/)
{
Property *selectedProp = NULL;
for (PropertyIterator i = mProperties.lower_bound(name),
@ -2426,12 +2426,12 @@ js2val RegExp_Constructor(Context *cx, const js2val thisValue, js2val *argv, uin
regexpStr = JSValue::string(JSValue::toString(cx, argv[0]));
if ((argc > 1) && !JSValue::isUndefined(argv[1])) {
flagStr = JSValue::string(JSValue::toString(cx, argv[1]));
if (parseFlags(flagStr->begin(), flagStr->length(), &flags) != RE_NO_ERROR) {
if (parseFlags(flagStr->begin(), (int32)flagStr->length(), &flags) != RE_NO_ERROR) {
cx->reportError(Exception::syntaxError, "Failed to parse RegExp : '{0}'", *regexpStr + "/" + *flagStr); // XXX error message?
}
}
}
REState *pState = REParse(regexpStr->begin(), regexpStr->length(), flags, RE_VERSION_1);
REState *pState = REParse(regexpStr->begin(), (int32)regexpStr->length(), flags, RE_VERSION_1);
if (pState) {
thisInst->mRegExp = pState;
// XXX ECMA spec says these are DONTENUM, but SpiderMonkey and test suite disagree
@ -2514,10 +2514,10 @@ js2val RegExp_exec(Context *cx, const js2val thisValue, js2val *argv, uint32 arg
index = (int32)JSValue::f64(JSValue::toInteger(cx, lastIndex));
}
REMatchState *match = REExecute(thisInst->mRegExp, str->begin(), index, str->length(), JSValue::boolean(JSValue::toBoolean(cx, globalMultiline)));
REMatchState *match = REExecute(thisInst->mRegExp, str->begin(), index, (int32)str->length(), JSValue::boolean(JSValue::toBoolean(cx, globalMultiline)));
if (match) {
result = Array_Type->newInstance(cx);
String *matchStr = new String(str->substr(match->startIndex, match->endIndex - match->startIndex));
String *matchStr = new String(str->substr((uint32)match->startIndex, (uint32)match->endIndex - match->startIndex));
JSValue::instance(result)->setProperty(cx, *numberToString(0), NULL, JSValue::newString(matchStr));
String *parenStr = &cx->Empty_StringAtom;
for (int32 i = 0; i < match->parenCount; i++) {
@ -2535,9 +2535,9 @@ js2val RegExp_exec(Context *cx, const js2val thisValue, js2val *argv, uint32 arg
// XXX Set up the SpiderMonkey 'RegExp statics'
RegExp_Type->setProperty(cx, cx->LastMatch_StringAtom, CURRENT_ATTR, JSValue::newString(matchStr));
RegExp_Type->setProperty(cx, cx->LastParen_StringAtom, CURRENT_ATTR, JSValue::newString(parenStr));
String *contextStr = new String(str->substr(0, match->startIndex));
String *contextStr = new String(str->substr(0, (uint32)match->startIndex));
RegExp_Type->setProperty(cx, cx->LeftContext_StringAtom, CURRENT_ATTR, JSValue::newString(contextStr));
contextStr = new String(str->substr(match->endIndex, str->length() - match->endIndex));
contextStr = new String(str->substr((uint32)match->endIndex, (uint32)str->length() - match->endIndex));
RegExp_Type->setProperty(cx, cx->RightContext_StringAtom, CURRENT_ATTR, JSValue::newString(contextStr));
if (thisInst->mRegExp->flags & RE_GLOBAL) {
@ -2562,7 +2562,7 @@ static js2val RegExp_test(Context *cx, const js2val thisValue, js2val *argv, uin
const String *str = JSValue::string(JSValue::toString(cx, argv[0]));
RegExp_Type->getProperty(cx, cx->Multiline_StringAtom, CURRENT_ATTR);
js2val globalMultiline = cx->popValue();
REMatchState *match = REExecute(thisInst->mRegExp, str->begin(), 0, str->length(), JSValue::boolean(JSValue::toBoolean(cx, globalMultiline)));
REMatchState *match = REExecute(thisInst->mRegExp, str->begin(), 0, (int32)str->length(), JSValue::boolean(JSValue::toBoolean(cx, globalMultiline)));
if (match)
return kTrueValue;
}

View File

@ -189,7 +189,7 @@ static const double two31 = 2147483648.0;
public:
static int32 tag(const js2val v) { return JS2VAL_TAG(v); }
static uint32 tag(const js2val v) { return JS2VAL_TAG(v); }
static float64 f64(const js2val v) { return *JS2VAL_TO_DOUBLE(v); }
static JSObject *object(const js2val v) { return JS2VAL_TO_OBJECT(v); }
static JSInstance *instance(const js2val v) { return (JSInstance *)JS2VAL_TO_OBJECT(v); }
@ -686,7 +686,7 @@ XXX ...couldn't get this to work...
/**
* Scans through the object, and copies all references.
*/
Collector::size_type scan(Collector* collector)
Collector::size_type scan(Collector* /* collector */)
{
// enumerate property map elements.
// scan mPrototype.

View File

@ -249,7 +249,7 @@ static float64 random_nextDouble(Context *cx)
}
static js2val Math_random(Context *cx, const js2val /*thisValue*/, js2val *argv, uint32 /*argc*/)
static js2val Math_random(Context *cx, const js2val /*thisValue*/, js2val * /* argv */, uint32 /*argc*/)
{
random_init(cx);
return JSValue::newNumber(random_nextDouble(cx));

View File

@ -126,7 +126,7 @@ static js2val String_search(Context *cx, const js2val thisValue, js2val *argv, u
REState *pState = (checked_cast<JSRegExpInstance *>(JSValue::instance(regexp)))->mRegExp;
const String *str = JSValue::string(S);
REMatchState *match = REExecute(pState, str->begin(), 0, str->length(), false);
REMatchState *match = REExecute(pState, str->begin(), 0, (int32)str->length(), false);
if (match)
return JSValue::newNumber((float64)(match->startIndex));
else
@ -170,14 +170,14 @@ static js2val String_match(Context *cx, const js2val thisValue, js2val *argv, ui
int32 index = 0;
int32 lastIndex = 0;
while (true) {
REMatchState *match = REExecute(pState, JSValue::string(S)->begin(), lastIndex, JSValue::string(S)->length(), false);
REMatchState *match = REExecute(pState, JSValue::string(S)->begin(), lastIndex, (int32)JSValue::string(S)->length(), false);
if (match == NULL)
break;
if (lastIndex == match->endIndex)
lastIndex++;
else
lastIndex = match->endIndex;
String *matchStr = new String(JSValue::string(S)->substr(match->startIndex, match->endIndex - match->startIndex));
String *matchStr = new String(JSValue::string(S)->substr((uint32)match->startIndex, (uint32)match->endIndex - match->startIndex));
A->setProperty(cx, *numberToString(index++), NULL, JSValue::newString(matchStr));
}
JSValue::instance(regexp)->setProperty(cx, cx->LastIndex_StringAtom, NULL, JSValue::newNumber((float64)lastIndex));
@ -193,11 +193,11 @@ static const String interpretDollar(Context *cx, const String *replaceStr, uint3
case '$':
return cx->Dollar_StringAtom;
case '&':
return searchStr->substr(match->startIndex, match->endIndex - match->startIndex);
return searchStr->substr((uint32)match->startIndex, (uint32)match->endIndex - match->startIndex);
case '`':
return searchStr->substr(0, match->startIndex);
return searchStr->substr(0, (uint32)match->startIndex);
case '\'':
return searchStr->substr(match->endIndex, searchStr->length() - match->endIndex);
return searchStr->substr((uint32)match->endIndex, (uint32)searchStr->length() - match->endIndex);
case '0':
case '1':
case '2':
@ -209,7 +209,7 @@ static const String interpretDollar(Context *cx, const String *replaceStr, uint3
case '8':
case '9':
{
int32 num = (uint32)(*dollarValue - '0');
int32 num = (int32)(*dollarValue - '0');
if (num <= match->parenCount) {
if ((dollarPos < (replaceStr->length() - 2))
&& (dollarValue[1] >= '0') && (dollarValue[1] <= '9')) {
@ -277,7 +277,7 @@ static js2val String_replace(Context *cx, const js2val thisValue, js2val *argv,
int32 lastIndex = 0;
while (true) {
match = REExecute(pState, S->begin(), lastIndex, S->length(), false);
match = REExecute(pState, S->begin(), lastIndex, (int32)S->length(), false);
if (match) {
String insertString;
uint32 start = 0;
@ -297,7 +297,7 @@ static js2val String_replace(Context *cx, const js2val thisValue, js2val *argv,
}
}
// grab everything preceding the match
newString += S->substr(lastIndex, match->startIndex - lastIndex);
newString += S->substr((uint32)lastIndex, (uint32)match->startIndex - lastIndex);
// and then add the replacement string
newString += insertString;
}
@ -307,7 +307,7 @@ static js2val String_replace(Context *cx, const js2val thisValue, js2val *argv,
if ((pState->flags & RE_GLOBAL) == 0)
break;
}
newString += S->substr(lastIndex, S->length() - lastIndex);
newString += S->substr((uint32)lastIndex, (uint32)S->length() - lastIndex);
if ((pState->flags & RE_GLOBAL) == 0)
JSValue::instance(searchValue)->setProperty(cx, cx->LastIndex_StringAtom, NULL, JSValue::newNumber((float64)lastIndex));
return JSValue::newString(new String(newString));
@ -319,7 +319,7 @@ static js2val String_replace(Context *cx, const js2val thisValue, js2val *argv,
if (pos == String::npos)
return JSValue::newString(S);
match.startIndex = (int32)pos;
match.endIndex = match.startIndex + searchStr->length();
match.endIndex = match.startIndex + (int32)searchStr->length();
match.parenCount = 0;
String insertString;
String newString;
@ -337,9 +337,9 @@ static js2val String_replace(Context *cx, const js2val thisValue, js2val *argv,
break;
}
}
newString += S->substr(0, match.startIndex);
newString += S->substr(0, (uint32)match.startIndex);
newString += insertString;
uint32 index = match.endIndex;
uint32 index = (uint32)match.endIndex;
newString += S->substr(index, S->length() - index);
return JSValue::newString(new String(newString));
}
@ -375,12 +375,12 @@ static void regexpSplitMatch(const String *S, uint32 q, REState *RE, MatchResult
result.failure = true;
result.captures = NULL;
REMatchState *match = REMatch(RE, S->begin() + q, S->length() - q);
REMatchState *match = REMatch(RE, S->begin() + q, (int32)(S->length() - q));
if (match) {
result.endIndex = match->startIndex + q;
result.failure = false;
result.capturesCount = match->parenCount;
result.capturesCount = (uint32)match->parenCount;
if (match->parenCount) {
result.captures = new js2val[match->parenCount];
for (int32 i = 0; i < match->parenCount; i++) {

View File

@ -792,7 +792,7 @@ lexHex:
}
++parseState->src;
}
parseState->result->data.chclass.classIndex = parseState->classCount++;
parseState->result->data.chclass.classIndex = (int32)parseState->classCount++;
/* Call calculateBitmapSize now as we want any errors it finds
to be reported during the parse phase, not at execution */
if (!calculateBitmapSize(parseState, parseState->result))
@ -888,7 +888,7 @@ quantifier:
parseState->result->child = term;
parseState->result->parenIndex = parenBaseCount;
parseState->result->data.quantifier.parenCount
= parseState->parenCount - parenBaseCount;
= (REint32)(parseState->parenCount - parenBaseCount);
if ((parseState->src < parseState->srcEnd) && (*parseState->src == '?')) {
++parseState->src;
parseState->result->data.quantifier.greedy = RE_FALSE;
@ -913,7 +913,7 @@ quantifier:
*/
static REMatchState *bolMatcher(REGlobalData *gData, REMatchState *x)
{
REuint32 e = x->endIndex;
REuint32 e = (REuint32)x->endIndex;
if (e != 0) {
if (gData->globalMultiline ||
(gData->regexp->flags & RE_MULTILINE)) {
@ -1453,9 +1453,9 @@ static REMatchState *backrefMatcher(REGlobalData *gData,
if (s->index == -1)
return x;
e = x->endIndex;
len = s->length;
f = e + len;
e = (REuint32)x->endIndex;
len = (REuint32)s->length;
f = (REint32)(e + len);
if (f > gData->length)
return NULL;
@ -1510,12 +1510,12 @@ static void freeRENode(RENode *t)
#define ARG_LEN (2)
#define CHECK_RANGE(branch, target) (ASSERT((((target) - (branch)) >= -32768) && (((target) - (branch)) <= 32767)))
#define EMIT_ARG(pc, a) ((pc)[0] = ((a) >> 8), (pc)[1] = (REuint8)(a), (pc) += ARG_LEN)
#define EMIT_ARG(pc, a) ((pc)[0] = (REuint8)((a) >> 8), (pc)[1] = (REuint8)(a), (pc) += ARG_LEN)
#define EMIT_BRANCH(pc) ((pc) += ARG_LEN)
#define EMIT_FIXUP(branch, target) (EMIT_ARG((branch), (target) - (branch)))
#define GET_ARG(pc) ((REuint32)(((pc)[0] << 8) | (pc)[1]))
REuint8 *emitREBytecode(REState *pState, REuint8 *pc, RENode *t)
static REuint8 *emitREBytecode(REState *pState, REuint8 *pc, RENode *t)
{
RENode *nextAlt;
REuint8 *nextAltFixup, *nextTermFixup;
@ -1626,7 +1626,7 @@ REuint8 *emitREBytecode(REState *pState, REuint8 *pc, RENode *t)
return pc;
}
REBackTrackData *pushBackTrackState(REGlobalData *gData, REOp op,
static REBackTrackData *pushBackTrackState(REGlobalData *gData, REOp op,
REuint8 *target, REMatchState *x)
{
REBackTrackData *result;
@ -1645,7 +1645,7 @@ REBackTrackData *pushBackTrackState(REGlobalData *gData, REOp op,
result->state = copyState(x);
result->lastParen = gData->lastParen;
result->precedingStateTop = stateStackTop;
result->precedingStateTop = (REint32)stateStackTop;
if (stateStackTop) {
result->precedingState = (REProgState *)malloc(sizeof(REProgState)
* stateStackTop);
@ -1668,7 +1668,8 @@ static REMatchState *executeREBytecode(REuint8 *pc, REGlobalData *gData, REMatch
REContinuationData currentContinuation;
REMatchState *result;
REBackTrackData *backTrackData;
REint32 k, length, offset, parenIndex, index;
REint32 k, length, offset, index;
REuint32 parenIndex;
REbool anchor = RE_FALSE;
REchar anchorCh;
REchar matchCh;
@ -1686,12 +1687,12 @@ static REMatchState *executeREBytecode(REuint8 *pc, REGlobalData *gData, REMatch
switch (op) {
case REOP_FLAT1:
case REOP_FLAT1i:
anchorCh = GET_ARG(pc);
anchorCh = (REchar)GET_ARG(pc);
anchor = RE_TRUE;
break;
case REOP_FLATN:
case REOP_FLATNi:
k = GET_ARG(pc);
k = (REint32)GET_ARG(pc);
anchorCh = gData->regexp->srcStart[k];
anchor = RE_TRUE;
break;
@ -1752,28 +1753,28 @@ static REMatchState *executeREBytecode(REuint8 *pc, REGlobalData *gData, REMatch
result = letdigMatcher(gData, x, RE_FALSE);
break;
case REOP_FLATN:
offset = GET_ARG(pc);
offset = (REint32)GET_ARG(pc);
pc += ARG_LEN;
length = GET_ARG(pc);
length = (REint32)GET_ARG(pc);
pc += ARG_LEN;
result = flatNMatcher(gData, x, gData->regexp->srcStart + offset,
length);
break;
case REOP_FLATNi:
offset = GET_ARG(pc);
offset = (REint32)GET_ARG(pc);
pc += ARG_LEN;
length = GET_ARG(pc);
length = (REint32)GET_ARG(pc);
pc += ARG_LEN;
result = flatNIMatcher(gData, x, gData->regexp->srcStart + offset,
length);
break;
case REOP_FLAT1:
matchCh = GET_ARG(pc);
matchCh = (REchar)GET_ARG(pc);
pc += ARG_LEN;
result = flatMatcher(gData, x, matchCh);
break;
case REOP_FLAT1i:
matchCh = GET_ARG(pc);
matchCh = (REchar)GET_ARG(pc);
pc += ARG_LEN;
result = flatIMatcher(gData, x, matchCh);
break;
@ -1791,7 +1792,7 @@ static REMatchState *executeREBytecode(REuint8 *pc, REGlobalData *gData, REMatch
case REOP_ENDALT:
--stateStackTop;
currentContinuation = stateStack[stateStackTop].continuation;
offset = GET_ARG(pc);
offset = (REint32)GET_ARG(pc);
pc += offset;
op = (REOp)(*pc++);
continue;
@ -1810,13 +1811,13 @@ static REMatchState *executeREBytecode(REuint8 *pc, REGlobalData *gData, REMatch
x->parens[parenIndex].length = x->endIndex
- x->parens[parenIndex].index;
if (parenIndex > gData->lastParen)
gData->lastParen = parenIndex;
gData->lastParen = (REint32)parenIndex;
op = (REOp)(*pc++);
continue;
case REOP_BACKREF:
parenIndex = GET_ARG(pc);
pc += ARG_LEN;
result = backrefMatcher(gData, x, parenIndex);
result = backrefMatcher(gData, x, (uint32)parenIndex);
break;
case REOP_ASSERT:
@ -1873,7 +1874,7 @@ static REMatchState *executeREBytecode(REuint8 *pc, REGlobalData *gData, REMatch
break;
case REOP_CLASS:
index = GET_ARG(pc);
index = (int32)GET_ARG(pc);
pc += ARG_LEN;
result = classMatcher(gData, x, index);
if (gData->error != RE_NO_ERROR) return NULL;
@ -1897,14 +1898,14 @@ static REMatchState *executeREBytecode(REuint8 *pc, REGlobalData *gData, REMatch
stateStack[stateStackTop].max = 1;
goto quantcommon;
case REOP_QUANT:
stateStack[stateStackTop].min = GET_ARG(pc);
stateStack[stateStackTop].min = (int32)GET_ARG(pc);
pc += ARG_LEN;
stateStack[stateStackTop].max = GET_ARG(pc);
stateStack[stateStackTop].max = (int32)GET_ARG(pc);
pc += ARG_LEN;
quantcommon:
stateStack[stateStackTop].parenCount = GET_ARG(pc);
stateStack[stateStackTop].parenCount = (int32)GET_ARG(pc);
pc += ARG_LEN;
stateStack[stateStackTop].parenIndex = GET_ARG(pc);
stateStack[stateStackTop].parenIndex = (int32)GET_ARG(pc);
pc += ARG_LEN;
stateStack[stateStackTop].index = x->endIndex;
stateStack[stateStackTop].continuation = currentContinuation;
@ -1959,7 +1960,7 @@ quantcommon:
if (!pushBackTrackState(gData, REOP_REPEAT, pc, x)) return NULL;
pc += ARG_LEN;
op = (REOp)(*pc++);
parenIndex = stateStack[stateStackTop - 1].parenIndex;
parenIndex = (REuint32)stateStack[stateStackTop - 1].parenIndex;
for (k = 0; k <= stateStack[stateStackTop - 1].parenCount; k++)
x->parens[parenIndex + k].index = -1;
}
@ -1978,14 +1979,14 @@ quantcommon:
stateStack[stateStackTop].max = 1;
goto minimalquantcommon;
case REOP_MINIMALQUANT:
stateStack[stateStackTop].min = GET_ARG(pc);
stateStack[stateStackTop].min = (int32)GET_ARG(pc);
pc += ARG_LEN;
stateStack[stateStackTop].max = GET_ARG(pc);
stateStack[stateStackTop].max = (int32)GET_ARG(pc);
pc += ARG_LEN;
minimalquantcommon:
stateStack[stateStackTop].parenCount = GET_ARG(pc);
stateStack[stateStackTop].parenCount = (int32)GET_ARG(pc);
pc += ARG_LEN;
stateStack[stateStackTop].parenIndex = GET_ARG(pc);
stateStack[stateStackTop].parenIndex = (int32)GET_ARG(pc);
pc += ARG_LEN;
stateStack[stateStackTop].index = x->endIndex;
stateStack[stateStackTop].continuation = currentContinuation;
@ -2015,7 +2016,7 @@ minimalquantcommon:
*/
if ((stateStack[stateStackTop].max == -1)
|| (stateStack[stateStackTop].max > 0)) {
parenIndex = stateStack[stateStackTop].parenIndex;
parenIndex = (REuint32)stateStack[stateStackTop].parenIndex;
for (k = 0; k <= stateStack[stateStackTop].parenCount; k++)
x->parens[parenIndex + k].index = -1;
stateStack[stateStackTop].index = x->endIndex;
@ -2045,7 +2046,7 @@ minimalquantcommon:
if (stateStack[stateStackTop].max != -1)
stateStack[stateStackTop].max--;
if (stateStack[stateStackTop].min > 0) {
parenIndex = stateStack[stateStackTop].parenIndex;
parenIndex = (REuint32)stateStack[stateStackTop].parenIndex;
for (k = 0; k <= stateStack[stateStackTop].parenCount; k++)
x->parens[parenIndex + k].index = -1;
stateStack[stateStackTop].index = x->endIndex;
@ -2088,7 +2089,7 @@ minimalquantcommon:
for (k = 0; k < backTrackData->precedingStateTop; k++) {
stateStack[k] = backTrackData->precedingState[k];
}
stateStackTop = backTrackData->precedingStateTop;
stateStackTop = (REuint32)backTrackData->precedingStateTop;
if (backTrackData->precedingState)
free(backTrackData->precedingState);
@ -2240,7 +2241,7 @@ static REMatchState *initMatch(REGlobalData *gData, REState *pState,
return NULL;
}
result->parenCount = pState->parenCount;
result->parenCount = (REint32)pState->parenCount;
for (j = 0; j < result->parenCount; j++)
result->parens[j].index = -1;
result->startIndex = 0;
@ -2253,7 +2254,7 @@ static REMatchState *initMatch(REGlobalData *gData, REState *pState,
gData->length = length;
gData->error = RE_NO_ERROR;
gData->lastParen = 0;
gData->globalMultiline = globalMultiline;
gData->globalMultiline = (REbool)globalMultiline;
backTrackStackTop = 0;
stateStackTop = 0;

View File

@ -149,7 +149,10 @@ static js2val dikdik(Context * /*cx*/, const js2val /*thisValue*/, js2val /*argv
static js2val quit(Context * /*cx*/, const js2val /*thisValue*/, js2val /*argv*/[], uint32 /*argc*/)
{
// XXX need correct call for other platforms
#ifdef XP_PC
exit(0);
#endif
return kUndefinedValue;
}