Git Product home page Git Product logo

Comments (6)

aantron avatar aantron commented on June 12, 2024

It looks like identifier is simply the value of the point's index i. It's just a way to get the index of a code point, given only the point_definition record, without doing a search in the points list. So, the answer to

what is the corresponding code point? Is it the one with identifier i or the one at index i in the list of code points?

is "both."

The naming of the field is confusing though, and the comment is not very helpful. We should fix that.

As for the type definitions, I agree it would make it clearer to understand what is really going on. Both the runtime data and the code point lists (i.e. .cmp files) could use clear type definitions. I'll submit a PR – unless you would like to :)

from bisect_ppx.

lindig avatar lindig commented on June 12, 2024

Thanks for the clarification. I haven't looked at this but I would try to get rid of this redundancy by removing the identifier field as there is the danger of inconsistencies. I'm currently working towards a more abstract interface to the runtime system but it has some parts that you are probably not going to be interested in: I want line numbers for each point. It looks like this and does not rely on array indices as they entire structure is tree shaped.

module SM: Map.S with type key = string

exception Error of string

type point = (** a code point in a source file *)
  { line:         int           (** line number *)
  ; offset:       int           (** byte offset from start *)
  ; kind:         Bisect.Common.point_kind  (** kind of point *)
  ; count:        int           (** number of hits *)
  }

type file = (** a file with coverage analysis *)
  { digest:       string        (** cryptographic hash of content *)
  ; linecount:    int           (** number of lines *)
  ; points:       point array   (** points that were covered *)
  }

type t = file SM.t              (** a collection of files *)

val read: string -> string list -> t

The read function takes the prefix directory and a list of *.out files and builds a map that for each file has all the points and the number of hits.

from bisect_ppx.

aantron avatar aantron commented on June 12, 2024

The interface looks good in principle – not sure if you are still working on it. Line numbers may be fine if they simplify some useful processing, which is, I'm sure, why you're adding them. The existing offsets are weird, but I guess they are useful to how the HTML reporter works right now.

How would your desire to add line numbers be affected by storing the source code and point info together in the .out files?

from bisect_ppx.

lindig avatar lindig commented on June 12, 2024

The reason why I want to support line numbers is that this is what editors and users understand best for navigating to a point. I've implemented them by scanning the source code and remembering all offsets of the newlines in the file. Given an offset, I can then find the corresponding line. Column numbers are difficult to support because they depend on the interpretation of tab characters.

If the source code is part of an out file, I could a compute line number from an offset later - so they would not have to be part of a point (although they are convenient and compact).

from bisect_ppx.

aantron avatar aantron commented on June 12, 2024

by scanning the source code and remembering all offsets of the newlines in the file.

I think you could also take line numbers from locations while instrumenting. This function and its caller would have to be modified to take a location.

from bisect_ppx.

aantron avatar aantron commented on June 12, 2024

Closing this for now, see #111 (comment). Please comment if this is still needed. The type is now here:

type point_definition = {
offset : int; (** Point offset, relative to file beginning. *)
identifier : int; (** Point identifier, unique in file. *)
}

It should be easy to add line numbers.

from bisect_ppx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.