;;; -*- Mode:Common-Lisp; Package:Compiler; Base:10; Patch-file:T -*-

;;; Reason: Fix COMPILE-FILE handling of &KEY arguments for object file compatibility with 
;;; previous releases.
;;; Copyright (C) 1989 Texas Instruments Incorporated. All rights reserved.

;;; Written 05/19/89 10:43:16 by GRAY,
;;; while running on Kelvin from band LODA
;;; With SYSTEM 6.1, VIRTUAL-MEMORY 6.0, EH 6.0, MAKE-SYSTEM 6.0, MICRONET 6.0, LOCAL-FILE 6.0,
;;;  BASIC-PATHNAME 6.0, NETWORK-SUPPORT-COLD 6.0, BASIC-NAMESPACE 6.0, NETWORK-NAMESPACE 6.0,
;;;  DISK-IO 6.0, DISK-LABEL 6.0, BASIC-FILE 6.0, MAC-PATHNAME 6.0, NETWORK-PATHNAME 6.0,
;;;  COMPILER 6.0, TV 6.3, DATALINK 6.0, CHAOSNET 6.0, GC 6.0, MEMORY-AUX 6.0, NVRAM 6.0,
;;;  SYSLOG 6.0, STREAMER-TAPE 6.0, UCL 6.0, INPUT-EDITOR 6.0, METER 6.0, ZWEI 6.0,
;;;  DEBUG-TOOLS 6.0, NETWORK-SUPPORT 6.0, NETWORK-SERVICE 6.0, DATALINK-DISPLAYS 6.0,
;;;  FONT-EDITOR 6.0, SERIAL 6.0, PRINTER 6.0, MAC-PRINTER-TYPES 6.0, PRINTER-TYPES 6.0,
;;;  IMAGEN 6.0, SUGGESTIONS 6.0, MAIL-DAEMON 6.1, MAIL-READER 6.0, TELNET 6.0, VT100 6.0,
;;;  NAMESPACE-EDITOR 6.0, PROFILE 6.1, VISIDOC 6.0, TI-CLOS 6.0, CLEH 6.0, IP 3.45,
;;;  Experimental BUG 11.4, Experimental CLX 6.0, Experimental CLUE 21.0, Experimental X11M 4.0,
;;;  Experimental DOCUMENTER 619.0,  microcode 428, Band Name: Rel 6.0 + SLE 5/12

;;; BUG REPORT NUMBER:  [none]
;;;
;;; PROBLEM:  
;;;	With a source file that defines functions with &KEY arguments,
;;;	COMPILE-FILE on 6.0, then LOAD the XLD file on 4.1.  The program
;;;	gets a run-time error when trying to process the keyword
;;;	arguments.  The problem is that although The aux-op used is
;;;	supported by the old microcode, it references a slot in the
;;;	support vector which had not been initialized prior to release 6.
;;;
;;; SOLUTION:
;;;	In the compiler's pass 2 handler for SI:STORE-KEYARGS,
;;;	un-comment the OR form that suppresses the use of the aux-op for
;;;	COMPILE-FILE of customer files.
;;;
;;; DEPENDENCIES: [none]
;;;
;;; CODEREAD:  C.L.M.

#!C
; From file P2HAND.LISP#> COMPILER; MR-X:
#10R COMPILER#:
(COMPILER-LET ((*PACKAGE* (FIND-PACKAGE "COMPILER"))
                          (SI:*LISP-MODE* :COMMON-LISP)
                          (*READTABLE* COMMON-LISP-READTABLE)
                          (SI:*READER-SYMBOL-SUBSTITUTIONS* SYS::*COMMON-LISP-SYMBOL-SUBSTITUTIONS*))
  (COMPILER#:PATCH-SOURCE-FILE "SYS: COMPILER; P2HAND.#"


(DEFUN (:PROPERTY SI:STORE-KEYARGS P2) (ARGL DEST)
  ;;  5/04/89 DNG - Original, added to use aux-op %STORE-KEY-WORD-ARGS.
  ;;  5/19/89 DNG - Don't use the aux-op when compiling to a file so that the 
  ;;		object file can be used on previous releases.
  ;; Note that this optimization must be done in pass 2 because 
  ;; EXTEND-LOCAL-VARIABLES could cause the STORE-KEYARGS to be moved to an 
  ;; internal function after pass 1 has finished.
  (IF (LET ((TM (FIRST ARGL))) ; the plist of actual keys and values
	;; Is it the rest arg of the current FEF?
	(AND (EQ (CAR-SAFE TM) 'LOCAL-REF)
	     (EQ (VAR-KIND (SETQ TM (SECOND TM))) 'FEF-ARG-REST)
	     (EQ (VAR-COMPILAND TM) *CURRENT-COMPILAND*)
	     ;; For release 6, don't use this if generating an object file that might be 
	     ;; loaded on an earlier release.  (The microcode has supported this 
	     ;; since 3.2, but it uses a support vector entry that wasn't initialized 
	     ;; prior to 6.0.)
	     (OR #.(> (TIME:GET-UNIVERSAL-TIME) (TIME:PARSE-UNIVERSAL-TIME "1/1/90")) ; release 7
		 QC-FILE-LOAD-FLAG ; compiling in memory
		 FILE-IN-COLD-LOAD ; a cold band file
		 (AND (ASSOC (PACKAGE-NAME *PACKAGE*) SYS::INITIAL-PACKAGES :TEST #'EQUAL)
		      (NOT (EQ *PACKAGE* *USER-PACKAGE*))) ; not a user package
	     )))
      ;; Can use the microcoded version.
      ;; rest arg is implicit
      (P2F `(%STORE-KEY-WORD-ARGS . ,(CDR ARGL)) DEST)
    ;; Else use Lisp version.
    (P2ARGC NIL ARGL NIL DEST 'SI:STORE-KEYARGS)))

))
