Fixed illegal use of 'this' in instance methods. Fixed bug in getType for

undefined value.


git-svn-id: svn://10.0.0.236/trunk@101037 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rogerl%netscape.com 2001-08-14 21:02:38 +00:00
parent f9badb9fe5
commit ddbadceb78
2 changed files with 21 additions and 14 deletions

View File

@ -1991,7 +1991,11 @@ BinaryOpEquals:
case ExprNode::This:
{
JSFunction *f = mScopeChain->getContainerFunction();
JSType *theClass = mScopeChain->topClass();
JSType *theClass;
if (f)
theClass = f->getClass();
else
theClass = mScopeChain->topClass();
// 'this' is legal in prototype functions
// and at the script top-level
if ( ((f == NULL) && theClass)

View File

@ -698,19 +698,22 @@ Reference *ParameterBarrel::genReference(bool /* hasBase */, const String& name,
JSType *ScopeChain::findType(const StringAtom& typeName, size_t pos)
{
JSValue v = getCompileTimeValue(typeName, NULL);
if (v.isType())
return v.type;
else {
// Allow finding a function that has the same name as it's containing class
// i.e. the default constructor.
FunctionName *fnName = v.function->getFunctionName();
if ((fnName->prefix == FunctionName::normal)
&& v.isFunction() && v.function->getClass()
&& (v.function->getClass()->mClassName->compare(*fnName->name) == 0))
return v.function->getClass();
m_cx->reportError(Exception::semanticError, "Unknown type", pos);
return NULL;
}
if (!v.isUndefined()) {
if (v.isType())
return v.type;
else {
// Allow finding a function that has the same name as it's containing class
// i.e. the default constructor.
FunctionName *fnName = v.function->getFunctionName();
if ((fnName->prefix == FunctionName::normal)
&& v.isFunction() && v.function->getClass()
&& (v.function->getClass()->mClassName->compare(*fnName->name) == 0))
return v.function->getClass();
m_cx->reportError(Exception::semanticError, "Unknown type", pos);
return NULL;
}
}
return NULL;
}
// Take the specified type in 't' and see if we have a compile-time