1. 27 Feb, 2020 1 commit
    • Yorick Peterse's avatar
      Use VirtualBox for both Windows and macOS · 1aac792c
      Yorick Peterse authored
      Using Windows containers in Docker has been a painful experience. Slow
      networks, no support for transparent networks due to the host being a
      VPS, building large containers taking forever, the list goes on.
      Meanwhile it costs me roughly €50 per month to keep the Windows CI
      runner online.
      
      Since we already have a Mac Mini at MacStadium (for free), we can just
      re-use that Mac and run Windows inside a VirtualBox VM. This allows us
      to work around the various Docker issues on Windows, and should reduce
      our monthly infrastructure costs to more or less €0 (excluding the €1-2
      I pay to AWS every month).
      
      As part of this we also re-organise the runner tags a bit: the runners
      now use three tags:
      
      1. "inko"
      2. "vbox" (to indicate it's a virtualbox runner)
      3. "macos" or "windows", based on the type of OS
      
      This ensures we don't accidentally pick up a shared runner that just
      uses a "windows" or "macos" tag.
      1aac792c
  2. 23 Feb, 2020 1 commit
    • Yorick Peterse's avatar
      Upgrade the "time" crate to 0.2.x · 5352ec7f
      Yorick Peterse authored
      Version 0.2.x of the "time" crate comes with an API that is quite
      different from version 0.1.x. This commit upgrades Inko to this new AP.
      As version 0.2.x does not support checking if DST is active, support for
      this has been removed. DST support is tricky, as it can vary based on
      where you are, politics (e.g. some countries may drop it), etc.
      
      As part of upgrading to time 0.2.x, some of the internals for obtaining
      timestamps has been changed. In particular, obtaining a timestamp and
      UTC offset has been merged into a single VM instruction. This should
      ensure that no funny business happens when obtaining a timestamp but not
      obtaining the UTC offset until a later point in time. The downside is
      having to allocate an array object, but the overhead of this should be
      minor.
      
      This fixes #188
      5352ec7f
  3. 05 Feb, 2020 1 commit
    • Yorick Peterse's avatar
      Remove type parameters when re-opening objects · d5c10f8b
      Yorick Peterse authored
      When implementing a trait for an object or when re-opening an object,
      the compiler required that you specify the type parameter names of the
      object. For example, to implement the Equal trait for Triple you would
      write:
      
          impl Equal for Triple!(A, B, C) {
            ...
          }
      
      The original idea of this syntax was to make it more clear that type
      parameters used in the body originated from the object, not the trait.
      
      Over time, I realised that this doesn't actually help and in fact makes
      the compiler's life more difficult in a bunch of places. In this commit,
      we remove the need for specifying the type parameters, allowing you to
      write the following instead:
      
          impl Equal for Triple {
            ...
          }
      d5c10f8b
  4. 31 Jan, 2020 1 commit
    • Yorick Peterse's avatar
      Update Cargo files for Rust 1.41 · 4541d246
      Yorick Peterse authored
      Rust 1.41 introduces a new more compact format for Cargo.lock. This
      commit takes advantage of that change, and bumps some crate versions
      while we're at it.
      4541d246
  5. 23 Jan, 2020 1 commit
    • Yorick Peterse's avatar
      First-class modules and remove top-level object · 278a1652
      Yorick Peterse authored
      Modules are now first-class objects in the VM. This allows us to remove
      the top-level object, clean up core::bootstrap, and remove
      core::globals (in favour of using core::bootstrap directly). As part of
      this we also remove Trait.implement(), instead implementing traits using
      compiler generated code. Trait.implement() could not be safely used
      anyway, as it only copied over default methods; without verifying if all
      required methods are implemented.
      
      All of this makes it easier to implement the self-hosting compiler: the
      top-level object no longer needs to be supported, and we can treat
      core::bootstrap like any other module. This in turn allows us to use a
      more efficient way of storing type information in various places.
      278a1652
  6. 22 Jan, 2020 4 commits
    • Yorick Peterse's avatar
      Clean up Nil by splitting it into NilType and Nil · a97f10be
      Yorick Peterse authored
      NilType is now the base object/prototype that Nil is an instance of,
      instead of Nil being a direct instance of Object. This allows us to
      implement traits and redefine methods on the type of Nil (= NilType),
      instead of Nil itself. This in turn allows the compiler to use a more
      efficient way of representing types versus instances.
      
      In type signatures you can still use Nil (or NilType, though Nil is
      preferred), as this signals that you expect or return something
      compatible with Nil, which is only Nil itself.
      a97f10be
    • Yorick Peterse's avatar
      Fixed broken/outdated compiler test · b3e718f6
      Yorick Peterse authored
      b3e718f6
    • Yorick Peterse's avatar
      Restore Boolean "if" instruction cleanup · ddedead0
      Yorick Peterse authored
      By introducing the virtual "if" instruction we can clean up Boolean so
      that we no longer have to refine the True and False instances. If we
      also clean up Nil in a similar way it becomes easier to rewrite the
      compiler in Inko, as it no longer needs to support the refining of
      random objects.
      
      This was originally introduced in
      ecd11a07, but later reverted. In this
      commit we re-introduce these changes. Refining True and False makes
      various compiler internals in the self-hosting compiler less efficient,
      as it has to support refining any object even when this only happens for
      True, False, and Nil. By cleaning up True and False we can reduce this
      down to just Nil, making it easier to find a way of cleaning that up
      too.
      ddedead0
    • Yorick Peterse's avatar
      Don't use shared Windows runners · d30f885c
      Yorick Peterse authored
      With the release of shared Windows runners on GitLab.com, using runners
      with _just_ the "windows" tag results in CI using these shared runners.
      The shared runners don't have the right software installed, and are
      still in beta. To prevent using these, we now also require the runners
      to specify the "inko" tag.
      d30f885c
  7. 11 Jan, 2020 1 commit
    • Yorick Peterse's avatar
      Remove support for constant receivers · f46694ef
      Yorick Peterse authored
      This removes support for syntax such as `A::B` where `A` and `B` are
      constants. Inko has not allowed defining nested types or constants in
      types for a while, and this syntax was only used in a few places to
      bootstrap the runtime. Removing support for this syntax simplifies both
      the parser and compiler quite a bit.
      f46694ef
  8. 07 Jan, 2020 1 commit
  9. 05 Jan, 2020 2 commits
  10. 04 Jan, 2020 1 commit
    • Yorick Peterse's avatar
      Add Array.reverse_iter · f6bf5de0
      Yorick Peterse authored
      The method Array.reverse_iter returns an Iterator that iterates over the
      values in an Array in reverse order.
      f6bf5de0
  11. 02 Jan, 2020 4 commits
    • Yorick Peterse's avatar
      Remove support for extending traits · 4af9354f
      Yorick Peterse authored
      Now that the Ruby compiler defines types using multiple passes, there no
      longer is a need for forward declaring and extending traits. Extending
      traits could also lead to odd behaviour when adding default methods. For
      example:
      
          trait A {}
      
          object Foo {}
      
          impl A for Foo {}
      
          trait A {
            def thing -> Integer {
              10
            }
          }
      
      Here type "Foo" would not have access to method "thing", because it is
      added after "A" is implemented for "Foo".
      
      Removing support for this entirely solves this problem, and we no longer
      need it anyway.
      4af9354f
    • Yorick Peterse's avatar
      Remove forward trait declaration from std::net::ip · 9f152024
      Yorick Peterse authored
      This is no longer needed now that the Ruby compiler defines types in
      multiple passes.
      9f152024
    • Yorick Peterse's avatar
      Rename a few AST nodes to use the pattern DefineX · 679ccf7b
      Yorick Peterse authored
      This ensures all these nodes use the same naming pattern
      (DefineAttribute, DefineMethod, etc), instead of sometimes being called
      DefineX while other times being called XDefinition.
      679ccf7b
    • Yorick Peterse's avatar
      Support circular types in the Ruby compiler · 81a8fd1e
      Yorick Peterse authored
      This adds very basic (and super hacky) support for circular types to the
      Ruby compiler, which should be _just_ enough to allow us to continue
      work on the self-hosting compiler. Circular types can arise as follows:
      
          object TypeParameter {
            @required_traits: Array!(TraitType)
          }
      
          object TraitType {
            @type_parameters: Array!(TypeParameter)
          }
      
      Without support for circular types code like this won't compile.
      
      The changes needed to make this work are a total hack, and in some cases
      will lead to some duplicate work being done (with the results being
      discarded). Since this code will only stick around briefly, this is fine
      for now.
      81a8fd1e
  12. 01 Jan, 2020 1 commit
    • Yorick Peterse's avatar
      Allow hashing of any object · def89e1f
      Yorick Peterse authored
      This was technically already supported, but would trigger a panic for
      non-permanent objects. By allowing the hashing of any object we simplify
      the API, and make it easier to hash complex objects without having to
      manually implement the Hash trait for such structures.
      def89e1f
  13. 30 Dec, 2019 2 commits
  14. 27 Dec, 2019 2 commits
    • Yorick Peterse's avatar
      Revert Boolean and Nil cleanup · 22328acc
      Yorick Peterse authored
      I thought this would make the self-hosting compiler easier to implement,
      but it turns out this may not be the case. If we use two objects per
      type (one for the "class" and one for the instance), then yes it will
      clean things up. But this two object approach complicates the compiler
      in various other places. Balancing the two, I prefer being able to
      refine random objects as this means fewer VM changes are needed for for
      example Boolean and Nil.
      22328acc
    • Yorick Peterse's avatar
      Split Nil into Nil and NilType · 8f9109a4
      Yorick Peterse authored
      Nil is still the singleton instance, but its prototype is set to NilType
      instead of Object. By splitting Nil this way we no longer refine
      instances of ad-hoc instances, instead only refining objects defined
      directly using the `object` keyword.
      8f9109a4
  15. 26 Dec, 2019 1 commit
    • Yorick Peterse's avatar
      Clean up Boolean using an "if" instruction · ecd11a07
      Yorick Peterse authored
      By introducing the virtual "if" instruction we can clean up Boolean so
      that we no longer have to refine the True and False instances. If we
      also clean up Nil in a similar way it becomes easier to rewrite the
      compiler in Inko, as it no longer needs to support the refining of
      random objects.
      ecd11a07
  16. 22 Dec, 2019 3 commits
  17. 20 Dec, 2019 5 commits
  18. 19 Dec, 2019 1 commit
    • Yorick Peterse's avatar
      Add String.slice_bytes() and String.split() · a65c52d0
      Yorick Peterse authored
      String.slice_bytes() can be used to slice a String into a ByteArray,
      similar to String.slice():
      
          'foo'.slice_bytes(start: 0, length: 2).to_string # => 'fo'
      
      String.split() can be used to split a string into an Array of
      substrings:
      
          'foo/bar/baz'.split('/') # => Array.new('foo', 'bar', 'baz')
      a65c52d0
  19. 18 Dec, 2019 1 commit
    • Yorick Peterse's avatar
      Change Process.identifier to return an Integer · 510e6d0c
      Yorick Peterse authored
      Ever since Integer.format has been introduced there no longer is a
      reason to have the VM format the identifier as a string. Using an
      integer also saves a heap allocation for cases where we don't need/want
      a string.
      510e6d0c
  20. 17 Dec, 2019 1 commit
    • Yorick Peterse's avatar
      Refactor std::mirror · d3841771
      Yorick Peterse authored
      This is a pretty big refactor of std::mirror to make it entirely
      optional. As part of this std::format has been refactored as well, and
      all implementations of the Inspect trait (now called Format) have been
      moved into std::mirror.
      
      Formatting objects is now part of std::mirror as that's where it
      belongs, since the output is often based on the internal representation
      of an object. The new API for pretty printing objects is a bit more
      verbose, but not that much:
      
          import std::mirror
      
          10.mirror.inspect # => '10'
      
      All of this means that the only module currently using std::module is
      std::test::assert, which needs std::mirror to produce useful test
      failures. Other code that previously used "inspect" has been refactored
      to no longer depend on it.
      d3841771
  21. 16 Dec, 2019 1 commit
    • Yorick Peterse's avatar
      Remove CallFrame.to_string · b59f2f72
      Yorick Peterse authored
      The desired string format for a CallFrame may differ between
      applications using it. Inko itself does not use CallFrame.to_string
      either, so let's just get rid of it.
      b59f2f72
  22. 11 Dec, 2019 1 commit
    • Yorick Peterse's avatar
      Add ByteArray to the prelude · e10bee15
      Yorick Peterse authored
      The compiler needs support for circular types (e.g. A depending on B and
      B depending on A). The way ByteArray was set up in std::byte_array meant
      this could not be done with multiple passes, as the assignment of the
      `ByteArray` constant would require full type-inference too early in the
      compilation process. Moving ByteArray to the prelude and setting it up
      while bootstrapping simplifies this, and makes it easier for the user to
      use byte arrays.
      e10bee15
  23. 07 Dec, 2019 1 commit
    • Yorick Peterse's avatar
      Rename Void to Never · 7a990558
      Yorick Peterse authored
      Void is confusing as in C it's used for void* pointers, which are more
      akin to dynamically typed pointers. The name Never more clearly
      indicates that something (e.g. returning) will never happen.
      7a990558
  24. 03 Dec, 2019 2 commits