/[jscoverage]/trunk/js/jsdbgapi.cpp
ViewVC logotype

Diff of /trunk/js/jsdbgapi.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 584 by siliconforks, Fri Apr 2 16:18:55 2010 UTC revision 585 by siliconforks, Sun Sep 12 15:13:23 2010 UTC
# Line 1  Line 1 
1  /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-  /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2   * vim: set ts=8 sw=4 et tw=78:   * vim: set ts=8 sw=4 et tw=99:
3   *   *
4   * ***** BEGIN LICENSE BLOCK *****   * ***** BEGIN LICENSE BLOCK *****
5   * Version: MPL 1.1/GPL 2.0/LGPL 2.1   * Version: MPL 1.1/GPL 2.0/LGPL 2.1
# Line 1569  Line 1569 
1569  }  }
1570    
1571  /************************************************************************/  /************************************************************************/
1572    
1573    class FakeFrame {
1574    public:
1575        FakeFrame(JSContext *cx, JSObject *scopeobj)
1576          : cx(cx) {
1577            JSFunction *fun = GET_FUNCTION_PRIVATE(cx, scopeobj);
1578            JS_ASSERT(FUN_MINARGS(fun) == 0 && !FUN_INTERPRETED(fun) && fun->u.n.extra == 0);
1579    
1580            vp[0] = OBJECT_TO_JSVAL(scopeobj);
1581            vp[1] = JSVAL_NULL;
1582    
1583            memset(&frame, 0, sizeof (frame));
1584            frame.fun = fun;
1585            frame.down = js_GetTopStackFrame(cx);
1586            frame.scopeChain = JS_GetGlobalForObject(cx, scopeobj);
1587            frame.argv = vp + 2;
1588    
1589            cx->fp = &frame;
1590        }
1591    
1592        ~FakeFrame() {
1593            if (frame.callobj)
1594                js_PutCallObject(cx, &frame);
1595            else if (frame.argsobj)
1596                js_PutArgsObject(cx, &frame);
1597            cx->fp = frame.down;
1598        }
1599    
1600    private:
1601        JSContext *cx;
1602        JSStackFrame frame;
1603        jsval vp[2];
1604    };
1605    
1606    JS_FRIEND_API(JSBool)
1607    js_GetPropertyByIdWithFakeFrame(JSContext *cx, JSObject *obj, JSObject *scopeobj, jsid id,
1608                                    jsval *vp)
1609    {
1610        FakeFrame frame(cx, scopeobj);
1611        return JS_GetPropertyById(cx, obj, id, vp);
1612    }
1613    
1614    JS_FRIEND_API(JSBool)
1615    js_SetPropertyByIdWithFakeFrame(JSContext *cx, JSObject *obj, JSObject *scopeobj, jsid id,
1616                                    jsval *vp)
1617    {
1618        FakeFrame frame(cx, scopeobj);
1619        return JS_SetPropertyById(cx, obj, id, vp);
1620    }
1621    
1622    JS_FRIEND_API(JSBool)
1623    js_CallFunctionValueWithFakeFrame(JSContext *cx, JSObject *obj, JSObject *scopeobj, jsval funval,
1624                                      uintN argc, jsval *argv, jsval *rval)
1625    {
1626        FakeFrame frame(cx, scopeobj);
1627        return JS_CallFunctionValue(cx, obj, funval, argc, argv, rval);
1628    }
1629    
1630    /************************************************************************/
1631    
1632  JS_PUBLIC_API(JSBool)  JS_PUBLIC_API(JSBool)
1633  JS_SetDebuggerHandler(JSRuntime *rt, JSTrapHandler handler, void *closure)  JS_SetDebuggerHandler(JSRuntime *rt, JSTrapHandler handler, void *closure)

Legend:
Removed from v.584  
changed lines
  Added in v.585

  ViewVC Help
Powered by ViewVC 1.1.24