;;; -*- mode:lisp;package:user;base:10.;fonts:(cptfontb) -*- 
;;;
;;;$Header: /ct/interp/diangraf.l,v 1.3 84/01/30 23:41:46 mark Exp $
;;;
;;;$Log:	/ct/interp/diangraf.l,v $
;;;Revision 1.3  84/01/30  23:41:46  mark
;;;Fixed bug in previous fix such that it does load dianatts
;;;and dianods {to get two macro definitions that ARE needed}
;;;but it still doesn't normally have to RE-load them since they
;;;are the same whether in diana_debugging mode or not.  This and
;;;the previous revision should be considered a single correction.
;;;
;;;Revision 1.2  84/01/30  21:02:31  mark
;;;Changed it to stop needlessly reloading dianatts and dianods,
;;;since it doesn't actually need them at all.
;;;Also brought the comments up to date.
;;;
;;;Revision 1.1  84/01/13  06:20:42  mark
;;;Initial revision
;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;                           DIANGRAF                               ;;;
;;; Mark Miller                                            12-Jan-84 ;;;
;;;                                                                  ;;;
;;; This defines a single function that is needed only at compile-   ;;;
;;; time in compiling DIANAPOS.  It computes the "graph" of attrib-  ;;;
;;; ute conflicts in the format needed by the graph coloring algor-  ;;;
;;; ithm.  The reason for defining it in its own file is so that it  ;;;
;;; can run compiled at compile-time.  This will no longer be needed ;;;
;;; in the planned future Symbolics Release whereby the compiler can ;;;
;;; be enterred recursively.  Meanwhile, it results in a dramatic    ;;;
;;; speedup when recompiling dianapos, which is to say, whenever     ;;;
;;; the attribute positions must be reassigned due to a change in    ;;;
;;; dianods or dianatts.  Does not depend on diana_debugging at all. ;;;
;;;                                                                  ;;;
;;; This file is part of a proprietary software project.  Source     ;;;
;;; code and documentation describing implementation details are     ;;;
;;; available on a confidential, non-disclosure basis only.  These   ;;;
;;; materials, including this file in particular, are trade secrets  ;;;
;;; of Computer * Thought Corporation.                               ;;;
;;;                                                                  ;;;
;;; (c) Copyright 1982 and 1983,  Computer * Thought Corporation.    ;;;
;;;     All Rights Reserved.                                         ;;;
;;;                                                                  ;;;
;;; Reference materials:                                             ;;;
;;;   Miller, December 1983.  The CTAda Diana Users Manual (online). ;;;
;;;   Ambler & Trawick, Chatin's Graph Coloring Algorithm as a       ;;;
;;;     Method for Assigning Positions to Diana Attributes.          ;;;
;;;     SIGPLAN NOTICES, V18, #2, February 1983.                     ;;;
;;;   Robertson & Miller, 1982.  The C*T Diana Virtual Machine.      ;;;
;;;   Foderaro and Sklower, The FRANZ LISP Manual, September 1981.   ;;;
;;;   Weinreb and Moon, LISP MACHINE MANUAL, Symbolics, July 1981.   ;;;
;;;   Charniak et al., 1980.  Artificial Intelligence Programming.   ;;;
;;;   Miller, 1982.  The C*T Ada Tutor: Guide to the Implementation. ;;;
;;;   Tartan Labs, 1982.  The Diana Reference Manual.                ;;;
;;; The following code assumes familiarity with these materials.     ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;		   Dependencies on External Files                    ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(comment assumes ctload and filemap)

(eval-when (compile load eval) (ct_load 'aip)
			       (ct_load 'compat)
			       (ct_load 'charmac)
			       (ct_load 'dianatts)
			       (ct_load 'dianods))

(declare (ct_includef 'intrpdcl))	  ;Uses *diana_xxx* specials.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;   Constructing Graph of Attribute Conflicts for Nodetype Slots   ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun diana_compute_conflicts_graph ()
       ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;; This function is needed at compile-time to compile dianapos.
  ;;; It is not used at run-time.  Since it runs very slowly interpreted,
  ;;; it has been moved to a separate file so that it may be compiled and
  ;;; yet not loaded at runtime.
    (let ((graph nil))
      (mapc
	#'(lambda (x)
	    (cond
	      ((not (diana_attribute_universalp x))
	       (let ((conflicts-list nil))
		 (mapc
		   #'(lambda (n)
		       (let ((conflicts1 (diana_contingent_attributes n)))
			 (cond
			   ((memq x conflicts1)
			    (mapc #'(lambda (a)
				      (or (eq a x)
					  (memq a conflicts-list)
					  (setq conflicts-list
						(cons a conflicts-list))))
				  conflicts1)))))
		   *diana_nodetypes*)
		 (setq graph (cons (list x conflicts-list) graph))))))
	*diana_attributes*)
      graph))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;				  eof                                ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
