Commit b26080de authored by darin's avatar darin

Reviewed by Maciej.

        - http://bugs.webkit.org/show_bug.cgi?id=15579
          stop churning identifier reference counts copying Completion objects

        * kjs/completion.h: Replace the Identifier with an Identifier*.
        * kjs/nodes.cpp:
        (ForInNode::execute): Update for change to Completion constructor.
        (ContinueNode::execute): Ditto.
        (BreakNode::execute): Ditto.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@26832 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9177ecfd
2007-10-20 Darin Adler <darin@apple.com>
Reviewed by Maciej.
- http://bugs.webkit.org/show_bug.cgi?id=15579
stop churning identifier reference counts copying Completion objects
* kjs/completion.h: Replace the Identifier with an Identifier*.
* kjs/nodes.cpp:
(ForInNode::execute): Update for change to Completion constructor.
(ContinueNode::execute): Ditto.
(BreakNode::execute): Ditto.
2007-10-20 Mark Rowe <mrowe@apple.com>
Reviewed by Alp.
......
// -*- c-basic-offset: 2 -*-
/*
* This file is part of the KDE libraries
* Copyright (C) 1999-2001 Harri Porten (porten@kde.org)
* Copyright (C) 2001 Peter Kelly (pmk@post.com)
* Copyright (C) 2003 Apple Computer, Inc
* Copyright (C) 2003, 2007 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
......@@ -22,17 +21,14 @@
*
*/
#ifndef _KJS_COMPLETION_H_
#define _KJS_COMPLETION_H_
#include "CommonIdentifiers.h"
#include "value.h"
#ifndef KJS_COMPLETION_H
#define KJS_COMPLETION_H
namespace KJS {
/**
* Completion types.
*/
class Identifier;
class JSValue;
enum ComplType { Normal, Break, Continue, ReturnValue, Throw, Interrupted };
/**
......@@ -47,18 +43,21 @@ namespace KJS {
*/
class Completion {
public:
Completion(ComplType c = Normal, JSValue *v = NULL, const Identifier &t = CommonIdentifiers::shared()->nullIdentifier)
: comp(c), val(v), tar(t) { }
Completion(ComplType type = Normal, JSValue* value = 0)
: m_type(type), m_value(value), m_target(0) { }
Completion(ComplType type, const Identifier* target)
: m_type(type), m_value(0), m_target(target) { }
ComplType complType() const { return m_type; }
JSValue* value() const { return m_value; }
void setValue(JSValue* v) { m_value = v; }
const Identifier& target() const { return *m_target; }
bool isValueCompletion() const { return !!m_value; }
ComplType complType() const { return comp; }
JSValue *value() const { return val; }
void setValue(JSValue* v) { val = v; }
Identifier target() const { return tar; }
bool isValueCompletion() const { return !!val; }
private:
ComplType comp;
JSValue *val;
Identifier tar;
ComplType m_type;
JSValue* m_value;
const Identifier* m_target;
};
}
......
......@@ -1998,9 +1998,8 @@ Completion ForInNode::execute(ExecState *exec)
// the loop at all, because their object wrappers will have a
// property list but will throw an exception if you attempt to
// access any property.
if (e->isUndefinedOrNull()) {
return Completion(Normal, 0);
}
if (e->isUndefinedOrNull())
return Completion(Normal);
KJS_CHECKEXCEPTION
v = e->toObject(exec);
......@@ -2090,10 +2089,9 @@ Completion ContinueNode::execute(ExecState *exec)
if (ident.isEmpty() && !exec->context()->inIteration())
return createErrorCompletion(exec, SyntaxError, "Invalid continue statement.");
else if (!ident.isEmpty() && !exec->context()->seenLabels()->contains(ident))
if (!ident.isEmpty() && !exec->context()->seenLabels()->contains(ident))
return createErrorCompletion(exec, SyntaxError, "Label %s not found.", ident);
else
return Completion(Continue, 0, ident);
return Completion(Continue, &ident);
}
// ------------------------------ BreakNode ------------------------------------
......@@ -2106,10 +2104,9 @@ Completion BreakNode::execute(ExecState *exec)
if (ident.isEmpty() && !exec->context()->inIteration() &&
!exec->context()->inSwitch())
return createErrorCompletion(exec, SyntaxError, "Invalid break statement.");
else if (!ident.isEmpty() && !exec->context()->seenLabels()->contains(ident))
if (!ident.isEmpty() && !exec->context()->seenLabels()->contains(ident))
return createErrorCompletion(exec, SyntaxError, "Label %s not found.");
else
return Completion(Break, 0, ident);
return Completion(Break, &ident);
}
// ------------------------------ ReturnNode -----------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment