Fixed unused vars. Added string literal as alternative function name.

Implemented invokeCall to use override.


git-svn-id: svn://10.0.0.236/trunk@87471 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rogerl%netscape.com
2001-02-20 21:39:59 +00:00
parent e77aaa22b0
commit 667f2a187d
4 changed files with 51 additions and 11 deletions

View File

@@ -229,7 +229,6 @@ bool ICodeGenerator::resolveIdentifier(const StringAtom &name, Reference &ref, b
else {
if (mClass) { // we're compiling a method of a class
// look for static references first
bool isConstructor = false;
if (isStaticName(mClass, name, ref)) {
return true;
}
@@ -429,7 +428,6 @@ TypedRegister ICodeGenerator::genExpr(ExprNode *p,
ICodeOp dblOp;
JSTypes::Operator op;
TypedRegister ret(NotARegister, &None_Type);
ICodeOp xOp = ADD;
switch (p->getKind()) {
case ExprNode::True:
if (trueBranch || falseBranch) {

View File

@@ -813,6 +813,41 @@ JSValue Context::interpret(ICodeModule* iCode, const JSValues& args)
break;
case INVOKE_CALL:
{
// the call operator has been invoked, see if it's overridden
// for the target
InvokeCall* call = static_cast<InvokeCall*>(instruction);
JSValue v = (*registers)[op2(call).first];
JSClass *clazz = v.isObject() ? dynamic_cast<JSClass*>(v.object->getType()) : NULL;
JSFunction *target = NULL;
if (clazz) {
JSOperator *candidate = clazz->findUnaryOperator(JSTypes::Call);
if (candidate) {
target = candidate->mFunction;
if (invokeFunction(target, registers, op1(call), v, op3(call))) {
endPC = mICode->its_iCode->end();
continue;
}
}
}
if (v.isFunction())
target = v.function;
else
if (v.isObject()) {
JSType *t = dynamic_cast<JSType*>(v.object);
if (t)
target = t->getInvokor();
}
if (!target)
throw new JSException("Call to non callable object");
if (invokeFunction(target, registers, op1(call), target->getThis(), op3(call))) {
endPC = mICode->its_iCode->end();
continue;
}
}
break;
case DIRECT_CALL:
{
DirectCall* call = static_cast<DirectCall*>(instruction);

View File

@@ -969,16 +969,20 @@ namespace JavaScript
{
fn.prefix = FunctionName::normal;
const Token *t = &lexer.get(true);
if (t->hasKind(Token::Get) || t->hasKind(Token::Set)) {
const Token *t2 = &lexer.peek(true);
if (!lineBreakBefore(*t2) && t2->getFlag(Token::canFollowGet)) {
fn.prefix = t->hasKind(Token::Get) ? FunctionName::Get :
FunctionName::Set;
t = &lexer.get(true);
}
if (t->hasKind(Token::string)) {
fn.name = NodeFactory::LiteralString(t->getPos(),ExprNode::string,copyTokenChars(*t));
}
else {
if (t->hasKind(Token::Get) || t->hasKind(Token::Set)) {
const Token *t2 = &lexer.peek(true);
if (!lineBreakBefore(*t2) && t2->getFlag(Token::canFollowGet)) {
fn.prefix = t->hasKind(Token::Get) ? FunctionName::Get :
FunctionName::Set;
t = &lexer.get(true);
}
}
fn.name = parseQualifiedIdentifier(*t, true);
}
fn.name = parseQualifiedIdentifier(*t, true);
}

View File

@@ -181,6 +181,9 @@ Formatter& operator<< (Formatter& f, JSTypes::Operator& op)
f << "BitXor"; break;
case JSTypes::BitOr:
f << "BitOr"; break;
default:
NOT_REACHED("Bad op");
break;
}
return f;
}