Fix Mac build errors/warnings

git-svn-id: svn://10.0.0.236/trunk@112399 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pschwartau%netscape.com
2002-01-17 21:23:59 +00:00
parent 2784b79499
commit b5cf363183
3 changed files with 8839 additions and 2274 deletions

View File

@@ -79,7 +79,8 @@ JSType *Type_Type;
JSType *Void_Type;
JSType *Null_Type;
JSType *Unit_Type;
JSType *Attribute_Type;
JSType *Attribute_Type;
JSType *Package_Type;
JSType *NamedArgument_Type;
JSArrayType *Array_Type;
@@ -335,13 +336,20 @@ Property *JSObject::defineVariable(Context *cx, const String &name, NamespaceLis
mProperties.insert(e);
return prop;
}
Property *JSObject::defineAlias(Context *cx, const String &name, NamespaceList *names, PropertyAttribute attrFlags, JSType *type, JSValue *vp)
{
Property *prop = new Property(vp, type, attrFlags);
const PropertyMap::value_type e(name, new NamespacedProperty(prop, names));
mProperties.insert(e);
return prop;
}
Property *JSObject::defineAlias(Context * /*cx*/, const String &name, NamespaceList *names, PropertyAttribute attrFlags, JSType *type, JSValue *vp)
{
Property *prop = new Property(vp, type, attrFlags);
const PropertyMap::value_type e(name, new NamespacedProperty(prop, names));
mProperties.insert(e);
return prop;
}
@@ -916,7 +924,8 @@ JSType *Context::getParameterType(FunctionDefinition &function, int index)
// Iterates over the linked list of statements, p.
// 1. Adds 'symbol table' entries for each class, var & function by defining
// 1. Adds 'symbol table' entries for each class, var & function by defining
// them in the object at the top of the scope chain
// 2. Using information from pass 1, evaluate types (and XXX later XXX other
// compile-time constants) to complete the definitions
@@ -968,25 +977,42 @@ bool ScopeChain::isPossibleUncheckedFunction(FunctionDefinition &f)
}
}
return result;
}
/*
Build a name for the package from the identifier list
*/
String ScopeChain::getPackageName(IdentifierList *packageIdList)
{
String packagePath;
IdentifierList *idList = packageIdList;
while (idList) {
packagePath += idList->name;
idList = idList->next;
if (idList)
packagePath += '/'; // XXX how to get path separator for OS?
}
return packagePath;
}
// counts the number of pigs that can fit in a small wicker basket
/*
Build a name for the package from the identifier list
*/
String ScopeChain::getPackageName(IdentifierList *packageIdList)
{
String packagePath;
IdentifierList *idList = packageIdList;
while (idList) {
packagePath += idList->name;
idList = idList->next;
if (idList)
packagePath += '/'; // XXX how to get path separator for OS?
}
return packagePath;
}
// counts the number of pigs that can fit in a small wicker basket
void JSFunction::countParameters(Context *cx, FunctionDefinition &f)
{
uint32 requiredParameterCount = 0;
@@ -1244,48 +1270,90 @@ void ScopeChain::collectNames(StmtNode *p)
}
}
break;
case StmtNode::Import:
{
ImportStmtNode *i = checked_cast<ImportStmtNode *>(p);
String packageName;
if (i->packageIdList)
packageName = getPackageName(i->packageIdList);
else
packageName = *i->packageString;
if (!m_cx->checkForPackage(packageName))
m_cx->loadPackage(packageName, packageName + ".js");
JSValue packageValue = getCompileTimeValue(packageName, NULL);
ASSERT(packageValue.isObject() && (packageValue.object->mType == Package_Type));
Package *package = checked_cast<Package *>(packageValue.object);
if (i->varName)
defineVariable(m_cx, *i->varName, NULL, Package_Type, JSValue(package));
for (PropertyIterator it = package->mProperties.begin(), end = package->mProperties.end();
(it != end); it++)
{
ASSERT(PROPERTY_KIND(it) == ValuePointer);
bool makeAlias = true;
if (i->includeExclude) {
makeAlias = i->exclude;
IdentifierList *idList = i->includeExclude;
while (idList) {
if (idList->name.compare(PROPERTY_NAME(it)) == 0) {
makeAlias = !makeAlias;
break;
}
idList = idList->next;
}
}
if (makeAlias)
defineAlias(m_cx, PROPERTY_NAME(it), PROPERTY_NAMESPACELIST(it), PROPERTY_ATTR(it), PROPERTY_TYPE(it), PROPERTY_VALUEPOINTER(it));
}
}
break;
case StmtNode::Import:
{
ImportStmtNode *i = checked_cast<ImportStmtNode *>(p);
String packageName;
if (i->packageIdList)
packageName = getPackageName(i->packageIdList);
else
packageName = *i->packageString;
if (!m_cx->checkForPackage(packageName))
m_cx->loadPackage(packageName, packageName + ".js");
JSValue packageValue = getCompileTimeValue(packageName, NULL);
ASSERT(packageValue.isObject() && (packageValue.object->mType == Package_Type));
Package *package = checked_cast<Package *>(packageValue.object);
if (i->varName)
defineVariable(m_cx, *i->varName, NULL, Package_Type, JSValue(package));
for (PropertyIterator it = package->mProperties.begin(), end = package->mProperties.end();
(it != end); it++)
{
ASSERT(PROPERTY_KIND(it) == ValuePointer);
bool makeAlias = true;
if (i->includeExclude) {
makeAlias = i->exclude;
IdentifierList *idList = i->includeExclude;
while (idList) {
if (idList->name.compare(PROPERTY_NAME(it)) == 0) {
makeAlias = !makeAlias;
break;
}
idList = idList->next;
}
}
if (makeAlias)
defineAlias(m_cx, PROPERTY_NAME(it), PROPERTY_NAMESPACELIST(it), PROPERTY_ATTR(it), PROPERTY_TYPE(it), PROPERTY_VALUEPOINTER(it));
}
}
break;
case StmtNode::Namespace:
{
NamespaceStmtNode *n = checked_cast<NamespaceStmtNode *>(p);
@@ -1293,21 +1361,36 @@ void ScopeChain::collectNames(StmtNode *p)
x->mNamespaceList = new NamespaceList(n->name, x->mNamespaceList);
m_cx->getGlobalObject()->defineVariable(m_cx, n->name, (NamespaceList *)(NULL), Property::NoAttribute, Attribute_Type, JSValue(x));
}
break;
case StmtNode::Package:
{
PackageStmtNode *ps = checked_cast<PackageStmtNode *>(p);
String packageName = getPackageName(ps->packageIdList);
Package *package = new Package(packageName);
ps->scope = package;
defineVariable(m_cx, packageName, NULL, Package_Type, JSValue(package));
m_cx->mPackages.push_back(package);
addScope(ps->scope);
collectNames(ps->body);
popScope();
package->mStatus = Package::InHand;
}
break;
case StmtNode::Package:
{
PackageStmtNode *ps = checked_cast<PackageStmtNode *>(p);
String packageName = getPackageName(ps->packageIdList);
Package *package = new Package(packageName);
ps->scope = package;
defineVariable(m_cx, packageName, NULL, Package_Type, JSValue(package));
m_cx->mPackages.push_back(package);
addScope(ps->scope);
collectNames(ps->body);
popScope();
package->mStatus = Package::InHand;
}
break;
default:
break;
@@ -1841,14 +1924,22 @@ void Context::buildRuntimeForStmt(StmtNode *p)
{
// do anything ?
}
break;
case StmtNode::Package:
{
PackageStmtNode *ps = checked_cast<PackageStmtNode *>(p);
mScopeChain->addScope(ps->scope);
buildRuntimeForStmt(ps->body);
mScopeChain->popScope();
}
break;
case StmtNode::Package:
{
PackageStmtNode *ps = checked_cast<PackageStmtNode *>(p);
mScopeChain->addScope(ps->scope);
buildRuntimeForStmt(ps->body);
mScopeChain->popScope();
}
break;
default:
break;
@@ -2378,9 +2469,11 @@ JSValue RegExp_exec(Context *cx, const JSValue& thisValue, JSValue *argv, uint32
if (regexp_result->parens[i].index != -1) {
String *parenStr = new String(str->substr((uint32)(regexp_result->parens[i].index), (uint32)(regexp_result->parens[i].length)));
resultArray->setProperty(cx, *numberToString(i + 1), NULL, JSValue(parenStr));
}
}
else
resultArray->setProperty(cx, *numberToString(i + 1), NULL, kUndefinedValue);
resultArray->setProperty(cx, *numberToString(i + 1), NULL, kUndefinedValue);
}
// XXX SpiderMonkey also adds 'index' and 'input' properties to the result
resultArray->setProperty(cx, cx->Index_StringAtom, CURRENT_ATTR, JSValue((float64)(regexp_result->endIndex)));
@@ -2852,8 +2945,10 @@ void Context::initBuiltins()
{ "SyntaxError", SyntaxError_Constructor, &kNullValue },
{ "TypeError", TypeError_Constructor, &kNullValue },
{ "UriError", UriError_Constructor, &kNullValue },
{ "RegExp", RegExp_Constructor, &kNullValue },
{ "Package", NULL, &kNullValue },
{ "RegExp", RegExp_Constructor, &kNullValue },
{ "Package", NULL, &kNullValue },
};
Object_Type = new JSType(this, &mWorld.identifiers[widenCString(builtInClasses[0].name)], NULL);
@@ -2909,7 +3004,8 @@ void Context::initBuiltins()
// XXX RegExp.prototype is set to a RegExp instance, which isn't ECMA (it's supposed to be an Object instance) bu
// is SpiderMonkey compatible.
RegExp_Type = new JSType(this, &mWorld.identifiers[widenCString(builtInClasses[21].name)], Object_Type);
Package_Type = new JSType(this, &mWorld.identifiers[widenCString(builtInClasses[22].name)], Object_Type);
Package_Type = new JSType(this, &mWorld.identifiers[widenCString(builtInClasses[22].name)], Object_Type);
@@ -3249,37 +3345,68 @@ Context::Context(JSObject **global, World &world, Arena &a, Pragma::Flags flags)
getGlobalObject()->defineVariable(this, Infinity_StringAtom, (NamespaceList *)(NULL), Property::NoAttribute, Void_Type, kPositiveInfinity);
}
/*
See if the specified package is already loaded - return true
Throw an exception if the package is being loaded already
*/
bool Context::checkForPackage(const String &packageName)
{
// XXX linear search
for (PackageList::iterator pi = mPackages.begin(), end = mPackages.end(); (pi != end); pi++) {
if (PACKAGE_NAME(pi).compare(packageName) == 0) {
if (PACKAGE_STATUS(pi) == Package::OnItsWay)
reportError(Exception::referenceError, "Package circularity");
else
return true;
}
}
return false;
}
/*
Load the specified package from the file
*/
void Context::loadPackage(const String &packageName, const String &filename)
{
// XXX need some rules for search path
// XXX need to extract just the target package from the file
readEvalFile(filename);
}
/*
See if the specified package is already loaded - return true
Throw an exception if the package is being loaded already
*/
bool Context::checkForPackage(const String &packageName)
{
// XXX linear search
for (PackageList::iterator pi = mPackages.begin(), end = mPackages.end(); (pi != end); pi++) {
if (PACKAGE_NAME(pi).compare(packageName) == 0) {
if (PACKAGE_STATUS(pi) == Package::OnItsWay)
reportError(Exception::referenceError, "Package circularity");
else
return true;
}
}
return false;
}
/*
Load the specified package from the file
*/
void Context::loadPackage(const String & /*packageName*/, const String &filename)
{
// XXX need some rules for search path
// XXX need to extract just the target package from the file
readEvalFile(filename);
}
void Context::reportError(Exception::Kind kind, char *message, size_t pos, const char *arg)
{