home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / msysjour / vol04 / 02b / project / act / install.act < prev    next >
Text File  |  1988-08-21  |  4KB  |  140 lines

  1. /* install.act          --utilities to be used in the seal off process
  2.  
  3.  revision history:
  4.         
  5.         02/01/88 mas    -removeCompiler, removeNames, removeGlobals defined
  6.                         -cleanup redefined to not print to the display
  7.         03/16/88 mas    -added the Object:fail method to prevent hanging
  8.                          if a message is not understood.  
  9.         07/12/88 mzu    -added the Object:error method to prevent hanging
  10.                          on untrapped high level errors.
  11.         07/21/88 acr    -added the Object:primError method to prevent hanging
  12.                          on untrapped prim errors.                            */
  13.  
  14. /* include an error handling routine to trap attempted execution of a 
  15.    non-existent method.  The errorBox, asString, class and other
  16.    related methods must also exist.
  17.  */
  18.  
  19. now(Object)!!
  20.  
  21. /* This method is executed any time a 
  22.   late-bound message is not understood. */
  23. Def fail(self, stackTop, selector)
  24. { errorBox("Method not in system",
  25.     "<a " + asString(class(self)) + 
  26.     "> does not understand " +
  27.     asString(selector));
  28.   abort(TheApp:late);
  29. }
  30. !!
  31.  
  32. /* All high-level errors are handled via this 
  33.   method.  The first parameter should be stackTop(), 
  34.   which gives a pointer to the activation of the 
  35.   caller.  The second parameter is a symbol that 
  36.   describes the error.  If the symbol is defined as 
  37.   an integer constant, the value is taken to be the 
  38.   ID of an error string.  Executes abort (never 
  39.   returns). 
  40.   
  41.   runtime version -- don't print a message or invoke debugger!
  42.   mzu 07/12/88 
  43. */
  44. Def error(self, stackTop, sym | str)
  45.   if not(str := errorString(sym))
  46.     then str := loadString(343) + sym;
  47.   endif;
  48.   
  49.   errorBox("Fatal runtime error", str);
  50.   abort(TheApp:late);
  51. !!
  52.  
  53. /* All primitive errors are handled 
  54.    through this method.  The second 
  55.    parameter is the primitive error number, 
  56.    which corresponds to an error string ID 
  57.    in the resource file.
  58.    
  59.    runtime version -- don't print a message or invoke debugger!
  60. */
  61. Def primError(self, stacktop, id | str)
  62. {
  63.    if not(str := loadString(id))
  64.       then str := loadString(343) + asString(id);
  65.    endif;
  66.    
  67.    errorBox("Fatal runtime primitive error", str);
  68.    abort(TheApp:late);
  69. }
  70. !!
  71.  
  72. now(Behavior)!!
  73. Def removeMethods(self, coll)
  74. {       do(coll, {using(sym) 
  75.         if methods[sym] 
  76.               print(self); 
  77.               print(":");
  78.               print(remove(methods, sym));
  79.               eol(ThePort); 
  80.         endif;});
  81. }!!
  82.  
  83. now(Symbol)!!
  84. Def removeGlobal(self)
  85. { if assocAt(Actor,self)
  86.   then print(self); 
  87.     Actor[self] := nil;
  88.     remove(Actor,self);
  89.     print(" removed."); eol(ThePort);
  90.   endif;
  91. }!!
  92.  
  93. now(Object)!!
  94.  
  95. /* to avoid errors */
  96. Def removeMethods(self, dummy)
  97. {
  98. }!!
  99.  
  100. Def removeNames(self)
  101. { classesDo(Actor,
  102.          { using(cl) cl.name := nil;
  103.            class(cl).name := nil;
  104.   });
  105. }!!
  106.  
  107.  
  108. Def removeCompiler(self)
  109. { do( #(
  110. Lex Lex1 CurrentParser Parser Loader Analyzer 
  111. ActorAnalyzer YaccMachine ActorParser
  112. ParseNode InfixNode EmptyList ListNode BlockNode RPN ImmedFunction
  113. IfNode IfElseNode LoopNode RetNode MsgNode CallNode
  114. CompileState Compiler IvChain AssgnNode IdNode 
  115. WCalls WTraps Functions CVars
  116. InfixOps EarlyMethods SpecialMethods KeyWords
  117. Constants SourceFile Source
  118. CStream CompileBuf LoadBuf BlockTemps Demos 
  119. Bug Context Debugger ActorApp
  120. ), {using(name)  removeGlobal(name) });
  121. }!!
  122.  
  123. now(File)!!
  124. /* redefine cleanup to NOT output to the display */
  125. Def cleanup(self | str)
  126. { initCache();
  127.   str := new(String, 24);
  128.   Call GetTempFileName(0,
  129.     asciiz("ACT"), 0, str);
  130.   setName(self, removeNulls(str));
  131.   create(self);
  132.   checkError(self);
  133.   gc(self);
  134.   delete(self);
  135. }
  136. !!
  137.  
  138.