mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Fixed illegal use of 'this' in instance methods. Fixed bug in getType for
undefined value.
This commit is contained in:
parent
906f2635ff
commit
31ea7a8d8e
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user