• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
        • Warnings
        • Primitives
        • Use-set
        • Syntax
        • Getting-started
        • Utilities
        • Loader
          • Preprocessor
          • Vl-loadconfig
          • Lexer
          • Vl-loadstate
          • Parser
          • Vl-load-merge-descriptions
          • Scope-of-defines
          • Vl-load-file
          • Vl-flush-out-descriptions
          • Vl-description
          • Vl-loadresult
          • Vl-read-file
          • Vl-find-basename/extension
          • Vl-find-file
          • Vl-read-files
          • Extended-characters
            • Vl-echar-p
            • Vl-location
              • Vl-location-p
              • Vl-location-fix
              • Vl-string-between-locs
              • Vl-location-between-p
              • Vl-string-findloc
                • Vl-string-findloc-aux
              • Vl-location-equiv
              • Make-vl-location
              • Vl-location-string
              • Vl-location->filename
              • Vl-location->line
              • Change-vl-location
              • Vl-location->col
              • *vl-fakeloc*
            • Vl-echarlist->chars
            • Vl-echarlist-from-chars
            • Vl-echarlist-from-str
            • Vl-echarlist-unsigned-value
            • Vl-change-echarlist-locations
            • Vl-echar-digit-value
            • Vl-echarlist->string
          • Vl-load
          • Vl-load-main
          • Vl-load-description
          • Vl-descriptions-left-to-load
          • Inject-warnings
          • Vl-load-descriptions
          • Vl-load-files
          • Vl-load-summary
          • Vl-collect-modules-from-descriptions
          • Vl-descriptionlist
        • Transforms
        • Lint
        • Mlib
        • Server
        • Kit
        • Printer
        • Esim-vl
        • Well-formedness
      • Sv
      • Fgl
      • Vwsim
      • Vl
      • X86isa
      • Svl
      • Rtl
    • Software-verification
    • Math
    • Testing-utilities
  • Vl-location

Vl-string-findloc

Traverse a string to determine the position of a vl-location-p.

Signature
(vl-string-findloc x loc) → offset
Arguments
x — A string, which should contain the full contents of the file indicated by loc. Typically this is gotten from a vl-filemap-p.
    Guard (stringp x).
loc — The location we're looking for.
    Guard (vl-location-p loc).
Returns
offset — The position of this location as an offset into x, or nil if the location is not found, e.g., because it refers to a line/column number that are too large.
    Type (maybe-natp offset).

Definitions and Theorems

Function: vl-string-findloc

(defun vl-string-findloc (x loc)
  (declare (xargs :guard (and (stringp x) (vl-location-p loc))))
  (let ((__function__ 'vl-string-findloc))
    (declare (ignorable __function__))
    (b* ((xl (length (string-fix x)))
         (tline (vl-location->line loc))
         (tcol (vl-location->col loc)))
      (vl-string-findloc-aux x 0 xl 1 0 tline tcol))))

Theorem: maybe-natp-of-vl-string-findloc

(defthm maybe-natp-of-vl-string-findloc
  (b* ((offset (vl-string-findloc x loc)))
    (maybe-natp offset))
  :rule-classes :type-prescription)

Theorem: bounds-of-vl-string-findloc

(defthm bounds-of-vl-string-findloc
  (and (<= 0 (vl-string-findloc x loc))
       (<= (vl-string-findloc x loc)
           (len (explode x))))
  :rule-classes :linear)

Subtopics

Vl-string-findloc-aux