Ignore:
Timestamp:
May 21, 2008, 6:20:45 PM (17 years ago)
Author:
[email protected]
Message:

Merge squirrelfish branch into trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/debugger.cpp

    r28473 r33979  
    11// -*- c-basic-offset: 2 -*-
    22/*
    3  *  This file is part of the KDE libraries
     3 *  Copyright (C) 2008 Apple Inc. All rights reserved.
    44 *  Copyright (C) 1999-2001 Harri Porten ([email protected])
    55 *  Copyright (C) 2001 Peter Kelly ([email protected])
     
    2525
    2626#include "JSGlobalObject.h"
    27 #include "internal.h"
    28 #include "ustring.h"
    29 
    30 using namespace KJS;
    31 
    32 // ------------------------------ Debugger -------------------------------------
    3327
    3428namespace KJS {
    35   struct AttachedGlobalObject
    36   {
    37   public:
    38     AttachedGlobalObject(JSGlobalObject* o, AttachedGlobalObject* ai) : globalObj(o), next(ai) { ++Debugger::debuggersPresent; }
    39     ~AttachedGlobalObject() { --Debugger::debuggersPresent; }
    40     JSGlobalObject* globalObj;
    41     AttachedGlobalObject* next;
    42   };
    43 
    44 }
    45 
    46 int Debugger::debuggersPresent = 0;
    4729
    4830Debugger::Debugger()
    4931{
    50   rep = new DebuggerImp();
    5132}
    5233
    5334Debugger::~Debugger()
    5435{
    55   detach(0);
    56   delete rep;
     36    HashSet<JSGlobalObject*>::iterator end = m_globalObjects.end();
     37    for (HashSet<JSGlobalObject*>::iterator it = m_globalObjects.begin(); it != end; ++it)
     38        (*it)->setDebugger(0);
    5739}
    5840
    5941void Debugger::attach(JSGlobalObject* globalObject)
    6042{
    61   Debugger* other = globalObject->debugger();
    62   if (other == this)
    63     return;
    64   if (other)
    65     other->detach(globalObject);
    66   globalObject->setDebugger(this);
    67   rep->globalObjects = new AttachedGlobalObject(globalObject, rep->globalObjects);
     43    ASSERT(!globalObject->debugger());
     44    globalObject->setDebugger(this);
     45    m_globalObjects.add(globalObject);
    6846}
    6947
    70 void Debugger::detach(JSGlobalObject* globalObj)
     48void Debugger::detach(JSGlobalObject* globalObject)
    7149{
    72   // iterate the addresses where AttachedGlobalObject pointers are stored
    73   // so we can unlink items from the list
    74   AttachedGlobalObject **p = &rep->globalObjects;
    75   AttachedGlobalObject *q;
    76   while ((q = *p)) {
    77     if (!globalObj || q->globalObj == globalObj) {
    78       *p = q->next;
    79       q->globalObj->setDebugger(0);
    80       delete q;
    81     } else
    82       p = &q->next;
    83   }
    84 
    85   if (globalObj)
    86     latestExceptions.remove(globalObj);
    87   else
    88     latestExceptions.clear();
     50    ASSERT(m_globalObjects.contains(globalObject));
     51    m_globalObjects.remove(globalObject);
     52    globalObject->setDebugger(0);
    8953}
    9054
    91 bool Debugger::hasHandledException(ExecState *exec, JSValue *exception)
    92 {
    93     if (latestExceptions.get(exec->dynamicGlobalObject()).get() == exception)
    94         return true;
    95 
    96     latestExceptions.set(exec->dynamicGlobalObject(), exception);
    97     return false;
    98 }
    99 
    100 bool Debugger::sourceParsed(ExecState*, int /*sourceId*/, const UString &/*sourceURL*/,
    101                            const UString &/*source*/, int /*startingLineNumber*/, int /*errorLine*/, const UString & /*errorMsg*/)
    102 {
    103   return true;
    104 }
    105 
    106 bool Debugger::sourceUnused(ExecState*, int /*sourceId*/)
    107 {
    108   return true;
    109 }
    110 
    111 bool Debugger::exception(ExecState*, int /*sourceId*/, int /*lineno*/,
    112                          JSValue* /*exception */)
    113 {
    114   return true;
    115 }
    116 
    117 bool Debugger::atStatement(ExecState*, int /*sourceId*/, int /*firstLine*/,
    118                            int /*lastLine*/)
    119 {
    120   return true;
    121 }
    122 
    123 bool Debugger::callEvent(ExecState*, int /*sourceId*/, int /*lineno*/,
    124                          JSObject* /*function*/, const List &/*args*/)
    125 {
    126   return true;
    127 }
    128 
    129 bool Debugger::returnEvent(ExecState*, int /*sourceId*/, int /*lineno*/,
    130                            JSObject* /*function*/)
    131 {
    132   return true;
    133 }
    134 
     55} // namespace KJS
Note: See TracChangeset for help on using the changeset viewer.