• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
      • Fgl
      • Vwsim
      • Vl
        • Syntax
        • Loader
          • Preprocessor
            • Vl-iframe
            • Preprocessor-ifdef-minutia
            • Vl-preprocess
            • Vl-preprocess-loop
            • Vl-includeskips
              • Vl-includeskips-p
              • Vl-includeskips-fix
              • Vl-iskipinfo
              • Vl-match-proper-header-file-start-2
              • Vl-match-proper-header-file-start-1
              • Vl-multiple-include-begin
                • Vl-includeskips-equiv
                • Vl-includeskips-record-miss
                • Vl-includeskips-install-controller
                • Vl-includeskips-record-hit
                • Vl-skip-whitespace/comments
              • Vl-read-until-end-of-define
              • Vl-define-formallist->defaults
              • Vl-define
              • Vl-expand-define
              • Vl-read-include
              • Vl-substitute-into-macro-text
              • Vl-process-ifdef
              • Ppst
              • Vl-read-define-default-text
              • Vl-process-define
              • Preprocessor-include-minutia
              • Vl-trim-for-preproc
              • Vl-line-up-define-formals-and-actuals
              • Vl-process-undef
              • Vl-split-define-text
              • Vl-def-context
              • Vl-process-endif
              • Scan-backward-for-non-whitespace
              • Vl-ifdef-context
              • Scan-backward-for-whitespace
              • Vl-atvl-atts-text
              • Scan-for-non-whitespace
              • Vl-check-remaining-formals-all-have-defaults
              • Vl-process-else
              • Vl-is-compiler-directive-p
              • Vl-includeskips-controller-lookup
              • Vl-ifdef-use-map
              • Vl-defines
              • Vl-def-use-map
              • Vl-nice-bytes
              • Vl-safe-previous-n
              • Vl-safe-next-n
              • Vl-ppst-pad
              • Vl-filename-to-string-literal
              • Vl-maybe-update-filemap
              • *vl-preprocess-clock*
              • Vl-ppst->warnings
              • Vl-ppst->iskips
              • Vl-ppst->ifdefmap
              • Vl-ppst->idcache
              • Vl-istack
              • Vl-ppst->istack
              • Vl-ppst->includes
              • Vl-ppst->filemap
              • Vl-ppst->defmap
              • Vl-ppst->defines
              • Vl-ppst->config
              • Vl-ppst->bytes
              • Vl-ppst->activep
              • Vl-ppst->acc
              • Vl-ppst-record-ifdef-use
              • Vl-ppst-record-def-use
              • Vl-ifdef-context-list
              • Vl-def-context-list
              • Vl-ppst-update-warnings
              • Vl-ppst-update-istack
              • Vl-ppst-update-iskips
              • Vl-ppst-update-includes
              • Vl-ppst-update-ifdefmap
              • Vl-ppst-update-idcache
              • Vl-ppst-update-filemap
              • Vl-ppst-update-defmap
              • Vl-ppst-update-defines
              • Vl-ppst-update-config
              • Vl-ppst-update-activep
              • Vl-ppst-update-bytes
              • Vl-ppst-update-acc
              • Vl-ppst-unsound-nreverse-acc
            • Vl-loadconfig
            • Vl-loadstate
            • Lexer
            • Parser
            • Vl-load-merge-descriptions
            • Vl-find-basename/extension
            • Vl-load-file
            • Vl-loadresult
            • Scope-of-defines
            • Vl-find-file
            • Vl-flush-out-descriptions
            • Vl-description
            • Vl-read-file
            • Vl-includeskips-report-gather
            • Vl-load-main
            • Extended-characters
            • Vl-load
            • Vl-load-description
            • Vl-descriptions-left-to-load
            • Inject-warnings
            • Vl-preprocess-debug
            • Vl-write-preprocessor-debug-file
            • Vl-read-file-report-gather
            • Vl-load-descriptions
            • Vl-load-files
            • Translate-off
            • Vl-load-read-file-hook
            • Vl-read-file-report
            • Vl-loadstate-pad
            • Vl-load-summary
            • Vl-collect-modules-from-descriptions
            • Vl-loadstate->warnings
            • Vl-iskips-report
            • Vl-descriptionlist
          • Warnings
          • Getting-started
          • Utilities
          • Printer
          • Kit
          • Mlib
          • Transforms
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • Vl-includeskips

    Vl-multiple-include-begin

    Check a file for a proper include-guard header; if so, install a special iframe and skip past the initial ifndef part, otherwise leave the file alone.

    Signature
    (vl-multiple-include-begin realfile contents ppst) 
      → 
    (mv new-contents ppst)
    Arguments
    realfile — File name being loaded.
        Guard (stringp realfile).
    contents — Contents of that file.
        Guard (vl-echarlist-p contents).
    Returns
    new-contents — On failure, the unmodified contents. On success, the remainder of the file just past the include guard.
        Type (vl-echarlist-p new-contents).
    ppst — Possibly updated with a special iframe for the include guard.

    Definitions and Theorems

    Function: vl-multiple-include-begin

    (defun vl-multiple-include-begin (realfile contents ppst)
     (declare (xargs :stobjs (ppst)))
     (declare (xargs :guard (and (stringp realfile)
                                 (vl-echarlist-p contents))))
     (let ((__function__ 'vl-multiple-include-begin))
      (declare (ignorable __function__))
      (b*
       ((contents (vl-echarlist-fix contents))
        ((mv controller1 controller1-loc post-ifndef)
         (vl-match-proper-header-file-start-1 contents))
        ((mv controller2 controller2-loc post-else)
         (if controller1 (mv nil nil nil)
           (vl-match-proper-header-file-start-2 contents)))
        (controller (or controller1 controller2))
        (resume-point (if controller1 post-ifndef post-else))
        (controller-loc (if controller1 controller1-loc
                          controller2-loc))
        ((unless controller)
         (let
          ((ppst
            (vl-ppst-warn
             :type :vl-warn-include-guard
             :msg
             "~s0: included file has no include-guard.  (This is ~
                               fine but may reduce performance if the file is ~
                               included multiple times.)"
             :args (list realfile))))
          (mv contents ppst)))
        (prev-def (vl-find-define controller (vl-ppst->defines)))
        ((when prev-def)
         (let
          ((ppst
            (vl-ppst-warn
             :type :vl-warn-include-guard
             :msg
             "~s0: potential include guard controller, ~s1, is ~
                               already defined when reading the file; previous ~
                               definition from ~a2.  This is unusual and will ~
                               defeat multiple-include optimization for this file."
             :args (list realfile
                         controller (vl-define->loc prev-def)))))
          (mv contents ppst)))
        (- (cw-unformatted (cat (vl-ppst-pad)
                                " (multi-include candidate)" *nls*)))
        (iframe (make-vl-iframe :initially-activep t
                                :some-thing-satisfiedp t
                                :already-saw-elsep (not controller1)
                                :mi-controller controller
                                :mi-filename realfile))
        (ppst (vl-ppst-record-ifdef-use
                   controller
                   (make-vl-ifdef-context :loc controller-loc)))
        (istack (vl-ppst->istack))
        (ppst (vl-ppst-update-istack (cons iframe istack))))
       (mv resume-point ppst))))

    Theorem: vl-echarlist-p-of-vl-multiple-include-begin.new-contents

    (defthm vl-echarlist-p-of-vl-multiple-include-begin.new-contents
      (b* (((mv ?new-contents ?ppst)
            (vl-multiple-include-begin realfile contents ppst)))
        (vl-echarlist-p new-contents))
      :rule-classes :rewrite)