From 1b8fe036ad46d18cbeb4fd6cdc0df3ed73a4ff1f Mon Sep 17 00:00:00 2001 From: Marimuthu Madasamy Date: Sun, 2 Jan 2022 05:21:40 -0500 Subject: [PATCH] Build 0.5.1 for JVM --- .github/workflows/ci-idris2.yml | 542 ------------------ .github/workflows/ci-sphinx.yml | 21 - .github/workflows/install.yml | 2 +- .github/workflows/pre-release.yml | 4 +- .github/workflows/release.yml | 6 +- idris-jvm-assembler/pom.xml | 2 +- .../idrisjvm/assembler/AsmGlobalState.java | 3 +- idris-jvm-compiler/pom.xml | 2 +- idris-jvm-compiler/src/assembly/bin.xml | 4 +- idris-jvm-runtime/pom.xml | 2 +- .../idrisjvm/runtime/ChannelIo.java | 1 + .../idrisjvm/runtime/Directories.java | 18 +- .../idrisjvm/runtime/IdrisSocket.java | 4 +- .../idrisjvm/runtime/Runtime.java | 11 + idris-jvm-tests/pom.xml | 2 +- libs/base/System/Errno.idr | 4 + libs/base/System/FFI.idr | 25 +- libs/base/System/File/Buffer.idr | 4 +- libs/base/System/File/Error.idr | 6 + libs/base/System/File/Handle.idr | 6 + libs/base/System/File/Meta.idr | 9 + libs/base/System/File/Permissions.idr | 5 + libs/base/System/File/Process.idr | 7 + libs/base/System/File/ReadWrite.idr | 11 + libs/base/System/File/Virtual.idr | 7 + libs/base/System/Info.idr | 1 + libs/network/Network/Socket/Data.idr | 1 + pom.xml | 3 +- src/Compiler/Jvm/Codegen.idr | 42 +- src/Compiler/Jvm/ExtPrim.idr | 30 +- src/Compiler/Jvm/Foreign.idr | 12 +- src/Compiler/Jvm/Jname.idr | 21 +- src/Compiler/Jvm/Optimizer.idr | 82 +-- src/Core/Binary/Prims.idr | 6 +- src/Core/Primitives.idr | 24 +- src/Idris/ProcessIdr.idr | 1 + tests/idris2/basic053/expected | 2 +- tests/idris2/basic055/BitOps.idr | 14 +- tests/idris2/basic055/expected | 18 +- tests/idris2/coverage018/expected | 6 +- tests/idris2/literate009/input | 2 +- tests/idris2/perror010/expected | 3 +- tests/jvm/jvm012/array.idr | 15 +- 43 files changed, 252 insertions(+), 739 deletions(-) delete mode 100644 .github/workflows/ci-idris2.yml delete mode 100644 .github/workflows/ci-sphinx.yml diff --git a/.github/workflows/ci-idris2.yml b/.github/workflows/ci-idris2.yml deleted file mode 100644 index 050c6e7b5..000000000 --- a/.github/workflows/ci-idris2.yml +++ /dev/null @@ -1,542 +0,0 @@ -name: Idris2 - -on: - push: - branches: - - '*' - tags: - - '*' - paths-ignore: - - 'docs/**' - - 'icons/**' - - 'Release/**' - - '*.md' - - 'CONTRIBUTORS' - - 'LICENSE' - - '.github/workflows/ci-lint.yml' - - '.github/workflows/ci-sphinx.yml' - - '.github/workflows/ci-super-linter.yml' - pull_request: - branches: - - main - paths-ignore: - - 'docs/**' - - 'icons/**' - - '*.md' - - 'CONTRIBUTORS' - - 'LICENSE' - - '.github/workflows/ci-lint.yml' - - '.github/workflows/ci-sphinx.yml' - - '.github/workflows/ci-super-linter.yml' - -env: - IDRIS2_VERSION: 0.4.0 # For previous-version build - -jobs: - - initialise: - runs-on: ubuntu-latest - steps: - - name: Checkout Project - uses: actions/checkout@v2 - with: - # for pull_request so we can do HEAD^2 - fetch-depth: 2 - - - name: Get commit message - id: get_commit_message - run: | - if [[ '${{ github.event_name }}' == 'push' ]]; then - echo ::set-output name=commit_message::$(git log --format=%B -n 1 HEAD) - elif [[ '${{ github.event_name }}' == 'pull_request' ]]; then - echo ::set-output name=commit_message::$(git log --format=%B -n 1 HEAD^2) - fi - - outputs: - commit_message: - echo "${{ steps.get_commit_message.outputs.commit_message }}" - - ###################################################################### - # Build from the previous version - # We perform this check before all the other ones because: - # 1. It is fast - # 2. If it fails then there is no point in trying the rest - ###################################################################### - - quick-check: - needs: initialise - runs-on: ubuntu-latest - if: | - !contains(needs.initialise.outputs.commit_message, '[ci: skip]') - env: - IDRIS2_CG: chez - SCHEME: scheme - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install build dependencies - run: | - echo "deb http://security.ubuntu.com/ubuntu hirsute universe" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - sudo apt-get install -y -t hirsute chezscheme - echo "$HOME/.idris2/bin" >> $GITHUB_PATH - - # Get our hands on the released version either by using the cache - # or by rebuilding it if necessary. - - name: Cache Chez Previous Version - id: previous-version-cache - uses: actions/cache@v2 - with: - path: Idris2-${{ env.IDRIS2_VERSION }} - key: ${{ runner.os }}-idris2-bootstrapped-hirsute-chez-${{ env.IDRIS2_VERSION }} - - name : Build previous version - if: steps.previous-version-cache.outputs.cache-hit != 'true' - run: | - wget https://www.idris-lang.org/idris2-src/idris2-$IDRIS2_VERSION.tgz - tar zxvf idris2-$IDRIS2_VERSION.tgz - cd Idris2-$IDRIS2_VERSION - make bootstrap - cd .. - - name: Install previous version - run: | - cd Idris2-$IDRIS2_VERSION - make install - cd .. - - # Build the current version and save the installation. - - name: Build current version - run: | - make && make install - - name: Artifact Idris2 from previous version - uses: actions/upload-artifact@v2 - with: - name: ubuntu-installed-idris2-${{ env.IDRIS2_VERSION }}-chez - path: ~/.idris2/ - - ###################################################################### - # Bootstrapping builds - ###################################################################### - - # CHEZ - - ubuntu-bootstrap-chez: - needs: quick-check - runs-on: ubuntu-latest - if: | - !contains(needs.initialise.outputs.commit_message, '[ci:') - || contains(needs.initialise.outputs.commit_message, '[ci: ubuntu]') - || contains(needs.initialise.outputs.commit_message, '[ci: chez]') - env: - IDRIS2_CG: chez - SCHEME: scheme - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install build dependencies - run: | - echo "deb http://security.ubuntu.com/ubuntu hirsute universe" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - sudo apt-get install -y -t hirsute chezscheme - echo "$HOME/.idris2/bin" >> $GITHUB_PATH - - name: Make bootstrap folder readonly - run: chmod -R a-w bootstrap - - name: Build from bootstrap - run: make bootstrap && make install - - name: Artifact Bootstrapped Idris2 - uses: actions/upload-artifact@v2 - with: - name: ubuntu-installed-bootstrapped-idris2-chez - path: ~/.idris2/ - - macos-bootstrap-chez: - needs: quick-check - runs-on: macos-latest - if: | - !contains(needs.initialise.outputs.commit_message, '[ci:') - || contains(needs.initialise.outputs.commit_message, '[ci: macos]') - || contains(needs.initialise.outputs.commit_message, '[ci: chez]') - env: - SCHEME: chez - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install build dependencies - run: | - brew install chezscheme - brew install coreutils - echo "$HOME/.idris2/bin" >> $GITHUB_PATH - - name: Make bootstrap folder readonly - run: chmod -R a-w bootstrap - - name: Build Idris 2 from bootstrap - run: make bootstrap && make install - shell: bash - - name: Artifact Bootstrapped Idris2 - uses: actions/upload-artifact@v2 - with: - name: macos-installed-bootstrapped-idris2-chez - path: ~/.idris2/ - - windows-bootstrap-chez: - needs: quick-check - runs-on: windows-latest - if: | - !contains(needs.initialise.outputs.commit_message, '[ci:') - || contains(needs.initialise.outputs.commit_message, '[ci: windows]') - || contains(needs.initialise.outputs.commit_message, '[ci: chez]') - || contains(needs.initialise.outputs.commit_message, '[ci: racket]') - env: - MSYSTEM: MINGW64 - MSYS2_PATH_TYPE: inherit - SCHEME: scheme - CC: gcc - steps: - - name: Init - run: | - git config --global core.autocrlf false - - name: Checkout - uses: actions/checkout@v2 - - name: Get Chez Scheme - run: | - git clone --depth 1 https://github.com/cisco/ChezScheme - c:\msys64\usr\bin\bash -l -c "pacman -S --noconfirm tar make" - echo "PWD=$(c:\msys64\usr\bin\cygpath -u $(pwd))" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Configure and Build Chez Scheme - run: | - c:\msys64\usr\bin\bash -l -c "cd $env:PWD && cd ChezScheme && ./configure --threads && make" - - name: Set Path - run: | - $chez="$(pwd)\ChezScheme\ta6nt\bin\ta6nt" - $idris="$(pwd)\.idris2" - echo "$chez" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "$idris\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "IDRIS_PREFIX=$idris" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "PREFIX=$(c:\msys64\usr\bin\cygpath -u $idris)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Test Scheme - run: | - scheme --version - - name: Bootstrap - run: c:\msys64\usr\bin\bash -l -c "cd $env:PWD && make bootstrap" - - name: Bootstrap test - run: c:\msys64\usr\bin\bash -l -c "cd $env:PWD && make bootstrap-test" - - name: Install - run: c:\msys64\usr\bin\bash -l -c "cd $env:PWD && make install" - - name: Artifact Idris2 from chez - uses: actions/upload-artifact@v2 - with: - name: windows-installed-bootstrapped-idris2-chez - path: ${{ env.IDRIS_PREFIX }} - - nix-bootstrap-chez: - needs: quick-check - runs-on: ubuntu-latest - if: | - !contains(needs.initialise.outputs.commit_message, '[ci:') - || contains(needs.initialise.outputs.commit_message, '[ci: nix]') - || contains(needs.initialise.outputs.commit_message, '[ci: chez]') - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - uses: cachix/install-nix-action@v12 - with: - install_url: https://github.com/numtide/nix-flakes-installer/releases/download/nix-2.4pre20210126_f15f0b8/install - - run: nix-build -A checks.x86_64-linux - - # RACKET - - ubuntu-bootstrap-racket: - needs: quick-check - runs-on: ubuntu-latest - if: | - !contains(needs.initialise.outputs.commit_message, '[ci:') - || contains(needs.initialise.outputs.commit_message, '[ci: ubuntu]') - || contains(needs.initialise.outputs.commit_message, '[ci: racket]') - - env: - IDRIS2_CG: racket - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Install build dependencies - run: | - sudo apt-get install -y racket - echo "$HOME/.idris2/bin" >> $GITHUB_PATH - - name: Make bootstrap folder readonly - run: chmod -R a-w bootstrap - - name: Build from bootstrap - run: make bootstrap-racket && make install - - name: Artifact Bootstrapped Idris2 - uses: actions/upload-artifact@v2 - with: - name: ubuntu-installed-bootstrapped-idris2-racket - path: ~/.idris2/ - - ###################################################################### - # Self-hosting builds and testing - ###################################################################### - - # CHEZ - - ubuntu-self-host-chez: - needs: ubuntu-bootstrap-chez - runs-on: ubuntu-latest - env: - IDRIS2_CG: chez - SCHEME: scheme - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Download Idris2 Artifact - uses: actions/download-artifact@v2 - with: - name: ubuntu-installed-bootstrapped-idris2-chez - path: ~/.idris2/ - - name: Install build dependencies - run: | - echo "deb http://security.ubuntu.com/ubuntu hirsute universe" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - sudo apt-get install -y -t hirsute chezscheme - echo "$HOME/.idris2/bin" >> $GITHUB_PATH - chmod +x $HOME/.idris2/bin/idris2 $HOME/.idris2/bin/idris2_app/* - - name: Build self-hosted - run: make all IDRIS2_BOOT="idris2 -Werror" && make install - - name: Test self-hosted - run: make test INTERACTIVE='' - - macos-self-host-chez: - needs: macos-bootstrap-chez - runs-on: macos-latest - env: - SCHEME: chez - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Download Idris2 Artifact - uses: actions/download-artifact@v2 - with: - name: macos-installed-bootstrapped-idris2-chez - path: ~/.idris2/ - - name: Install build dependencies - run: | - brew install chezscheme - brew install coreutils - echo "$HOME/.idris2/bin" >> $GITHUB_PATH - chmod +x $HOME/.idris2/bin/idris2 $HOME/.idris2/bin/idris2_app/* - - name: Build self-hosted - run: make all IDRIS2_BOOT="idris2 -Werror" && make install - shell: bash - - name: Test self-hosted - run: make test INTERACTIVE='' - shell: bash - - # RACKET - - ubuntu-self-host-racket: - needs: ubuntu-bootstrap-racket - runs-on: ubuntu-latest - env: - IDRIS2_CG: racket - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Download Idris2 Artifact - uses: actions/download-artifact@v2 - with: - name: ubuntu-installed-bootstrapped-idris2-racket - path: ~/.idris2/ - - name: Install build dependencies - run: | - sudo apt-get install -y racket - echo "$HOME/.idris2/bin" >> $GITHUB_PATH - chmod +x $HOME/.idris2/bin/idris2 $HOME/.idris2/bin/idris2_app/* - - name: Build self-hosted - run: make all IDRIS2_BOOT="idris2 -Werror" && make install - - name: Test self-hosted - run: make test INTERACTIVE='' - - ubuntu-self-host-previous-version: - needs: quick-check - runs-on: ubuntu-latest - if: | - !contains(needs.initialise.outputs.commit_message, '[ci:') - || contains(needs.initialise.outputs.commit_message, '[ci: ubuntu]') - || contains(needs.initialise.outputs.commit_message, '[ci: libs]') - env: - IDRIS2_CG: chez - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Download Idris2 Artifact - uses: actions/download-artifact@v2 - with: - name: ubuntu-installed-idris2-${{ env.IDRIS2_VERSION }}-chez - path: ~/.idris2/ - - name: Install build dependencies - run: | - echo "deb http://security.ubuntu.com/ubuntu hirsute universe" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - sudo apt-get install -y -t hirsute chezscheme - echo "$HOME/.idris2/bin" >> $GITHUB_PATH - chmod +x $HOME/.idris2/bin/idris2 $HOME/.idris2/bin/idris2_app/* - - name: Build self-hosted from previous version - run: make all IDRIS2_BOOT="idris2 -Werror" && make install - - name: Test self-hosted from previous version - run: make test INTERACTIVE='' - - name: Artifact Idris2 - uses: actions/upload-artifact@v2 - with: - name: idris2-nightly-chez - path: ~/.idris2/ - - windows-self-host-racket: - needs: windows-bootstrap-chez - runs-on: windows-latest - if: | - !contains(needs.initialise.outputs.commit_message, '[ci:') - || contains(needs.initialise.outputs.commit_message, '[ci: windows]') - || contains(needs.initialise.outputs.commit_message, '[ci: racket]') - env: - IDRIS2_CG: racket - MSYSTEM: MINGW64 - MSYS2_PATH_TYPE: inherit - CC: gcc - RACKET_RACO: raco - steps: - - name: Init - run: | - git config --global core.autocrlf false - echo "PWD=$(c:\msys64\usr\bin\cygpath -u $(pwd))" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Checkout - uses: actions/checkout@v2 - - name: Get Chez Scheme - run: | - git clone --depth 1 https://github.com/cisco/ChezScheme - c:\msys64\usr\bin\bash -l -c "pacman -S --noconfirm tar make" - echo "PWD=$(c:\msys64\usr\bin\cygpath -u $(pwd))" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Configure and Build Chez Scheme - run: | - c:\msys64\usr\bin\bash -l -c "cd $env:PWD && cd ChezScheme && ./configure --threads && make" - - name: Set Path - run: | - $chez="$(pwd)\ChezScheme\ta6nt\bin\ta6nt" - $idris="$(pwd)\.idris2" - echo "$chez" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "$idris\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - echo "IDRIS_PREFIX=$idris" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - echo "PREFIX=$(c:\msys64\usr\bin\cygpath -u $idris)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append - - name: Download Idris2 Artifact - uses: actions/download-artifact@v2 - with: - name: windows-installed-bootstrapped-idris2-chez - path: ${{ env.IDRIS_PREFIX }} - - name: Install build dependencies - uses: Bogdanp/setup-racket@v1.4 - with: - variant: 'CS' - version: 'stable' - distribution: 'full' - - name: Self host - run: | - c:\msys64\usr\bin\bash -l -c "cd $env:PWD && make" - # TODO: fix the broken tests! - # - name: Test - # run: c:\msys64\usr\bin\bash -l -c "cd $env:PWD && make test" - - name: Install - run: c:\msys64\usr\bin\bash -l -c "cd $env:PWD && make install" - - ###################################################################### - # Ubuntu API - ###################################################################### - - ubuntu-build-api: - needs: ubuntu-bootstrap-chez - runs-on: ubuntu-latest - env: - IDRIS2_CG: chez - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Download Idris2 Artifact - uses: actions/download-artifact@v2 - with: - name: ubuntu-installed-bootstrapped-idris2-chez - path: ~/.idris2/ - - name: Install build dependencies - run: | - echo "deb http://security.ubuntu.com/ubuntu hirsute universe" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - sudo apt-get install -y -t hirsute chezscheme - echo "$HOME/.idris2/bin" >> $GITHUB_PATH - chmod +x $HOME/.idris2/bin/idris2 $HOME/.idris2/bin/idris2_app/* - - name: Build API - run: make install-api - shell: bash - - name: Test API - run: cd tests/idris2/api001 && ./run idris2 - shell: bash - - ###################################################################### - # Ubuntu testing some libraries. - # We are particularly interested in libraries that are heavily using - # dependent types, that are prone to find bugs and regressions in the - # compiler. - ###################################################################### - - ubuntu-test-collie: - needs: ubuntu-self-host-previous-version - runs-on: ubuntu-latest - if: | - !contains(needs.initialise.outputs.commit_message, '[ci:') - || contains(needs.initialise.outputs.commit_message, '[ci: libs]') - env: - IDRIS2_CG: chez - steps: - - name: Download Idris2 Artifact - uses: actions/download-artifact@v2 - with: - name: idris2-nightly-chez - path: ~/.idris2/ - - name: Install build dependencies - run: | - echo "deb http://security.ubuntu.com/ubuntu hirsute universe" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - sudo apt-get install -y -t hirsute chezscheme - echo "$HOME/.idris2/bin" >> $GITHUB_PATH - chmod +x $HOME/.idris2/bin/idris2 $HOME/.idris2/bin/idris2_app/* - - name: Checkout - uses: actions/checkout@v2 - with: - repository: 'ohad/collie' - - name: Build Collie - run: | - make - - ubuntu-test-frex: - needs: ubuntu-self-host-previous-version - runs-on: ubuntu-latest - if: | - !contains(needs.initialise.outputs.commit_message, '[ci:') - || contains(needs.initialise.outputs.commit_message, '[ci: libs]') - env: - IDRIS2_CG: chez - steps: - - name: Download Idris2 Artifact - uses: actions/download-artifact@v2 - with: - name: idris2-nightly-chez - path: ~/.idris2/ - - name: Install build dependencies - run: | - echo "deb http://security.ubuntu.com/ubuntu hirsute universe" | sudo tee -a /etc/apt/sources.list - sudo apt-get update - sudo apt-get install -y -t hirsute chezscheme - echo "$HOME/.idris2/bin" >> $GITHUB_PATH - chmod +x $HOME/.idris2/bin/idris2 $HOME/.idris2/bin/idris2_app/* - - name: Checkout - uses: actions/checkout@v2 - with: - repository: 'frex-project/idris-frex' - - name: Build Frex - run: | - make - make test \ No newline at end of file diff --git a/.github/workflows/ci-sphinx.yml b/.github/workflows/ci-sphinx.yml deleted file mode 100644 index 41d97defa..000000000 --- a/.github/workflows/ci-sphinx.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Sphinx - -on: - push: - branches: - - '*' - tags: - - '*' - pull_request: - branches: - - main -jobs: - - sphinx-doc-check: - name: Sphinx - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: ammaraskar/sphinx-action@master - with: - docs-folder: "docs/" diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml index 56157c0eb..865785e50 100644 --- a/.github/workflows/install.yml +++ b/.github/workflows/install.yml @@ -31,7 +31,7 @@ jobs: run: echo "PREFIX=$IDRIS2_PREFIX" >> $GITHUB_ENV - name: Download previous version run: | - wget https://github.com/mmhelloworld/idris-jvm/releases/download/v0.4.0-rc.4/idris2-0.4.0-SNAPSHOT.zip + wget https://github.com/mmhelloworld/idris-jvm/releases/download/v0.4.0/idris2-0.4.0-SNAPSHOT.zip unzip idris2-0.4.0-SNAPSHOT.zip -d $HOME/bin echo "::add-path::$HOME/bin/idris2-0.4.0-SNAPSHOT/bin" - name: Build diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index 228da1597..bd16b99f2 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -29,7 +29,7 @@ jobs: run: echo "PREFIX=$IDRIS2_PREFIX" >> $GITHUB_ENV - name: Download previous version run: | - wget https://github.com/mmhelloworld/idris-jvm/releases/download/v0.4.0-rc.4/idris2-0.4.0-SNAPSHOT.zip + wget https://github.com/mmhelloworld/idris-jvm/releases/download/v0.4.0/idris2-0.4.0-SNAPSHOT.zip unzip idris2-0.4.0-SNAPSHOT.zip -d $HOME/bin echo "::add-path::$HOME/bin/idris2-0.4.0-SNAPSHOT/bin" - name: Build @@ -42,4 +42,4 @@ jobs: prerelease: true title: "Development Build" files: | - idris-jvm-compiler/target/idris2-0.4.0-SNAPSHOT.zip + idris-jvm-compiler/target/idris2-0.5.1-SNAPSHOT.zip diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2da4ce721..2ed8db347 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -29,7 +29,7 @@ jobs: run: echo "PREFIX=$IDRIS2_PREFIX" >> $GITHUB_ENV - name: Download previous version run: | - wget https://github.com/mmhelloworld/idris-jvm/releases/download/v0.4.0-rc.4/idris2-0.4.0-SNAPSHOT.zip + wget https://github.com/mmhelloworld/idris-jvm/releases/download/v0.4.0/idris2-0.4.0-SNAPSHOT.zip unzip idris2-0.4.0-SNAPSHOT.zip -d $HOME/bin echo "::add-path::$HOME/bin/idris2-0.4.0-SNAPSHOT/bin" - name: Build @@ -39,6 +39,6 @@ jobs: with: repo_token: "${{ secrets.GITHUB_TOKEN }}" prerelease: false - title: "Release 0.4.0" + title: "Release 0.5.1-rc.1" files: | - idris-jvm-compiler/target/idris2-0.4.0-SNAPSHOT.zip + idris-jvm-compiler/target/idris2-0.5.1-SNAPSHOT.zip diff --git a/idris-jvm-assembler/pom.xml b/idris-jvm-assembler/pom.xml index 211debd0f..f14cd142e 100644 --- a/idris-jvm-assembler/pom.xml +++ b/idris-jvm-assembler/pom.xml @@ -5,7 +5,7 @@ io.github.mmhelloworld idris-jvm - 0.4.0-SNAPSHOT + 0.5.1-SNAPSHOT 4.0.0 diff --git a/idris-jvm-assembler/src/main/java/io/github/mmhelloworld/idrisjvm/assembler/AsmGlobalState.java b/idris-jvm-assembler/src/main/java/io/github/mmhelloworld/idrisjvm/assembler/AsmGlobalState.java index ce8612b3d..16bccf441 100644 --- a/idris-jvm-assembler/src/main/java/io/github/mmhelloworld/idrisjvm/assembler/AsmGlobalState.java +++ b/idris-jvm-assembler/src/main/java/io/github/mmhelloworld/idrisjvm/assembler/AsmGlobalState.java @@ -92,7 +92,8 @@ public void classCodeEnd(String outputDirectory, String outputFile, String mainC public void interpret(String mainClass) { Map classes = getClassNameAndClassWriters() - .collect(toMap(Entry::getKey, entry -> entry.getValue().toByteArray())); + .collect(toMap(Entry::getKey, entry -> entry.getValue().toByteArray(), + (first, second) -> second)); try { new InterpreterClassLoader(classes) .loadClass(mainClass) diff --git a/idris-jvm-compiler/pom.xml b/idris-jvm-compiler/pom.xml index 039767146..46a85be0c 100644 --- a/idris-jvm-compiler/pom.xml +++ b/idris-jvm-compiler/pom.xml @@ -5,7 +5,7 @@ io.github.mmhelloworld idris-jvm - 0.4.0-SNAPSHOT + 0.5.1-SNAPSHOT 4.0.0 diff --git a/idris-jvm-compiler/src/assembly/bin.xml b/idris-jvm-compiler/src/assembly/bin.xml index 728544304..a2e213a60 100644 --- a/idris-jvm-compiler/src/assembly/bin.xml +++ b/idris-jvm-compiler/src/assembly/bin.xml @@ -7,8 +7,8 @@ - ${env.IDRIS2_PREFIX}/idris2-0.4.0 - lib/idris2-0.4.0 + ${env.IDRIS2_PREFIX}/idris2-0.5.1 + lib/idris2-0.5.1 ${project.build.directory}/assembly diff --git a/idris-jvm-runtime/pom.xml b/idris-jvm-runtime/pom.xml index 3f7d9efa8..818df827b 100644 --- a/idris-jvm-runtime/pom.xml +++ b/idris-jvm-runtime/pom.xml @@ -5,7 +5,7 @@ io.github.mmhelloworld idris-jvm - 0.4.0-SNAPSHOT + 0.5.1-SNAPSHOT 4.0.0 diff --git a/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/ChannelIo.java b/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/ChannelIo.java index 8396020c9..86b451464 100644 --- a/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/ChannelIo.java +++ b/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/ChannelIo.java @@ -211,6 +211,7 @@ public int seekLine() { public void handleException(Exception e) { this.exception = e; + Runtime.setException(exception); Runtime.setErrorNumber(getErrorNumber(e)); } diff --git a/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/Directories.java b/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/Directories.java index 2798ad0da..8d8d13d88 100644 --- a/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/Directories.java +++ b/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/Directories.java @@ -19,7 +19,7 @@ public static int createDirectory(String pathString) { java.nio.file.Files.createDirectory(Paths.createPath(pathString)); return 0; } catch (Exception exception) { - Runtime.setErrorNumber(ChannelIo.getErrorNumber(exception)); + handleException(exception); return -1; } } @@ -51,40 +51,48 @@ public static boolean deleteIfExists(Path path) { } public static void delete(String pathString) { + Runtime.setErrorNumber(0); try { Files.delete(Paths.createPath(pathString)); } catch (IOException exception) { - Runtime.setErrorNumber(ChannelIo.getErrorNumber(exception)); + handleException(exception); } } public static Object openDirectory(String name) { + Runtime.setErrorNumber(0); Path path = Paths.createPath(name); try { DirectoryStream stream = newDirectoryStream(path); return new Directory(path, stream, stream.iterator()); } catch (Exception exception) { - Runtime.setErrorNumber(ChannelIo.getErrorNumber(exception)); + handleException(exception); return null; } } public static void closeDirectory(Object directory) { + Runtime.setErrorNumber(0); try { if (directory != null) { ((Directory) directory).getStream().close(); } } catch (IOException exception) { - Runtime.setErrorNumber(ChannelIo.getErrorNumber(exception)); + handleException(exception); } } + private static void handleException(Exception exception) { + Runtime.setException(exception); + Runtime.setErrorNumber(ChannelIo.getErrorNumber(exception)); + } + public static Object getNextDirectoryEntry(Object directory) { + Runtime.setErrorNumber(0); Iterator iterator = ((Directory) directory).getIterator(); if (iterator.hasNext()) { return iterator.next().getFileName().toString(); } else { - Runtime.setErrorNumber(2); return null; } } diff --git a/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/IdrisSocket.java b/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/IdrisSocket.java index 144efad0d..0b4cb2a11 100644 --- a/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/IdrisSocket.java +++ b/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/IdrisSocket.java @@ -63,7 +63,7 @@ public static IdrisSocket create(int socketFamily, int socketType, int protocolN return null; } } catch (Exception exception) { - Runtime.setErrorNumber(getErrorNumber(exception)); + handleException(exception); return null; } } @@ -346,7 +346,7 @@ private long withExceptionHandling(LongSupplierE action, lo } } - private void handleException(Exception e) { + private static void handleException(Exception e) { Runtime.setException(e); Runtime.setErrorNumber(getErrorNumber(e)); } diff --git a/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/Runtime.java b/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/Runtime.java index 6340f7df7..f487c634b 100644 --- a/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/Runtime.java +++ b/idris-jvm-runtime/src/main/java/io/github/mmhelloworld/idrisjvm/runtime/Runtime.java @@ -65,6 +65,10 @@ public static int getPid() { return Integer.parseInt(ManagementFactory.getRuntimeMXBean().getName().split("@")[0]); } + public static int getAvailableProcessors() { + return java.lang.Runtime.getRuntime().availableProcessors(); + } + public static T crash(String message) { throw new RuntimeException(message); } @@ -86,6 +90,9 @@ static void setException(Exception exception) { } static void setErrorNumber(int errorNumber) { + if (errorNumber == 0) { + setException(null); + } ERROR_NUMBER.set(errorNumber); } @@ -93,6 +100,10 @@ public static int getEagain() { return EAGAIN; } + public static String getErrorMessage(int errorNumber) { + return "Error code: " + errorNumber; + } + public static void free(Object object) { } diff --git a/idris-jvm-tests/pom.xml b/idris-jvm-tests/pom.xml index 9d471eed9..f71593784 100644 --- a/idris-jvm-tests/pom.xml +++ b/idris-jvm-tests/pom.xml @@ -5,7 +5,7 @@ io.github.mmhelloworld idris-jvm - 0.4.0-SNAPSHOT + 0.5.1-SNAPSHOT 4.0.0 diff --git a/libs/base/System/Errno.idr b/libs/base/System/Errno.idr index 73832ac1d..52d13e77e 100644 --- a/libs/base/System/Errno.idr +++ b/libs/base/System/Errno.idr @@ -1,12 +1,16 @@ module System.Errno +import System.FFI + %default total %foreign "C:idris2_getErrno, libidris2_support, idris_support.h" + jvm' runtimeClass "getErrorNumber" "java/lang/Object" "int" prim__getErrno : PrimIO Int %foreign "C:idris2_strerror, libidris2_support, idris_support.h" "node:lambda:errno=>'Error code: '+errno" + jvm' runtimeClass "getErrorMessage" "int" "String" prim__strerror : Int -> PrimIO String ||| Fetch libc `errno` global variable. diff --git a/libs/base/System/FFI.idr b/libs/base/System/FFI.idr index 398b6d8dd..16fb99eba 100644 --- a/libs/base/System/FFI.idr +++ b/libs/base/System/FFI.idr @@ -35,6 +35,18 @@ setField : {s : _} -> Struct s fs -> (n : String) -> {auto fieldok : FieldType n ty fs} -> ty -> IO () setField s n val = primIO (prim__setField s n fieldok val) +public export +runtimeClass : String +runtimeClass = "io/github/mmhelloworld/idrisjvm/runtime/Runtime" + +public export +jvm' : String -> String -> String -> String -> String +jvm' className methodName arguments ret = "jvm:" ++ methodName ++ "(" ++ arguments ++ " " ++ ret ++ ")," ++ className + +public export +jvm : String -> String -> String +jvm className methodName = "jvm:" ++ methodName ++ "," ++ className + %foreign "C:idris2_malloc, libidris2_support, idris_memory.h" "jvm:malloc(int java/lang/Object),io/github/mmhelloworld/idrisjvm/runtime/IdrisSystem" prim__malloc : (size : Int) -> PrimIO AnyPtr @@ -52,16 +64,3 @@ malloc size = primIO $ prim__malloc size export free : HasIO io => AnyPtr -> io () free ptr = primIO $ prim__free ptr - -public export -jvm' : String -> String -> String -> String -> String -jvm' className methodName arguments ret = "jvm:" ++ methodName ++ "(" ++ - arguments ++ " " ++ ret ++ ")," ++ className - -public export -jvm : String -> String -> String -jvm className methodName = "jvm:" ++ methodName ++ "," ++ className - -public export -runtimeClass : String -runtimeClass = "io/github/mmhelloworld/idrisjvm/runtime/Runtime" diff --git a/libs/base/System/File/Buffer.idr b/libs/base/System/File/Buffer.idr index e47572649..f026c1036 100644 --- a/libs/base/System/File/Buffer.idr +++ b/libs/base/System/File/Buffer.idr @@ -14,12 +14,12 @@ import Data.Buffer %foreign support "idris2_readBufferData" "node:lambda:(f,b,l,m) => require('fs').readSync(f.fd,b,l,m)" - "jvm:readFromFile(java/nio/channels/ReadableByteChannel io/github/mmhelloworld/idris2/runtime/IdrisBuffer int int int),io/github/mmhelloworld/idris2/runtime/IdrisBuffer" + "jvm:readFromFile(java/nio/channels/ReadableByteChannel io/github/mmhelloworld/idrisjvm/runtime/IdrisBuffer int int int),io/github/mmhelloworld/idrisjvm/runtime/IdrisBuffer" prim__readBufferData : FilePtr -> Buffer -> (offset : Int) -> (maxbytes : Int) -> PrimIO Int %foreign support "idris2_writeBufferData" "node:lambda:(f,b,l,m) => require('fs').writeSync(f.fd,b,l,m)" - "jvm:writeToFile(java/nio/channels/WritableByteChannel io/github/mmhelloworld/idris2/runtime/IdrisBuffer int int int),io/github/mmhelloworld/idris2/runtime/IdrisBuffer" + "jvm:writeToFile(java/nio/channels/WritableByteChannel io/github/mmhelloworld/idrisjvm/runtime/IdrisBuffer int int int),io/github/mmhelloworld/idrisjvm/runtime/IdrisBuffer" prim__writeBufferData : FilePtr -> Buffer -> (offset : Int) -> (maxbytes : Int) -> PrimIO Int export diff --git a/libs/base/System/File/Error.idr b/libs/base/System/File/Error.idr index 0e74ce5f3..f65e2a449 100644 --- a/libs/base/System/File/Error.idr +++ b/libs/base/System/File/Error.idr @@ -4,15 +4,21 @@ import System.Errno import System.File.Support import public System.File.Types +import System.FFI %default total +fileClass : String +fileClass = "io/github/mmhelloworld/idrisjvm/runtime/ChannelIo" + %foreign support "idris2_fileError" "node:lambda:x=>(x===1?1:0)" + jvm' fileClass "getErrorNumber" fileClass "int" prim__error : FilePtr -> PrimIO Int %foreign support "idris2_fileErrno" "node:support:fileErrno,support_system_file" + jvm' runtimeClass "getErrorNumber" "java/lang/Object" "int" prim__fileErrno : PrimIO Int public export diff --git a/libs/base/System/File/Handle.idr b/libs/base/System/File/Handle.idr index 5b8024d17..c6158725c 100644 --- a/libs/base/System/File/Handle.idr +++ b/libs/base/System/File/Handle.idr @@ -4,15 +4,21 @@ import public System.File.Error import public System.File.Mode import System.File.Support import public System.File.Types +import System.FFI %default total +fileClass : String +fileClass = "io/github/mmhelloworld/idrisjvm/runtime/ChannelIo" + %foreign support "idris2_openFile" "node:support:openFile,support_system_file" + jvm' fileClass "open" "String String" fileClass prim__open : String -> String -> PrimIO FilePtr %foreign support "idris2_closeFile" "node:lambda:(fp) => require('fs').closeSync(fp.fd)" + jvm' fileClass "close" fileClass "void" prim__close : FilePtr -> PrimIO () export diff --git a/libs/base/System/File/Meta.idr b/libs/base/System/File/Meta.idr index bf4dbacac..6d8fe2f1e 100644 --- a/libs/base/System/File/Meta.idr +++ b/libs/base/System/File/Meta.idr @@ -3,24 +3,33 @@ module System.File.Meta import System.File.Handle import System.File.Support import public System.File.Types +import System.FFI %default total +fileClass : String +fileClass = "io/github/mmhelloworld/idrisjvm/runtime/ChannelIo" + %foreign support "idris2_fileSize" "node:lambda:fp=>require('fs').fstatSync(fp.fd).size" + jvm' fileClass "size" fileClass "int" prim__fileSize : FilePtr -> PrimIO Int %foreign support "idris2_fileSize" + jvm' fileClass "size" fileClass "int" prim__fPoll : FilePtr -> PrimIO Int %foreign support "idris2_fileAccessTime" + jvm' fileClass "getAccessTime" fileClass "int" prim__fileAccessTime : FilePtr -> PrimIO Int %foreign support "idris2_fileModifiedTime" "node:lambda:fp=>require('fs').fstatSync(fp.fd).mtimeMs / 1000" + jvm' fileClass "getModifiedTime" fileClass "int" prim__fileModifiedTime : FilePtr -> PrimIO Int %foreign support "idris2_fileStatusTime" + jvm' fileClass "getStatusTime" fileClass "int" prim__fileStatusTime : FilePtr -> PrimIO Int %foreign support "idris2_fileIsTTY" diff --git a/libs/base/System/File/Permissions.idr b/libs/base/System/File/Permissions.idr index 40b41e3d0..964ffa420 100644 --- a/libs/base/System/File/Permissions.idr +++ b/libs/base/System/File/Permissions.idr @@ -4,11 +4,16 @@ import public System.File.Error import System.File.Meta import System.File.Support import public System.File.Types +import System.FFI %default total +fileClass : String +fileClass = "io/github/mmhelloworld/idrisjvm/runtime/ChannelIo" + %foreign support "idris2_chmod" "node:support:chmod,support_system_file" + jvm' fileClass "chmod" "String int" "int" prim__chmod : String -> Int -> PrimIO Int namespace FileMode diff --git a/libs/base/System/File/Process.idr b/libs/base/System/File/Process.idr index da75b9e95..79c229b0d 100644 --- a/libs/base/System/File/Process.idr +++ b/libs/base/System/File/Process.idr @@ -4,12 +4,19 @@ import public System.File.Error import public System.File.Mode import System.File.Support import public System.File.Types +import System.FFI + +fileClass : String +fileClass = "io/github/mmhelloworld/idrisjvm/runtime/ChannelIo" %foreign "C:fflush,libc 6" + jvm' fileClass "flush" fileClass "int" prim__flush : FilePtr -> PrimIO Int %foreign support "idris2_popen" + jvm' fileClass "popen" "String String" fileClass prim__popen : String -> String -> PrimIO FilePtr %foreign support "idris2_pclose" + jvm' fileClass "close" fileClass "void" prim__pclose : FilePtr -> PrimIO () export diff --git a/libs/base/System/File/ReadWrite.idr b/libs/base/System/File/ReadWrite.idr index a171a782d..0278cae4e 100644 --- a/libs/base/System/File/ReadWrite.idr +++ b/libs/base/System/File/ReadWrite.idr @@ -8,31 +8,42 @@ import System.File.Handle import public System.File.Error import System.File.Support import public System.File.Types +import System.FFI %default total +fileClass : String +fileClass = "io/github/mmhelloworld/idrisjvm/runtime/ChannelIo" + %foreign support "idris2_seekLine" "node:support:seekLine,support_system_file" + jvm' fileClass ".seekLine" fileClass "int" prim__seekLine : FilePtr -> PrimIO Int %foreign support "idris2_readLine" "node:support:readLine,support_system_file" + jvm' fileClass "readLine" fileClass "String" prim__readLine : FilePtr -> PrimIO (Ptr String) %foreign support "idris2_readChars" + jvm' fileClass "readChars" ("int " ++ fileClass) "String" prim__readChars : Int -> FilePtr -> PrimIO (Ptr String) %foreign "C:fgetc,libc 6" + jvm' fileClass "readChar" fileClass "char" prim__readChar : FilePtr -> PrimIO Int %foreign support "idris2_writeLine" "node:lambda:(filePtr, line) => require('fs').writeSync(filePtr.fd, line, undefined, 'utf-8')" + jvm' fileClass "writeLine" (fileClass ++ " String") "int" prim__writeLine : FilePtr -> String -> PrimIO Int %foreign support "idris2_eof" "node:lambda:x=>(x.eof?1:0)" + jvm' fileClass "isEof" fileClass "int" prim__eof : FilePtr -> PrimIO Int %foreign support "idris2_removeFile" + jvm' fileClass "delete" "String" "int" prim__removeFile : String -> PrimIO Int ||| Seek through the next newline. diff --git a/libs/base/System/File/Virtual.idr b/libs/base/System/File/Virtual.idr index a8009eb3c..558780fb9 100644 --- a/libs/base/System/File/Virtual.idr +++ b/libs/base/System/File/Virtual.idr @@ -2,19 +2,26 @@ module System.File.Virtual import System.File.Support import public System.File.Types +import System.FFI %default total +fileClass : String +fileClass = "io/github/mmhelloworld/idrisjvm/runtime/ChannelIo" + %foreign support "idris2_stdin" "node:lambda:x=>({fd:0, buffer: Buffer.alloc(0), name:'', eof: false})" + jvm runtimeClass "getStdin" prim__stdin : FilePtr %foreign support "idris2_stdout" "node:lambda:x=>({fd:1, buffer: Buffer.alloc(0), name:'', eof: false})" + jvm runtimeClass "getStdout" prim__stdout : FilePtr %foreign support "idris2_stderr" "node:lambda:x=>({fd:2, buffer: Buffer.alloc(0), name:'', eof: false})" + jvm runtimeClass "getStderr" prim__stderr : FilePtr export diff --git a/libs/base/System/Info.idr b/libs/base/System/Info.idr index 69e6b5a89..ad7026330 100644 --- a/libs/base/System/Info.idr +++ b/libs/base/System/Info.idr @@ -18,6 +18,7 @@ isWindows : Bool isWindows = os `elem` ["windows", "mingw32", "cygwin32"] %foreign "C:idris2_getNProcessors, libidris2_support, idris_support.h" + "jvm:getAvailableProcessors(int),io/github/mmhelloworld/idrisjvm/runtime/Runtime" prim__getNProcessors : PrimIO Int export diff --git a/libs/network/Network/Socket/Data.idr b/libs/network/Network/Socket/Data.idr index 105aff0da..7110d63df 100644 --- a/libs/network/Network/Socket/Data.idr +++ b/libs/network/Network/Socket/Data.idr @@ -8,6 +8,7 @@ module Network.Socket.Data import Data.List import Data.List1 import Data.String +import System.FFI -- ------------------------------------------------------------ [ Type Aliases ] diff --git a/pom.xml b/pom.xml index 71802c7cc..5e9770103 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.mmhelloworld idris-jvm - 0.4.0-SNAPSHOT + 0.5.1-SNAPSHOT pom Idris JVM JVM bytecode backend for Idris @@ -60,6 +60,7 @@ 3.0.1 3.0.0-M1 3.0.0-M4 + 2.8.1 diff --git a/src/Compiler/Jvm/Codegen.idr b/src/Compiler/Jvm/Codegen.idr index 3c795a708..bb817fb48 100644 --- a/src/Compiler/Jvm/Codegen.idr +++ b/src/Compiler/Jvm/Codegen.idr @@ -42,7 +42,7 @@ import Compiler.Jvm.Tuples %hide System.FFI.runtimeClass %hide Compiler.Jvm.Asm.assemble -%hide Core.Context.Constructor.arity +%hide Core.Context.Context.Constructor.arity addScopeLocalVariables : Scope -> Asm () addScopeLocalVariables scope = do @@ -299,7 +299,7 @@ mutual assembleExpr isTailCall returnType expr -- Tail recursion. Store arguments and recur to the beginning of the method - assembleExpr _ returnType app@(NmApp fc (NmRef _ (UN ":__jvmTailRec__:")) args) = + assembleExpr _ returnType app@(NmApp fc (NmRef _ (UN (Basic "$jvmTailRec"))) args) = case length args of Z => Goto methodStartLabel (S lastArgIndex) => do @@ -610,8 +610,8 @@ mutual assembleExprOp returnType fc (Mod Bits32Type) [x, y] = assembleExprBinaryOp returnType IInt integerRemainderUnsigned x y - assembleExprOp returnType fc (ShiftL Bits64Type) [x, y] = assembleExprBinaryOp returnType ILong Lshl x y - assembleExprOp returnType fc (ShiftR Bits64Type) [x, y] = assembleExprBinaryOp returnType ILong Lushr x y + assembleExprOp returnType fc (ShiftL Bits64Type) [x, y] = assembleExprBinaryOp returnType ILong (do L2i; Lshl) x y + assembleExprOp returnType fc (ShiftR Bits64Type) [x, y] = assembleExprBinaryOp returnType ILong (do L2i; Lushr) x y assembleExprOp returnType fc (BAnd Bits64Type) [x, y] = assembleExprBinaryOp returnType ILong Land x y assembleExprOp returnType fc (BOr Bits64Type) [x, y] = assembleExprBinaryOp returnType ILong Lor x y assembleExprOp returnType fc (BXOr Bits64Type) [x, y] = assembleExprBinaryOp returnType ILong Lxor x y @@ -676,7 +676,8 @@ mutual assembleExprOp returnType fc (Neg ty) [x] = assembleExprUnaryOp returnType IInt Ineg x assembleExprOp returnType fc (ShiftL ty) [x, y] = assembleExprBinaryOp returnType IInt Ishl x y - assembleExprOp returnType fc (ShiftR ty) [x, y] = assembleExprBinaryOp returnType IInt Iushr x y + assembleExprOp returnType fc (ShiftR Bits32Type) [x, y] = assembleExprBinaryOp returnType IInt Iushr x y + assembleExprOp returnType fc (ShiftR ty) [x, y] = assembleExprBinaryOp returnType IInt Ishr x y assembleExprOp returnType fc (BAnd ty) [x, y] = assembleExprBinaryOp returnType IInt Iand x y assembleExprOp returnType fc (BOr ty) [x, y] = assembleExprBinaryOp returnType IInt Ior x y assembleExprOp returnType fc (BXOr ty) [x, y] = assembleExprBinaryOp returnType IInt Ixor x y @@ -1088,14 +1089,15 @@ mutual (parameterName : Maybe Name) -> NamedCExp -> Asm () assembleSubMethodWithScope isTailCall returnType (Just value) (Just name) body = do parentScope <- getScope !getCurrentScopeIndex - let shouldGenerateVariable = name == UN extractedMethodArgumentName + let shouldGenerateVariable = name == extractedMethodArgumentName parameterValueVariable <- if shouldGenerateVariable then Pure $ jvmSimpleName name ++ show !newDynamicVariableIndex else Pure $ jvmSimpleName name + let parameterValueVariableName = UN $ Basic parameterValueVariable withScope $ assembleSubMethod isTailCall returnType (Just (assembleValue parentScope parameterValueVariable)) - (Just $ UN parameterValueVariable) parentScope - (substituteVariableSubMethodBody (NmLocal (getFC body) $ UN parameterValueVariable) body) + (Just parameterValueVariableName) parentScope + (substituteVariableSubMethodBody (NmLocal (getFC body) parameterValueVariableName) body) where assembleValue : Scope -> String -> Asm () assembleValue enclosingScope variableName = do @@ -1108,22 +1110,22 @@ mutual body@(NmLam _ p1 (NmLam _ p2 (NmLam _ p3 (NmLam _ p4 (NmApp _ (NmRef _ name) [NmLocal _ arg0, NmLocal _ arg1, NmLocal _ arg2, NmLocal _ arg3, NmLocal _ arg4]))))) = assembleMethodReference isTailCall returnType - ((fromMaybe (UN "") p0) == arg0 && p1 == arg1 && p2 == arg2 && p3 == arg3 && p4 == arg4) + (maybe False ((==) arg0) p0 && p1 == arg1 && p2 == arg2 && p3 == arg3 && p4 == arg4) 5 name p0 body assembleSubMethodWithScope isTailCall returnType _ p0 body@(NmLam _ p1 (NmLam _ p2 (NmLam _ p3 (NmApp _ (NmRef _ name) [NmLocal _ arg0, NmLocal _ arg1, NmLocal _ arg2, NmLocal _ arg3])))) = assembleMethodReference isTailCall returnType - ((fromMaybe (UN "") p0) == arg0 && p1 == arg1 && p2 == arg2 && p3 == arg3) 4 name p0 body + (maybe False ((==) arg0) p0 && p1 == arg1 && p2 == arg2 && p3 == arg3) 4 name p0 body assembleSubMethodWithScope isTailCall returnType _ p0 body@(NmLam _ p1 (NmLam _ p2 (NmApp _ (NmRef _ name) [NmLocal _ arg0, NmLocal _ arg1, NmLocal _ arg2]))) = - assembleMethodReference isTailCall returnType ((fromMaybe (UN "") p0) == arg0 && p1 == arg1 && p2 == arg2) + assembleMethodReference isTailCall returnType (maybe False ((==) arg0) p0 && p1 == arg1 && p2 == arg2) 3 name p0 body assembleSubMethodWithScope isTailCall returnType _ p0 body@(NmLam _ p1 (NmApp _ (NmRef _ name) [NmLocal _ arg0, NmLocal _ arg1])) = - assembleMethodReference isTailCall returnType ((fromMaybe (UN "") p0) == arg0 && p1 == arg1) + assembleMethodReference isTailCall returnType (maybe False ((==) arg0) p0 && p1 == arg1) 2 name p0 body assembleSubMethodWithScope isTailCall returnType _ p0 body@(NmApp _ (NmRef _ name) [NmLocal _ arg0]) = - assembleMethodReference isTailCall returnType ((fromMaybe (UN "") p0) == arg0) 1 name p0 body + assembleMethodReference isTailCall returnType (maybe False ((==) arg0) p0) 1 name p0 body assembleSubMethodWithScope isTailCall returnType _ parameterName body@(NmLam _ c (NmLam _ a (NmLocal _ b))) = let hasParameter = isJust parameterName @@ -1133,13 +1135,13 @@ mutual then assembleIdentity2Lambda isTailCall else assembleSubMethodWithScope1 isTailCall returnType parameterName body assembleSubMethodWithScope isTailCall returnType _ parameterName body@(NmLam _ a (NmLocal _ b)) = - if (fromMaybe (UN "") parameterName) == b + if maybe False ((==) b) parameterName then assembleConstantLambda isTailCall else if isJust parameterName && a == b then assembleIdentity1Lambda isTailCall else assembleSubMethodWithScope1 isTailCall returnType parameterName body assembleSubMethodWithScope isTailCall returnType _ parameterName body@(NmLocal _ b) = - if (fromMaybe (UN "") parameterName) == b + if maybe False ((==) b) parameterName then assembleIdentityLambda isTailCall else assembleSubMethodWithScope1 isTailCall returnType parameterName body assembleSubMethodWithScope isTailCall returnType _ parameterName body = @@ -1158,7 +1160,7 @@ mutual let lambdaInterfaceType = getLambdaInterfaceType lambdaType lambdaBodyReturnType parameterType <- the (Asm (Maybe InferredType)) $ traverse getVariableType - (jvmSimpleName <$> (if parameterName == Just (UN "$jvm$thunk") then Nothing else parameterName)) + (jvmSimpleName <$> (if parameterName == Just thunkParamName then Nothing else parameterName)) variableTypes <- LiftIo $ Map.values {key=Int} !(loadClosures declaringScope scope) maybe (Pure ()) id parameterValueExpr let invokeDynamicDescriptor = getMethodDescriptor $ MkInferredFunctionType lambdaInterfaceType variableTypes @@ -1351,7 +1353,7 @@ mutual let lineNumberStart = fst $ lineNumbers scope LabelStart switchEndLabel addLineNumber lineNumberStart switchEndLabel - assembleConstantSwitch returnType IInt fc (NmLocal fc $ UN hashCodePositionVariableName) + assembleConstantSwitch returnType IInt fc (NmLocal fc $ UN $ Basic hashCodePositionVariableName) (hashPositionSwitchAlts hashPositionAndAlts) def where constantAltHashCodeExpr : FC -> (Int, NamedConstAlt) -> Asm (Int, Int, NamedConstAlt) @@ -1524,7 +1526,7 @@ mutual let lineNumberStart = fst $ lineNumbers scope LabelStart switchEndLabel addLineNumber lineNumberStart switchEndLabel - assembleExpr False IInt (NmLocal fc $ UN hashCodePositionVariableName) + assembleExpr False IInt (NmLocal fc $ UN $ Basic hashCodePositionVariableName) assembleConstructorSwitch returnType fc idrisObjectVariableIndex (hashPositionSwitchAlts hashPositionAndAlts) def where @@ -1775,7 +1777,7 @@ assemble globalState fcAndDefinitionsByName name = do Just (fc, def) => do programName <- AsmGlobalState.getProgramName globalState asmState <- createAsmState globalState name - ignore $ runAsm asmState $ do + ignore $ asm asmState $ do inferDef programName name fc def assembleDefinition name fc scopes <- LiftIo $ JList.new {a=Scope} @@ -1854,4 +1856,4 @@ executeExprJvm c execDir term = ignore $ compileExprJvm c execDir "" term "" ||| Codegen wrapper for JVM implementation. export codegenJvm : Codegen -codegenJvm = MkCG compileExprJvm executeExprJvm +codegenJvm = MkCG compileExprJvm executeExprJvm Nothing Nothing diff --git a/src/Compiler/Jvm/ExtPrim.idr b/src/Compiler/Jvm/ExtPrim.idr index b015e5fd6..731aab640 100644 --- a/src/Compiler/Jvm/ExtPrim.idr +++ b/src/Compiler/Jvm/ExtPrim.idr @@ -36,20 +36,20 @@ Show ExtPrim where export toPrim : Name -> ExtPrim toPrim pn@(NS _ n) - = cond [(n == UN "prim__jvmStatic", JvmStaticMethodCall), - (n == UN "prim__jvmInstance", JvmInstanceMethodCall), - (n == UN "prim__newIORef", NewIORef), - (n == UN "prim__readIORef", ReadIORef), - (n == UN "prim__writeIORef", WriteIORef), - (n == UN "prim__newArray", NewArray), - (n == UN "prim__arrayGet", ArrayGet), - (n == UN "prim__arraySet", ArraySet), - (n == UN "prim__getField", GetField), - (n == UN "prim__setField", SetField), - (n == UN "void", VoidElim), - (n == UN "prim__os", SysOS), - (n == UN "prim__codegen", SysCodegen), - (n == UN "prim__makeFuture", MakeFuture) + = cond [(n == UN (Basic "prim__jvmStatic"), JvmStaticMethodCall), + (n == UN (Basic "prim__jvmInstance"), JvmInstanceMethodCall), + (n == UN (Basic "prim__newIORef"), NewIORef), + (n == UN (Basic "prim__readIORef"), ReadIORef), + (n == UN (Basic "prim__writeIORef"), WriteIORef), + (n == UN (Basic "prim__newArray"), NewArray), + (n == UN (Basic "prim__arrayGet"), ArrayGet), + (n == UN (Basic "prim__arraySet"), ArraySet), + (n == UN (Basic "prim__getField"), GetField), + (n == UN (Basic "prim__setField"), SetField), + (n == UN (Basic "void"), VoidElim), + (n == UN (Basic "prim__os"), SysOS), + (n == UN (Basic "prim__codegen"), SysCodegen), + (n == UN (Basic "prim__makeFuture"), MakeFuture) ] (Unknown pn) -toPrim pn = Unknown pn \ No newline at end of file +toPrim pn = Unknown pn diff --git a/src/Compiler/Jvm/Foreign.idr b/src/Compiler/Jvm/Foreign.idr index 1b979f349..602fdb7e9 100644 --- a/src/Compiler/Jvm/Foreign.idr +++ b/src/Compiler/Jvm/Foreign.idr @@ -194,8 +194,8 @@ inferForeign programName idrisName fc foreignDescriptors argumentTypes returnTyp let inferredFunctionType = MkInferredFunctionType methodReturnType (replicate arityNat inferredObjectType) scopes <- LiftIo $ JList.new {a=Scope} let externalFunctionBody = - NmExtPrim fc (NS (mkNamespace "") $ UN $ getPrimMethodName foreignFunctionName) [ - NmCon fc (UN $ createExtPrimTypeSpec jvmReturnType) DATACON Nothing [], + NmExtPrim fc (NS (mkNamespace "") $ UN $ Basic $ getPrimMethodName foreignFunctionName) [ + NmCon fc (UN $ Basic $ createExtPrimTypeSpec jvmReturnType) DATACON Nothing [], NmPrimVal fc (Str $ foreignFunctionClassName ++ "." ++ foreignFunctionName), getJvmExtPrimArguments $ zip argumentTypes $ SortedMap.toList argumentTypesByName, NmPrimVal fc WorldVal] @@ -227,9 +227,9 @@ inferForeign programName idrisName fc foreignDescriptors argumentTypes returnTyp updateScopeVariableTypes arityNat where getJvmExtPrimArguments : List (CFType, String, InferredType) -> NamedCExp - getJvmExtPrimArguments [] = NmCon fc (UN "emptyForeignArg") DATACON (Just 0) [] + getJvmExtPrimArguments [] = NmCon fc (UN $ Basic "emptyForeignArg") DATACON (Just 0) [] getJvmExtPrimArguments ((CFWorld, _, _) :: rest) = getJvmExtPrimArguments rest - getJvmExtPrimArguments ((_, name, ty) :: rest) = NmCon fc (UN "foreignArg") DATACON (Just 1) [ - NmCon fc (UN $ createExtPrimTypeSpec ty) DATACON (Just 0) [], - NmLocal fc (UN name), + getJvmExtPrimArguments ((_, name, ty) :: rest) = NmCon fc (UN $ Basic "foreignArg") DATACON (Just 1) [ + NmCon fc (UN . Basic $ createExtPrimTypeSpec ty) DATACON (Just 0) [], + NmLocal fc (UN $ Basic name), getJvmExtPrimArguments rest ] diff --git a/src/Compiler/Jvm/Jname.idr b/src/Compiler/Jvm/Jname.idr index 9d639c7d9..88bffb5bd 100644 --- a/src/Compiler/Jvm/Jname.idr +++ b/src/Compiler/Jvm/Jname.idr @@ -29,10 +29,13 @@ cleanupIdentifier : String -> String %foreign "jvm:.replace,java/lang/String" replace : String -> Char -> Char -> String +getSimpleNameWithSep : String -> Jname -> String +getSimpleNameWithSep _ (Jsimple n) = n +getSimpleNameWithSep sep (Jqualified q n) = q ++ sep ++ n + export getSimpleName : Jname -> String -getSimpleName (Jsimple n) = n -getSimpleName (Jqualified q n) = q ++ "/" ++ n +getSimpleName = getSimpleNameWithSep "/" export implementation Eq Jname where @@ -48,13 +51,13 @@ implementation Show Jname where export jvmName : Name -> Jname -jvmName (NS ns n) = Jqualified (replace (cleanupIdentifier $ showNSWithSep "$" ns) '$' '/') $ getSimpleName (jvmName n) -jvmName (UN n) = Jsimple $ cleanupIdentifier n +jvmName (NS ns n) = + Jqualified (replace (cleanupIdentifier $ showNSWithSep "$" ns) '$' '/') $ getSimpleNameWithSep "$" (jvmName n) +jvmName (UN n) = Jsimple $ cleanupIdentifier (displayUserName n) jvmName (MN n i) = Jsimple $ cleanupIdentifier n ++ "$" ++ show i -jvmName (PV n d) = Jsimple $ "$p" ++ getSimpleName (jvmName n) -jvmName (DN str n) = Jsimple $ cleanupIdentifier str ++ getSimpleName (jvmName n) -jvmName (RF str) = Jsimple $ cleanupIdentifier str -jvmName (Nested (i, x) n) = Jsimple $ "$n" ++ show i ++ "$" ++ show x ++ "$" ++ getSimpleName (jvmName n) +jvmName (PV n d) = Jsimple $ "$p" ++ getSimpleNameWithSep "$" (jvmName n) +jvmName (DN str n) = Jsimple $ cleanupIdentifier str ++ "$" ++ getSimpleNameWithSep "$" (jvmName n) +jvmName (Nested (i, x) n) = Jsimple $ "$n" ++ show i ++ "$" ++ show x ++ "$" ++ getSimpleNameWithSep "$" (jvmName n) jvmName (CaseBlock x y) = Jsimple $ "$c" ++ cleanupIdentifier (show x) ++ "$" ++ show y jvmName (WithBlock x y) = Jsimple $ "$w" ++ cleanupIdentifier (show x) ++ "$" ++ show y jvmName (Resolved i) = Jsimple $ "$r" ++ show i @@ -72,4 +75,4 @@ jvmIdrisMainClass rootPackage = rootPackage ++ "/Main" export idrisMainFunctionName : String -> Name -idrisMainFunctionName rootPackage = NS (mkNamespace $ rootPackage ++ ".Main") (UN jvmIdrisMainMethodName) +idrisMainFunctionName rootPackage = NS (mkNamespace $ rootPackage ++ ".Main") (UN $ Basic jvmIdrisMainMethodName) diff --git a/src/Compiler/Jvm/Optimizer.idr b/src/Compiler/Jvm/Optimizer.idr index a48e0d202..2873f34d7 100644 --- a/src/Compiler/Jvm/Optimizer.idr +++ b/src/Compiler/Jvm/Optimizer.idr @@ -24,14 +24,14 @@ import Compiler.Jvm.InferredType import Compiler.Jvm.Jname import Compiler.Jvm.ShowUtil -%hide Core.Context.Constructor.arity +%hide Core.Context.Context.Constructor.arity mutual hasTailCall : (predicate: Name -> Bool) -> NamedCExp -> Bool hasTailCall predicate (NmLet _ _ _ expr) = hasTailCall predicate expr hasTailCall predicate (NmApp _ (NmRef _ name) _) = predicate name - hasTailCall predicate (NmApp _ lambdaVariable _) = predicate (UN "") - hasTailCall predicate (NmExtPrim fc p args) = predicate (UN "") + hasTailCall predicate (NmApp _ lambdaVariable _) = predicate (UN $ Basic "") + hasTailCall predicate (NmExtPrim fc p args) = predicate (UN $ Basic "") hasTailCall predicate (NmConCase _ _ conAlts def) = maybe False (\defExp => hasTailCall predicate defExp) def || hasTailCallConAlt predicate conAlts hasTailCall predicate (NmConstCase _ _ constAlts def) = @@ -48,27 +48,31 @@ mutual hasTailCallConstAlt predicate ((MkNConstAlt _ expr) :: alts) = hasTailCall predicate expr || hasTailCallConstAlt predicate alts +export +thunkParamName : Name +thunkParamName = UN $ Basic "$jvm$thunk" + thunkExpr : NamedCExp -> NamedCExp -thunkExpr expr = NmLam (getFC expr) (UN "$jvm$thunk") expr +thunkExpr expr = NmLam (getFC expr) thunkParamName expr isBoolTySpec : String -> Name -> Bool -isBoolTySpec "Prelude" (UN "Bool") = True -isBoolTySpec "Prelude.Basics" (UN "Bool") = True +isBoolTySpec "Prelude" (UN (Basic "Bool")) = True +isBoolTySpec "Prelude.Basics" (UN (Basic "Bool")) = True isBoolTySpec _ _ = False export tySpec : NamedCExp -> Asm InferredType -tySpec (NmCon fc (UN "Int") _ _ []) = pure IInt -tySpec (NmCon fc (UN "Integer") _ _ []) = pure inferredBigIntegerType -tySpec (NmCon fc (UN "String") _ _ []) = pure inferredStringType -tySpec (NmCon fc (UN "Double") _ _ []) = pure IDouble -tySpec (NmCon fc (UN "Char") _ _ []) = pure IChar -tySpec (NmCon fc (UN "Bool") _ _ []) = pure IBool -tySpec (NmCon fc (UN "long") _ _ []) = pure ILong -tySpec (NmCon fc (UN "void") _ _ []) = pure IVoid -tySpec (NmCon fc (UN ty) _ _ []) = pure $ IRef ty +tySpec (NmCon fc (UN (Basic "Int")) _ _ []) = pure IInt +tySpec (NmCon fc (UN (Basic "Integer")) _ _ []) = pure inferredBigIntegerType +tySpec (NmCon fc (UN (Basic "String")) _ _ []) = pure inferredStringType +tySpec (NmCon fc (UN (Basic "Double")) _ _ []) = pure IDouble +tySpec (NmCon fc (UN (Basic "Char")) _ _ []) = pure IChar +tySpec (NmCon fc (UN (Basic "Bool")) _ _ []) = pure IBool +tySpec (NmCon fc (UN (Basic "long")) _ _ []) = pure ILong +tySpec (NmCon fc (UN (Basic "void")) _ _ []) = pure IVoid +tySpec (NmCon fc (UN (Basic ty)) _ _ []) = pure $ IRef ty tySpec (NmCon fc (NS namespaces n) _ _ []) = cond - [(n == UN "Unit", pure IVoid), + [(n == UN (Basic "Unit"), pure IVoid), (isBoolTySpec (show namespaces) n, pure IBool)] (pure inferredObjectType) tySpec ty = pure inferredObjectType @@ -137,10 +141,9 @@ mutual usedConst : String -> NamedConstAlt -> Bool usedConst n (MkNConstAlt _ sc) = used n sc -%inline export -extractedMethodArgumentName : String -extractedMethodArgumentName = "$jvm$arg" +extractedMethodArgumentName : Name +extractedMethodArgumentName = UN (Basic "$jvm$arg") %inline maxCasesInMethod : Int @@ -169,7 +172,7 @@ getAppliedLambdaType fc = mutual goLiftToLambda : (isTailPosition: Bool) -> NamedCExp -> State Int NamedCExp goLiftToLambda False (NmLet fc var value sc) = do - let extractedMethodArgumentVarName = UN extractedMethodArgumentName + let extractedMethodArgumentVarName = extractedMethodArgumentName let extractedMethodArgumentVar = NmLocal fc extractedMethodArgumentVarName liftedValue <- goLiftToLambda False value liftedSc <- goLiftToLambda True sc @@ -179,7 +182,7 @@ mutual pure $ NmLet fc var !(goLiftToLambda False value) !(goLiftToLambda True sc) goLiftToLambda False (NmConCase fc sc alts def) = do put $ succ !get - let var = UN extractedMethodArgumentName + let var = extractedMethodArgumentName liftedSc <- goLiftToLambda False sc liftedAlts <- traverse liftToLambdaCon alts liftedDef <- traverse liftToLambdaDefault def @@ -198,7 +201,7 @@ mutual pure $ NmConCase fc !(goLiftToLambda False sc) liftedAlts liftedDef goLiftToLambda False (NmConstCase fc sc alts def) = do put $ succ !get - let var = UN extractedMethodArgumentName + let var = extractedMethodArgumentName liftedAlts <- traverse liftToLambdaConst alts liftedDef <- traverse liftToLambdaDefault def liftedSc <- goLiftToLambda False sc @@ -298,13 +301,16 @@ mutual getFreeVariables : SortedSet String -> NamedCExp -> SortedSet String getFreeVariables boundVariables expr = doGetFreeVariables SortedSet.empty boundVariables expr +jvmTailRecName : Name +jvmTailRecName = UN $ Basic "$jvmTailRec" + mutual markTailRecursion : NamedCExp -> Asm NamedCExp markTailRecursion expr@(NmApp fc (NmRef nameFc idrisName) args) = let jname = jvmName idrisName functionName = getIdrisFunctionName !getProgramName (className jname) (methodName jname) in if functionName == !getRootMethodName - then Pure (NmApp fc (NmRef nameFc (UN ":__jvmTailRec__:")) args) + then Pure (NmApp fc (NmRef nameFc jvmTailRecName) args) else Pure expr markTailRecursion expr@(NmLet fc var value body) = NmLet fc var value <$> markTailRecursion body @@ -332,8 +338,8 @@ optThunkExpr _ = id mutual trampolineExpression : (isTailRec: Bool) -> NamedCExp -> NamedCExp -- Do not trampoline as tail recursion will be eliminated - trampolineExpression _ (NmApp fc (NmRef nameFc (UN ":__jvmTailRec__:")) args) = - NmApp fc (NmRef nameFc (UN ":__jvmTailRec__:")) (trampolineExpression False <$> args) + trampolineExpression _ (NmApp fc (NmRef nameFc (UN (Basic "$jvmTailRec"))) args) = + NmApp fc (NmRef nameFc jvmTailRecName) (trampolineExpression False <$> args) trampolineExpression isTailRec (NmApp fc f args) = optThunkExpr isTailRec $ NmApp fc (trampolineExpression False f) (trampolineExpression False <$> args) trampolineExpression _ (NmLam fc param body) = NmLam fc param $ trampolineExpression False body @@ -451,7 +457,7 @@ Eq LambdaType where export getLambdaTypeByParameter : (parameterName: Maybe Name) -> LambdaType -getLambdaTypeByParameter (Just (UN "$jvm$thunk")) = ThunkLambda +getLambdaTypeByParameter (Just (UN (Basic "$jvm$thunk"))) = ThunkLambda getLambdaTypeByParameter Nothing = DelayedLambda getLambdaTypeByParameter _ = FunctionLambda @@ -777,14 +783,14 @@ mutual else if appliedLambdaType == AppliedLambdaLet then Pure inferredObjectType else Pure IUnknown - let shouldGenerateVariable = parameterName == UN extractedMethodArgumentName + let shouldGenerateVariable = parameterName == extractedMethodArgumentName generatedJvmVariableName <- if shouldGenerateVariable then Pure $ jvmSimpleName parameterName ++ show !newDynamicVariableIndex else Pure $ jvmSimpleName parameterName let generatedVariableName = if shouldGenerateVariable - then UN generatedJvmVariableName + then UN $ Basic generatedJvmVariableName else parameterName let valueExpr = NmLocal (getFC lambdaBody) generatedVariableName parentScope <- getScope !getCurrentScopeIndex @@ -805,24 +811,24 @@ mutual inferExprLam _ _ p0 expr@(NmLam _ p1 (NmLam _ p2 (NmLam _ p3 (NmLam _ p4 (NmApp _ (NmRef _ name) [NmLocal _ arg0, NmLocal _ arg1, NmLocal _ arg2, NmLocal _ arg3, NmLocal _ arg4]))))) = inferExprLamWithParameterType1 - ((fromMaybe (UN "") p0) == arg0 && p1 == arg1 && p2 == arg2 && p3 == arg3 && p4 == arg4) p0 expr + (maybe False ((==) arg0) p0 && p1 == arg1 && p2 == arg2 && p3 == arg3 && p4 == arg4) p0 expr inferExprLam _ _ p0 expr@(NmLam _ p1 (NmLam _ p2 (NmLam _ p3 (NmApp _ (NmRef _ name) [NmLocal _ arg0, NmLocal _ arg1, NmLocal _ arg2, NmLocal _ arg3])))) = inferExprLamWithParameterType1 - ((fromMaybe (UN "") p0) == arg0 && p1 == arg1 && p2 == arg2 && p3 == arg3) p0 expr + (maybe False ((==) arg0) p0 && p1 == arg1 && p2 == arg2 && p3 == arg3) p0 expr inferExprLam _ _ p0 expr@(NmLam _ p1 (NmLam _ p2 (NmApp _ (NmRef _ name) [NmLocal _ arg0, NmLocal _ arg1, NmLocal _ arg2]))) = - inferExprLamWithParameterType1 ((fromMaybe (UN "") p0) == arg0 && p1 == arg1 && p2 == arg2) p0 expr + inferExprLamWithParameterType1 (maybe False ((==) arg0) p0 && p1 == arg1 && p2 == arg2) p0 expr inferExprLam _ _ p0 expr@(NmLam _ p1 (NmApp _ (NmRef _ name) [NmLocal _ arg0, NmLocal _ arg1])) = - inferExprLamWithParameterType1 ((fromMaybe (UN "") p0) == arg0 && p1 == arg1) p0 expr + inferExprLamWithParameterType1 (maybe False ((==) arg0) p0 && p1 == arg1) p0 expr inferExprLam _ _ p0 expr@(NmApp _ (NmRef _ _) [NmLocal _ b]) = - inferExprLamWithParameterType1 ((fromMaybe (UN "") p0) == b) p0 expr + inferExprLamWithParameterType1 (maybe False ((==) b) p0) p0 expr inferExprLam _ _ p0 expr@(NmLam _ c (NmLam _ a (NmLocal _ b))) = inferExprLamWithParameterType1 (isJust p0 && (c == b || a == b)) p0 expr inferExprLam _ _ p0 expr@(NmLam _ a (NmLocal _ b)) = - inferExprLamWithParameterType1 ((fromMaybe (UN "") p0) == b || (isJust p0 && a == b)) p0 expr + inferExprLamWithParameterType1 (maybe False ((==) b) p0 || (isJust p0 && a == b)) p0 expr inferExprLam _ _ p0 expr@(NmLocal _ b) = - inferExprLamWithParameterType1 ((fromMaybe (UN "") p0) == b) p0 expr + inferExprLamWithParameterType1 (maybe False ((==) b) p0) p0 expr inferExprLam _ _ p0 expr = inferExprLamWithParameterType1 False p0 expr inferExprLet : FC -> InferredType -> (x : Name) -> NamedCExp -> NamedCExp -> Asm InferredType @@ -855,7 +861,7 @@ mutual _ => createNewVariable "tailRecArg" ty inferExprApp : InferredType -> NamedCExp -> Asm InferredType - inferExprApp exprTy app@(NmApp _ (NmRef _ (UN ":__jvmTailRec__:")) args) = + inferExprApp exprTy app@(NmApp _ (NmRef _ (UN (Basic "$jvmTailRec"))) args) = case args of [] => Pure exprTy args@(_ :: argsTail) => do @@ -1176,10 +1182,6 @@ inferDef programName idrisName fc (MkNmFun args body) = do retTy <- inferExpr IUnknown optimizedExpr updateScopeVariableTypes arity updateCurrentFunction $ record { inferredFunctionType = inferredFunctionType } - when shouldDebugExpr $ - debug $ "Inferring " ++ (className jvmClassAndMethodName) ++ "." ++ (methodName jvmClassAndMethodName) ++ - ":\n" ++ showNamedCExp 0 expr ++ "\n" ++ show inferredFunctionType - when shouldDebugExpr $ showScopes (scopeCounter !GetState - 1) where getArgumentTypes : List String -> Asm (List InferredType) getArgumentTypes argumentNames = do diff --git a/src/Core/Binary/Prims.idr b/src/Core/Binary/Prims.idr index 579624172..a9db4aebe 100644 --- a/src/Core/Binary/Prims.idr +++ b/src/Core/Binary/Prims.idr @@ -364,12 +364,12 @@ toLimbs x = if x == 0 then [] else if x == -1 then [-1] - else fromInteger (prim__and_Integer x 0xffffffff) :: - toLimbs (prim__shr_Integer x 32) + else fromInteger (prim__and_Integer x 0xffff) :: + toLimbs (prim__shr_Integer x 16) fromLimbs : List Int -> Integer fromLimbs [] = 0 -fromLimbs (x :: xs) = cast x + prim__shl_Integer (fromLimbs xs) 32 +fromLimbs (x :: xs) = cast x + prim__shl_Integer (fromLimbs xs) 16 export TTC Integer where diff --git a/src/Core/Primitives.idr b/src/Core/Primitives.idr index a1018f825..4f14f2725 100644 --- a/src/Core/Primitives.idr +++ b/src/Core/Primitives.idr @@ -93,32 +93,14 @@ castInt [NPrimVal fc (Ch i)] = Just (NPrimVal fc (I (cast i))) castInt [NPrimVal fc (Str i)] = Just (NPrimVal fc (I (cast i))) castInt _ = Nothing -b8max : Int -b8max = 0x100 - -b16max : Int -b16max = 0x10000 - -b32max : Int -b32max = 0x100000000 - -b64max : Integer -b64max = 18446744073709551616 -- 0x10000000000000000 - -bitCastWrap : Ord a => Integral a => (i : a) -> (max : a) -> a -bitCastWrap i max - = if i >= 0 -- oops, we don't have `rem` yet! - then i `mod` max - else max + i `mod` max - bit8CastWrap : (i : Int) -> Int -bit8CastWrap i = bitCastWrap i b8max +bit8CastWrap i = cast $ bitCastWrap (cast i) (cast b8max) bit16CastWrap : (i : Int) -> Int -bit16CastWrap i = bitCastWrap i b16max +bit16CastWrap i = cast $ bitCastWrap (cast i) (cast b16max) bit32CastWrap : (i : Int) -> Int -bit32CastWrap i = bitCastWrap i b32max +bit32CastWrap i = cast $ bitCastWrap (cast i) b32max bit64CastWrap : (i : Integer) -> Integer bit64CastWrap i = bitCastWrap i b64max diff --git a/src/Idris/ProcessIdr.idr b/src/Idris/ProcessIdr.idr index 4799e8d0c..f35bd4ae3 100644 --- a/src/Idris/ProcessIdr.idr +++ b/src/Idris/ProcessIdr.idr @@ -10,6 +10,7 @@ import Compiler.ES.Javascript import Compiler.Common import Compiler.Inline import Compiler.Interpreter.VMCode +import Compiler.Jvm.Codegen import Core.Binary import Core.Context diff --git a/tests/idris2/basic053/expected b/tests/idris2/basic053/expected index 11424502f..263b025f5 100644 --- a/tests/idris2/basic053/expected +++ b/tests/idris2/basic053/expected @@ -1,7 +1,7 @@ 1/1: Building UnderscoredIntegerLiterals (UnderscoredIntegerLiterals.idr) UnderscoredIntegerLiterals> 10000000000 UnderscoredIntegerLiterals> True -UnderscoredIntegerLiterals> 3405705229 +UnderscoredIntegerLiterals> 212856576 UnderscoredIntegerLiterals> True UnderscoredIntegerLiterals> True UnderscoredIntegerLiterals> True diff --git a/tests/idris2/basic055/BitOps.idr b/tests/idris2/basic055/BitOps.idr index 34eeca98f..6a7b53852 100644 --- a/tests/idris2/basic055/BitOps.idr +++ b/tests/idris2/basic055/BitOps.idr @@ -24,12 +24,12 @@ b32max = 0xffffffff b64max : Bits64 b64max = 18446744073709551615 --- the only way to create -2^63 +-- the only way to create -2^31 intmin : Int -intmin = shl1 63 +intmin = shl1 31 intmax : Int -intmax = 0x7fffffffffffffff +intmax = 0x7fffffff powsOf2 : Num a => Nat -> List a powsOf2 n = take n (iterate (*2) 1) @@ -54,10 +54,10 @@ shiftRInteger : List Integer shiftRInteger = map (`prim__shr_Integer` 1) (powsOf2 128) shiftRInt : List Int -shiftRInt = map (`prim__shr_Int` 1) (powsOf2 63 ++ [intmax]) +shiftRInt = map (`prim__shr_Int` 1) (powsOf2 31 ++ [intmax]) shiftRNegativeInt : List Int -shiftRNegativeInt = map (`prim__shr_Int` 1) (map negate (powsOf2 63) ++ [intmin]) +shiftRNegativeInt = map (`prim__shr_Int` 1) (map negate (powsOf2 31) ++ [intmin]) -------------------------------------------------------------------------------- -- shiftL @@ -79,10 +79,10 @@ shiftLInteger : List Integer shiftLInteger = map (`prim__shl_Integer` 1) (0 :: powsOf2 127) shiftLInt : List Int -shiftLInt = map (`prim__shl_Int` 1) (0 :: powsOf2 62) +shiftLInt = map (`prim__shl_Int` 1) (0 :: powsOf2 30) shiftLNegativeInt : List Int -shiftLNegativeInt = map (`prim__shl_Int` 1) (map negate (powsOf2 62)) +shiftLNegativeInt = map (`prim__shl_Int` 1) (map negate (powsOf2 30)) -------------------------------------------------------------------------------- diff --git a/tests/idris2/basic055/expected b/tests/idris2/basic055/expected index ea5c96346..66e59273a 100644 --- a/tests/idris2/basic055/expected +++ b/tests/idris2/basic055/expected @@ -1,21 +1,21 @@ 1/1: Building BitOps (BitOps.idr) -Main> -9223372036854775808 +Main> -2147483648 [0, 1, 2, 4, 8, 16, 32, 64, 127] [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32767] [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483647] [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775807] [0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808, 18446744073709551616, 36893488147419103232, 73786976294838206464, 147573952589676412928, 295147905179352825856, 590295810358705651712, 1180591620717411303424, 2361183241434822606848, 4722366482869645213696, 9444732965739290427392, 18889465931478580854784, 37778931862957161709568, 75557863725914323419136, 151115727451828646838272, 302231454903657293676544, 604462909807314587353088, 1208925819614629174706176, 2417851639229258349412352, 4835703278458516698824704, 9671406556917033397649408, 19342813113834066795298816, 38685626227668133590597632, 77371252455336267181195264, 154742504910672534362390528, 309485009821345068724781056, 618970019642690137449562112, 1237940039285380274899124224, 2475880078570760549798248448, 4951760157141521099596496896, 9903520314283042199192993792, 19807040628566084398385987584, 39614081257132168796771975168, 79228162514264337593543950336, 158456325028528675187087900672, 316912650057057350374175801344, 633825300114114700748351602688, 1267650600228229401496703205376, 2535301200456458802993406410752, 5070602400912917605986812821504, 10141204801825835211973625643008, 20282409603651670423947251286016, 40564819207303340847894502572032, 81129638414606681695789005144064, 162259276829213363391578010288128, 324518553658426726783156020576256, 649037107316853453566312041152512, 1298074214633706907132624082305024, 2596148429267413814265248164610048, 5192296858534827628530496329220096, 10384593717069655257060992658440192, 20769187434139310514121985316880384, 41538374868278621028243970633760768, 83076749736557242056487941267521536, 166153499473114484112975882535043072, 332306998946228968225951765070086144, 664613997892457936451903530140172288, 1329227995784915872903807060280344576, 2658455991569831745807614120560689152, 5316911983139663491615228241121378304, 10633823966279326983230456482242756608, 21267647932558653966460912964485513216, 42535295865117307932921825928971026432, 85070591730234615865843651857942052864] -[0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387903] -[-1, -1, -2, -4, -8, -16, -32, -64, -128, -256, -512, -1024, -2048, -4096, -8192, -16384, -32768, -65536, -131072, -262144, -524288, -1048576, -2097152, -4194304, -8388608, -16777216, -33554432, -67108864, -134217728, -268435456, -536870912, -1073741824, -2147483648, -4294967296, -8589934592, -17179869184, -34359738368, -68719476736, -137438953472, -274877906944, -549755813888, -1099511627776, -2199023255552, -4398046511104, -8796093022208, -17592186044416, -35184372088832, -70368744177664, -140737488355328, -281474976710656, -562949953421312, -1125899906842624, -2251799813685248, -4503599627370496, -9007199254740992, -18014398509481984, -36028797018963968, -72057594037927936, -144115188075855872, -288230376151711744, -576460752303423488, -1152921504606846976, -2305843009213693952, -4611686018427387904] +[0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741823] +[-1, -1, -2, -4, -8, -16, -32, -64, -128, -256, -512, -1024, -2048, -4096, -8192, -16384, -32768, -65536, -131072, -262144, -524288, -1048576, -2097152, -4194304, -8388608, -16777216, -33554432, -67108864, -134217728, -268435456, -536870912, -1073741824] [0, 2, 4, 8, 16, 32, 64, 128] [0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768] [0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648] [0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808] [0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808, 18446744073709551616, 36893488147419103232, 73786976294838206464, 147573952589676412928, 295147905179352825856, 590295810358705651712, 1180591620717411303424, 2361183241434822606848, 4722366482869645213696, 9444732965739290427392, 18889465931478580854784, 37778931862957161709568, 75557863725914323419136, 151115727451828646838272, 302231454903657293676544, 604462909807314587353088, 1208925819614629174706176, 2417851639229258349412352, 4835703278458516698824704, 9671406556917033397649408, 19342813113834066795298816, 38685626227668133590597632, 77371252455336267181195264, 154742504910672534362390528, 309485009821345068724781056, 618970019642690137449562112, 1237940039285380274899124224, 2475880078570760549798248448, 4951760157141521099596496896, 9903520314283042199192993792, 19807040628566084398385987584, 39614081257132168796771975168, 79228162514264337593543950336, 158456325028528675187087900672, 316912650057057350374175801344, 633825300114114700748351602688, 1267650600228229401496703205376, 2535301200456458802993406410752, 5070602400912917605986812821504, 10141204801825835211973625643008, 20282409603651670423947251286016, 40564819207303340847894502572032, 81129638414606681695789005144064, 162259276829213363391578010288128, 324518553658426726783156020576256, 649037107316853453566312041152512, 1298074214633706907132624082305024, 2596148429267413814265248164610048, 5192296858534827628530496329220096, 10384593717069655257060992658440192, 20769187434139310514121985316880384, 41538374868278621028243970633760768, 83076749736557242056487941267521536, 166153499473114484112975882535043072, 332306998946228968225951765070086144, 664613997892457936451903530140172288, 1329227995784915872903807060280344576, 2658455991569831745807614120560689152, 5316911983139663491615228241121378304, 10633823966279326983230456482242756608, 21267647932558653966460912964485513216, 42535295865117307932921825928971026432, 85070591730234615865843651857942052864, 170141183460469231731687303715884105728] -[0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904] -[-2, -4, -8, -16, -32, -64, -128, -256, -512, -1024, -2048, -4096, -8192, -16384, -32768, -65536, -131072, -262144, -524288, -1048576, -2097152, -4194304, -8388608, -16777216, -33554432, -67108864, -134217728, -268435456, -536870912, -1073741824, -2147483648, -4294967296, -8589934592, -17179869184, -34359738368, -68719476736, -137438953472, -274877906944, -549755813888, -1099511627776, -2199023255552, -4398046511104, -8796093022208, -17592186044416, -35184372088832, -70368744177664, -140737488355328, -281474976710656, -562949953421312, -1125899906842624, -2251799813685248, -4503599627370496, -9007199254740992, -18014398509481984, -36028797018963968, -72057594037927936, -144115188075855872, -288230376151711744, -576460752303423488, -1152921504606846976, -2305843009213693952, -4611686018427387904] +[0, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824] +[-2, -4, -8, -16, -32, -64, -128, -256, -512, -1024, -2048, -4096, -8192, -16384, -32768, -65536, -131072, -262144, -524288, -1048576, -2097152, -4194304, -8388608, -16777216, -33554432, -67108864, -134217728, -268435456, -536870912, -1073741824] [11, 0, 1, 2, 0, 11] [11, 0, 1, 2, 0, 11] @@ -23,14 +23,14 @@ Main> -9223372036854775808 [11, 0, 1, 2, 0, 11] [11, 0, 1, 2, 0, 11] [11, 0, 1, 2, 0, 11] -[9223372036854775797, 0, 1, 0, 4, 1, -9223372036854775808, -11, -12, -12, -11] +[2147483637, 0, 1, 0, 4, 1, -2147483648, -11, -12, -12, -11] [255, 11, 11, 11, 15, 11] [65535, 11, 11, 11, 15, 11] [4294967295, 11, 11, 11, 15, 11] [18446744073709551615, 11, 11, 11, 15, 11] [340282366920938463463374607431768211455, 11, 11, 11, 15, 11] -[9223372036854775807, 11, 11, 11, 15, 11] +[2147483647, 11, 11, 11, 15, 11] [-1, -11, -11, -9, -11, -1, -11, -1, -1, -3, -11] [244, 11, 10, 9, 15, 0] @@ -38,6 +38,6 @@ Main> -9223372036854775808 [4294967284, 11, 10, 9, 15, 0] [18446744073709551604, 11, 10, 9, 15, 0] [340282366920938463463374607431768211444, 11, 10, 9, 15, 0] -[9223372036854775796, 11, 10, 9, 15, 0] -[-9223372036854775798, -11, -12, -9, -15, -2, 9223372036854775797, 10, 11, 9, 0] +[2147483636, 11, 10, 9, 15, 0] +[-2147483638, -11, -12, -9, -15, -2, 2147483637, 10, 11, 9, 0] Main> Bye for now! diff --git a/tests/idris2/coverage018/expected b/tests/idris2/coverage018/expected index 889d8d34e..7e12cbff1 100644 --- a/tests/idris2/coverage018/expected +++ b/tests/idris2/coverage018/expected @@ -20,8 +20,7 @@ Compiled: [{arg:0}]: (%case !{arg:0} [(%constcase 0 0)] Just (%let {e:0} (-Integ Refers to: [Prelude.Basics.True, Prelude.Basics.False] Refers to (runtime): [] Flags: [allguarded, covering] -Issue1831_1> -Bye for now! +Issue1831_1> Bye for now! 1/1: Building Issue1831_2 (Issue1831_2.idr) Issue1831_2> Issue1831_2.test2 ==> [{arg:0}]; Compile time tree: case {arg:0}[0] : [__] of @@ -44,5 +43,4 @@ Compiled: [{arg:0}]: (%case !{arg:0} [(%constcase 0 0)] Just (%let {e:0} (-Integ Refers to: [Prelude.Basics.True, Prelude.Basics.False] Refers to (runtime): [] Flags: [allguarded, covering] -Issue1831_2> -Bye for now! +Issue1831_2> Bye for now! diff --git a/tests/idris2/literate009/input b/tests/idris2/literate009/input index 595df9cca..e37cc0415 100644 --- a/tests/idris2/literate009/input +++ b/tests/idris2/literate009/input @@ -1,4 +1,4 @@ :ml 16 succNotZero :ml 19 recNotEqLift -:gd 11 recNotEq +:gd 12 recNotEq :q diff --git a/tests/idris2/perror010/expected b/tests/idris2/perror010/expected index cbb8ddc48..6cc9e301d 100644 --- a/tests/idris2/perror010/expected +++ b/tests/idris2/perror010/expected @@ -36,5 +36,4 @@ TrailingLam:3:9--3:22 ^^^^^^^^^^^^^ Main> 1 hole: Main.a : Nat -> Nat -Main> -Bye for now! +Main> Bye for now! diff --git a/tests/jvm/jvm012/array.idr b/tests/jvm/jvm012/array.idr index 209677fa2..83fa302ac 100644 --- a/tests/jvm/jvm012/array.idr +++ b/tests/jvm/jvm012/array.idr @@ -1,10 +1,21 @@ import Data.IOArray +import System + main : IO () main = do x <- newArray 20 - writeArray x 10 "Hello" - writeArray x 11 "World" + True <- writeArray x 10 "Hello" + | False => do putStrLn "should success 1" + exitFailure + True <- writeArray x 11 "World" + | False => do putStrLn "should success 2" + exitFailure + + False <- writeArray x 20 "World" + | True => do putStrLn "should fail" + exitFailure + printLn !(toList x) y <- fromList (map Just [1,2,3,4,5])