jitcraft/API.cpp
changeset 62 e04c5be84792
parent 61 864e4b02a4c1
child 64 11c81eb30246
     1.1 --- a/jitcraft/API.cpp	Sun Jul 08 11:33:12 2012 -0700
     1.2 +++ b/jitcraft/API.cpp	Sun Jul 08 15:23:48 2012 -0700
     1.3 @@ -30,7 +30,7 @@
     1.4  using namespace ke;
     1.5  
     1.6  bool
     1.7 -Ke::Initialize()
     1.8 +Ke::Keima::Initialize()
     1.9  {
    1.10      SingleThreadedZone = new Zone();
    1.11      if (!SingleThreadedZone || !SingleThreadedZone->initialize())
    1.12 @@ -39,7 +39,7 @@
    1.13  }
    1.14  
    1.15  void
    1.16 -Ke::Shutdown()
    1.17 +Ke::Keima::Shutdown()
    1.18  {
    1.19      delete SingleThreadedZone;
    1.20      SingleThreadedZone = NULL;
    1.21 @@ -68,6 +68,12 @@
    1.22      return ZONE()->rootScopes().make(obj);
    1.23  }
    1.24  
    1.25 +template <typename From, typename To> static inline To *
    1.26 +Open(Ke::Handle<From> from)
    1.27 +{
    1.28 +    return *reinterpret_cast<To **>(*from);
    1.29 +}
    1.30 +
    1.31  template <typename From, typename To> static inline Ke::Local<To>
    1.32  ToLocal(Handle<From> from)
    1.33  {
    1.34 @@ -173,3 +179,16 @@
    1.35  {
    1.36      ZONE()->globalRoots()->decref(FromAPI(root));
    1.37  }
    1.38 +
    1.39 +bool
    1.40 +Ke::Keima::IsInCallStack(Handle<Module> argModule)
    1.41 +{
    1.42 +    ke::Local<ke::Module> module(ke::ZONE(), Open<Ke::Module, ke::Module>(argModule));
    1.43 +    return ZONE()->stack().isInCallStack(module);
    1.44 +}
    1.45 +
    1.46 +void
    1.47 +Ke::Keima::CollectGarbage()
    1.48 +{
    1.49 +    ke::ZONE()->heap().reclaim();
    1.50 +}