Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: don't manage blittable types #1407

Merged
merged 15 commits into from
Apr 4, 2022
Merged

Commits on Nov 29, 2021

  1. feat: add box templates and box type

    This commit adds an implementation of Boxes, memory manged heap
    allocated values.
    
    Boxes are implemented as C pointers, with no additional structure but
    are treated as structs in Carp. To facilitate this, we need to add them
    as a clause to our special type emissions (TypesToC) as they'd otherwise
    be emitted like other struct types.
    
    Co-authored-by: Veit Heller <[email protected]>
    scolsen and hellerve committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    d23977b View commit details
    Browse the repository at this point in the history
  2. fix: slight memory management fix for Box

    Make sure we free the box!
    scolsen committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    5c6839d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    33c99e0 View commit details
    Browse the repository at this point in the history
  4. Revert "fix: Ignore clang nitpick"

    This reverts commit 70ec6d4.
    eriksvedang authored and scolsen committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    7149afd View commit details
    Browse the repository at this point in the history
  5. fix: update example/functor.carp

    Now that a builtin type named Box exists, the definitions in this file
    cause a conflict. I've renamed the "Box" type in the functor example to
    remove the conflict.
    scolsen committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    082cfab View commit details
    Browse the repository at this point in the history
  6. feat: add Box.peek

    Box.peek allows users to transform a reference to a box into a a
    reference to the box's contained value. The returned reference will have
    the same lifetime as the box. This function allows callers to manipulate
    the value in a box without re-allocation, for example:
    
    ```clojure
    (deftype Num [val Int])
    
    (let-do [box (Box.init (Num.init 0))]
      (Num.set-val! (Box.peek &box) 1)
      @(Num.val (Box.peek &box)))
    ```
    
    This commit also includes tests for Box.peek.
    
    Co-authored-by: TimDeve <[email protected]>
    scolsen and TimDeve committed Nov 29, 2021
    Configuration menu
    Copy the full SHA
    7e95f58 View commit details
    Browse the repository at this point in the history

Commits on Dec 8, 2021

  1. Configuration menu
    Copy the full SHA
    50ab32e View commit details
    Browse the repository at this point in the history

Commits on Dec 28, 2021

  1. Configuration menu
    Copy the full SHA
    d52f7a3 View commit details
    Browse the repository at this point in the history

Commits on Mar 7, 2022

  1. Configuration menu
    Copy the full SHA
    215b4fd View commit details
    Browse the repository at this point in the history

Commits on Mar 22, 2022

  1. Configuration menu
    Copy the full SHA
    ee33762 View commit details
    Browse the repository at this point in the history

Commits on Mar 23, 2022

  1. Configuration menu
    Copy the full SHA
    503ead4 View commit details
    Browse the repository at this point in the history

Commits on Mar 28, 2022

  1. Configuration menu
    Copy the full SHA
    5dc22ec View commit details
    Browse the repository at this point in the history

Commits on Apr 1, 2022

  1. Configuration menu
    Copy the full SHA
    44dca8e View commit details
    Browse the repository at this point in the history
  2. feat: don't manage blittable types

    The `blit` interface, when implemented, indicates that a type is freely
    copyable and does not require deletion. It is similar to Rust's Copy
    trait and indicates that a type should have copy instead of "move"
    semantics. This commit updates the memory management system to ignore
    such types, since we do not need to worry about deleting them.
    
    Thus, when using a blittable type, users can freely use a variable of
    the type in more than one place.
    
    This commit also fixes a small typo and adds a TODO to warn users when
    delete and blit are both implemented (as typically one shouldn't need
    delete if a type is truly blittable).
    scolsen committed Apr 1, 2022
    Configuration menu
    Copy the full SHA
    0a34084 View commit details
    Browse the repository at this point in the history
  3. test: check blittable memory behavior in memory.carp

    This commit updates memory.carp to test that types that implement blit
    are freely copyable (have copy instead of move semantics, are not borrow
    checked) and do not cause leaks.
    
    Of course, users can still cause leaks if they define blit on a type
    that isn't actually freely copyable (e.g. it owns some data that is heap
    allocated), but this test checks the basic behavior.
    scolsen committed Apr 1, 2022
    Configuration menu
    Copy the full SHA
    aa93614 View commit details
    Browse the repository at this point in the history