Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

analyzer: Proper implementation of type casts #105

Merged
merged 24 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f2fb53c
analyzer: Make type casting tests work again
delasy Oct 3, 2024
32d20d3
parser: Re-export TokenType
delasy Oct 3, 2024
53dc735
analyzer: Cover binary expression with tests
delasy Oct 4, 2024
31c1f29
analyzer: Code split statement function
delasy Oct 7, 2024
5b50a7b
analyzer: Cover IfStatement with type casting tests
delasy Oct 7, 2024
a00c9d6
analyzer: Display IsExpression type cast with print
delasy Oct 7, 2024
a4620a3
analyzer: Remove `largest` function
delasy Oct 8, 2024
71f8900
analyzer: Finish canBeCast, stringifyTC todos
delasy Oct 8, 2024
1b3ae45
analyzer: Add more tests for IsExpression, Literals
delasy Oct 8, 2024
891328b
analyzer: Type narrow VariableDeclaration initializer
delasy Oct 8, 2024
f0b3296
parser: Ability to treat assignment as access expression
delasy Oct 8, 2024
69d69f1
analyzer: Use access methods from parser package
delasy Oct 8, 2024
221f48d
analyzer: Cover TypeMap union methods with tests
delasy Oct 9, 2024
5574aa9
analyzer: Cover context with tests and docs
delasy Oct 9, 2024
d1fdb89
Remove dependency of running pre-process-codegen
delasy Oct 10, 2024
fc3c885
Add installation instructions
delasy Oct 10, 2024
3f72238
parser: Remove hasFunctionOrMainParent method
delasy Oct 10, 2024
5eb0a63
analyzer: Stop using hasFunctionOrMainParent
delasy Oct 10, 2024
74f43a9
analyzer: Fix AsExpression context target type
delasy Oct 10, 2024
2842c81
analyzer: Cover expression context print with tests
delasy Oct 10, 2024
08296de
analyzer: Cover analyzer-print with tests
delasy Oct 11, 2024
7fde53e
analyzer: Cover type function with tests
delasy Oct 11, 2024
05248b3
parser: Add context extra field to Expression
delasy Oct 11, 2024
690822e
analyzer: Change the way context extra is handled
delasy Oct 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/cross-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
platform: windows
steps:
- uses: actions/checkout@v4
- uses: thelang-io/setup-the@v1
- run: sudo apt-get update
- run: sudo apt-get install mingw-w64 ninja-build
- run: curl -fsSL https://cdn.thelang.io/deps.tar.gz | sudo tar -C /usr/local -xz
Expand All @@ -42,7 +41,6 @@ jobs:
run: echo "DEPS_DIR=/usr/local/the/cross-compile/${{ matrix.config.platform }}" >> $GITHUB_ENV
- run: echo "/usr/local/the/osxcross/bin" >> $GITHUB_PATH
- run: sudo sed -i 's/#define _WIN32_WINNT .*/#define _WIN32_WINNT 0x0A00/' /usr/share/mingw-w64/include/_mingw.h
- run: the run scripts/pre-process-codegen
- run: cmake . -B ./build -G Ninja -D BUILD_TESTS=ON -D TEST_CODEGEN_PLATFORM=${{ matrix.config.platform }}
- run: cmake --build build
- run: ctest --output-on-failure --test-dir build
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: thelang-io/setup-the@v1
- run: the run scripts/pre-process-codegen
- run: cmake -B ./build -D CMAKE_BUILD_TYPE=Release
- run: cmake --build build
- uses: aws-actions/configure-aws-credentials@v1
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
generator: Visual Studio 17 2022
steps:
- uses: actions/checkout@v4
- uses: thelang-io/setup-the@v1
- if: runner.os == 'Linux'
run: |
sudo apt-get update
Expand All @@ -49,8 +48,6 @@ jobs:
run: brew install ninja
- if: runner.os != 'Windows'
run: uname -a
- run: the -v
- run: the run scripts/pre-process-codegen
- run: curl -fsSL https://cdn.thelang.io/deps.tar.gz -o deps.tar.gz
- run: tar -xzf deps.tar.gz the/native/${{ matrix.config.platform }}
- if: runner.os == 'Linux'
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
build/
coverage/
lab/
src/codegen-api.hpp
*.out
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ RUN apt-get update && \

RUN curl -fsSL https://cdn.thelang.io/deps.tar.gz | tar -xz
ENV DEPS_DIR="$PWD/the/native/linux"
RUN curl -fsSL https://cdn.thelang.io/cli | bash

WORKDIR /app
COPY . .
RUN the run scripts/pre-process-codegen
RUN cmake . -G Ninja -D BUILD_TESTS=ON -D TEST_CODEGEN_MEMCHECK=ON
RUN cmake --build .

Expand Down
124 changes: 124 additions & 0 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# How To Install
Updated: Oct 10, 2024

> [!important]
> I tested it only on macOS. Windows commands is what I remember of how it should work.
> If you have suggestions feel free to tell me on Discord or create a PR.

## CLI
First you need CLI to orchestrate the compiler.

For Unix:
```sh
curl -fsSL sh.thelang.io | bash
```

In case you are curious what it does,
you can check here: https://github.com/thelang-io/cli/blob/main/install.sh

For Windows:
```powershell
irm ps1.thelang.io | iex
```

If that doesn't work, try this one:
```powershell
(New-Object System.Net.WebClient).DownloadString('https://ps1.thelang.io/') | iex
```

In case you are curious what it does,
you can check here: https://github.com/thelang-io/cli/blob/main/install.ps1

## Test CLI Installation

```sh
the -v
```

If that doesn't work you probably need to re-login into your terminal.

## Before Downloading Compiler
Before, everything was compiled on cloud servers.
After Oct 2024, I disabled cloud servers (I paid $600 for the last year and nobody used it).
To compile you will need a compiler now :)

Before you will get a compiler you will need to have CMake installed: https://cmake.org/download/

Next thing you need to download prebuilt dev version of OpenSSL
from: https://cdn.thelang.io/deps.tar.gz and unpack the file.
It will contain folder "native" with your platform inside of it.
This is needed by compiler itself when you are compiling programs that require SSL support.

After that you need to create system environment variable or add it to your `~/.profile`:
```
DEPS_DIR="path/to/native/$platform"
```

## Building Compiler
This is how to build a compiler from source on Unix:
```sh
git clone --depth=1 -b feat-new-codegen --single-branch https://github.com/thelang-io/the.git
cmake the -B the/build -D CMAKE_BUILD_TYPE=Release
cmake --build the/build
cp the/build/the ~/.the/bin/thex
rm -rf the
```

And this is how to build a compiler from source on Windows:
```powershell
git clone --depth=1 -b feat-new-codegen --single-branch https://github.com/thelang-io/the.git
cmake the -B the/build -D CMAKE_BUILD_TYPE=Release
cmake --build the/build
Copy-Item "the/build/Debug/the.exe" -Destination "$env:UserProfile/The/bin/thex.exe"
Remove-Item -Recurse -Force the
```

That should be it!

## Test Installation
Create a file, eg "main.the":

```the
main {
print("Hello, World")
}
```

And run it like this:

```sh
the run main.the --compiler=thex
```

> [!important]
> If you don't add `--compiler=thex` it will try to run on cloud server, and you will get an error.

## Further Reading
Remember, this is old version that is built using C++.
This version is slow, and I'm aware of that.
The new version, where it's much faster and self-compiles, is still in development.
Expected to be released by the end of 2024.

1. [Comments](https://docs.thelang.io/guides/comments.html)
2. [Operations](https://docs.thelang.io/guides/operations.html)
3. [Types](https://docs.thelang.io/guides/types.html)
4. [Mutability](https://docs.thelang.io/guides/mutability.html)
5. [Control Flow](https://docs.thelang.io/guides/control-flow.html)
6. [Iteration](https://docs.thelang.io/guides/iteration.html)
7. Types: [Arrays](https://docs.thelang.io/guides/arrays.html) /
[Enumerations](https://docs.thelang.io/guides/enumerations.html) /
[Objects](https://docs.thelang.io/guides/objects.html) /
[Maps](https://docs.thelang.io/guides/maps.html) /
[Unions](https://docs.thelang.io/guides/unions.html) /
[Functions](https://docs.thelang.io/guides/functions.html) /
[Optionals](https://docs.thelang.io/guides/optionals.html) /
[References](https://docs.thelang.io/guides/references.html) /
[Any](https://docs.thelang.io/guides/any.html)
8. [Anonymous Functions (Closures)](https://docs.thelang.io/guides/anonymous-functions.html)
9. [Variadic Parameters](https://docs.thelang.io/guides/variadics.html)
10. [Type Aliasing](https://docs.thelang.io/guides/type-aliasing.html)
11. [Type Checking](https://docs.thelang.io/guides/type-checking.html)
12. [Type Casting](https://docs.thelang.io/guides/type-casting.html)
13. [Error Handling](https://docs.thelang.io/guides/error-handling.html)
14. [Asynchronous Programming](https://docs.thelang.io/guides/asynchronous-programming.html)
15. [Modules](https://docs.thelang.io/guides/modules.html)
Loading
Loading