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:
parent
f9badb9fe5
commit
ddbadceb78
@ -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…
x
Reference in New Issue
Block a user