Ejemplo n.º 1
0
static void allslots_command(ostream &out, istream &in)
{
   FrObject *fr ;

   in >> fr ;
   if (fr && fr->symbolp())
      {
      FrFrame *frame = find_vframe((FrSymbol *)fr) ;

      if (frame)
	 {
	 FrList *slots, *s ;
	 
	 slots = frame->collectSlots(get_inheritance_type()) ;
	 out << "The slots and facets which may be inherited by " << fr
	     << " are:" << endl ;
	 for (s = slots ; s ; s = s->rest())
	    out << "   " << s->first()->car() << ": " << s->first()->cdr()
		<< endl ;
	 free_object(slots) ;
	 }
      else
	 out << fr << " is not a frame!" << endl ;
      }
   else
      out << "Usage: ALL-SLOTS <frame>" << endl ;
   free_object(fr) ;
}
Ejemplo n.º 2
0
bool FrSymbol::lockFrames(FrList *locklist)
{
   if (VFrame_Info)
      {
//!!!for now, just do one at a time
      while (locklist)
	 {
	 if (!((FrSymbol*)(locklist->first()))->lockFrame())
	    return false ;	// failed
	 locklist = locklist->rest() ;
	 }
      return true ;	// successful
      }
   else
      {
      while (locklist)
	 {
	 FrFrame *fr = ((FrSymbol*)(locklist->first()))->symbolFrame() ;
	 if (fr)
	    fr->setLock(true) ;
	 locklist = locklist->rest() ;
	 }
      return true ;   // successful
      }
}
Ejemplo n.º 3
0
bool FrSymbol::isLocked() const
{
   FrFrame *fr = find_vframe_inline(this) ;

   if (fr)
      return fr->isLocked() ;
   else if (VFrame_Info)
      return VFrame_Info->isLocked(this) ;
   else
      return false ;
}
Ejemplo n.º 4
0
bool FrSymbol::unlockFrame()
{
   FrFrame *fr = symbolFrame() ;
   // don't use find_vframe above, to avoid pulling in frame if not already
   // in memory

   if (fr && fr->isLocked() && VFrame_Info)
      {
      if (VFrame_Info->unlockFrame(this))
         fr->setLock(false) ;
      else
         return false ;
      }
   return true ;
}
Ejemplo n.º 5
0
FrFrame *FrSymbol::lockFrame()
{
   FrFrame *fr = find_vframe_inline(this) ;

   if (fr && !fr->isLocked() && VFrame_Info)
      {
      if (VFrame_Info->lockFrame(this))
         fr->setLock(true) ;
      else
         {
	 FrWarningVA("unable to lock frame %s",symbolName()) ;
         return 0 ;
         }
      }
   return fr ;
}
Ejemplo n.º 6
0
int FrSymbol::deleteFrame()
{
   FrFrame *fr = symbolFrame() ;
   // don't use find_vframe to avoid pulling in frame if not already in memory

   if (fr)
      {
      fr->markDirty() ;		 // force the frame to be flushed
      if (VFrame_Info)
	 VFrame_Info->deleteFrame(this,true) ;
      delete fr ;
      }
   else if (VFrame_Info && VFrame_Info->isFrame(this))
      VFrame_Info->deleteFrame(this,true) ;
   return 0 ;
}
Ejemplo n.º 7
0
bool import_FrameKit_frames(istream &input,ostream &output)
{
   FrObject *obj ;
   FrFrame *fr ;
   FrSymbol *symbolMAKEFRAME = FrSymbolTable::add(stringMAKEFRAME) ;
   FrSymbol *symbolMAKEFROLD = FrSymbolTable::add(stringMAKEFR_OLD) ;

   if (output)
      output << "Importing frames" << endl ;
   bool oldvirt = read_virtual_frames(true) ;
   if (!VFrame_Info)
      read_virtual_frames(oldvirt) ;
   while (!input.eof())
      {
      input >> obj ;
      if (obj)
	 {
	 if (obj->consp() &&
	     (((FrCons*)obj)->first() == symbolMAKEFRAME ||
	      ((FrCons*)obj)->first() == symbolMAKEFROLD))
	    {
	    fr = FrameKit_to_FramepaC((FrList*)obj) ;
	    if (!fr)
	       {
	       read_virtual_frames(oldvirt) ;
	       return false ;	// error reading stream
	       }
	    if (output)
	       output << stringREAD << fr->frameName() << endl ;
	    }
	 else if (output)
	    {
	    output << stringREAD << obj->objTypeName() << ' ' ;
	    if (obj->framep())
	       output << ((FrFrame*)obj)->frameName() ;
	    else if (obj->consp())
	       output << "(" << obj->car() << " ... )" ;
	    else
	       output << obj ;
	    output << endl ;
	    }
	 obj->freeObject() ;
	 }
      }
   read_virtual_frames(oldvirt) ;
   return true ;
}
Ejemplo n.º 8
0
static void rename_command(ostream &out, istream &in)
{
   FrObject *oldname ;
   FrObject *newname ;
   out << "FrFrame to be renamed: " << flush ;
   in >> oldname ;
   out << "New name for frame: " << flush ;
   in >> newname ;
   if (oldname && oldname->symbolp() && newname && newname->symbolp())
      {
      FrFrame *oldframe = ((FrSymbol*)oldname)->findFrame() ;
      if (!oldframe)
	 out << "The specified frame does not exist!" << endl ;
      else if (oldframe->renameFrame((FrSymbol*)newname))
	 out << "Rename was successful." << endl ;
      else
	 out << "Rename failed!" << endl ;
      }
   else
      out << "Usage: * RENAME <oldname> <newname>  (both symbols)" << endl ;
}
Ejemplo n.º 9
0
static bool discard_dirty_frame(const FrObject *obj, va_list args)
{
   FrVarArg(uint32_t,thres) ;
   FrVarArg(int *,discarded) ;
   FrFrame *frame = ((FrSymbol*)obj)->symbolFrame() ;
   // throw out any and all unlocked virtual frames, even if dirty, that were
   // last used before the threshold value of the clock
   if (frame && frame->isVFrame() && !frame->isLocked() &&
       frame->getLRUclock() < thres)
      {
      if (frame->dirtyFrame())
	 frame->frameName()->commitFrame() ;
      frame->discard() ;	// discard the frame
      (*discarded)++ ;
      }
   return true ;
}
Ejemplo n.º 10
0
static bool discard_clean_frame(const FrObject *obj, va_list args)
{
   FrVarArg(uint32_t,thres) ;
   FrVarArg(int *,discarded) ;
   FrFrame *frame = ((FrSymbol*)obj)->symbolFrame() ;
   // throw out the current frame if it is a clean virtual frame last used
   // before the threshold value of the clock
   if (frame && frame->isVFrame() && !frame->isLocked() &&
       !frame->dirtyFrame() && frame->getLRUclock() < thres)
      {
      frame->discard() ;	// discard the frame
      (*discarded)++ ;
      }
   return true ;
}