Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
4a760c3
Refactored and added implicit wrapper
AntoniosBarotsis Mar 5, 2022
1f9a881
Made use of the implicit wrapper
AntoniosBarotsis Mar 5, 2022
e901aee
Merge branch 'master' into dev
pijuskri Mar 6, 2022
7b6aade
Refactored
AntoniosBarotsis Mar 6, 2022
86cb412
Moved package to the top
AntoniosBarotsis Mar 6, 2022
c8fec3b
exception message
pijuskri Mar 6, 2022
07b0156
anonymous lambdas
pijuskri Mar 7, 2022
fd215bb
some coding
pijuskri Mar 20, 2022
5656e4c
Made package top level
AntoniosBarotsis Mar 25, 2022
e509201
Added compile error clarification
AntoniosBarotsis Mar 25, 2022
1c44240
Added simple coverage
AntoniosBarotsis Mar 26, 2022
f383bee
Trying to resolve pipeline issue
AntoniosBarotsis Mar 26, 2022
b014e99
Upped gradle version and trying different JDK
AntoniosBarotsis Mar 26, 2022
f0aa3c2
Removed '|'s
AntoniosBarotsis Mar 26, 2022
e43f40f
Switching WSL to an Ubuntu distro
AntoniosBarotsis Mar 26, 2022
0972bcf
Using cache
AntoniosBarotsis Mar 26, 2022
fa7c4fa
idk
AntoniosBarotsis Mar 26, 2022
e1e29bd
Hol up
AntoniosBarotsis Mar 26, 2022
8f19a8b
Removed random newline
AntoniosBarotsis Mar 26, 2022
093a32f
Moved synchronized block back
AntoniosBarotsis Mar 26, 2022
b93e258
Merge branch 'pijuskri:dev' into dev
AntoniosBarotsis Mar 30, 2022
db66f7d
Separated coverage to a separate task
AntoniosBarotsis Mar 30, 2022
f877c38
Switched to codecov export
AntoniosBarotsis Mar 30, 2022
1ed2a3e
Adding codecov in the workflow
AntoniosBarotsis Mar 30, 2022
d0efa44
Removed verbose flag
AntoniosBarotsis Mar 30, 2022
3dc6b03
Merge pull request #9 from AntoniosBarotsis/dev
pijuskri Mar 30, 2022
8f68b21
Added veritas README
AntoniosBarotsis Apr 4, 2022
6b4f964
Added helper class
AntoniosBarotsis Apr 4, 2022
c5478df
Referenced Veritas
AntoniosBarotsis Apr 5, 2022
d238197
Made JSON coverage export optional
AntoniosBarotsis Apr 5, 2022
1c76b98
Added workflow dispatch trigger
AntoniosBarotsis Apr 5, 2022
43ac3b6
makefile works
pijuskri Apr 7, 2022
8bda66d
Did gradle refactoring
AntoniosBarotsis Apr 8, 2022
97e9d0b
Switched to kotlin
AntoniosBarotsis Apr 28, 2022
2b277b2
Merge pull request #10 from AntoniosBarotsis/gradleOptimizations
pijuskri Apr 28, 2022
b0a90d1
Merge branch 'dev' into multiple-files
pijuskri Apr 28, 2022
cb6868a
import functions and objects
pijuskri May 1, 2022
c0c3875
file path support
pijuskri May 13, 2022
a2cf1f4
static methods
pijuskri May 16, 2022
1e1f67a
Removed random run
AntoniosBarotsis Jun 15, 2022
6899823
Fixed linux bug
AntoniosBarotsis Jun 15, 2022
b9accc8
Created toast workflow
AntoniosBarotsis Jun 15, 2022
561abba
Updated github workflow
AntoniosBarotsis Jun 15, 2022
9fb1836
Removed failing test
AntoniosBarotsis Jun 15, 2022
b75d323
Fixed env?
AntoniosBarotsis Jun 15, 2022
cd1f24c
Trying to add coverage report
AntoniosBarotsis Jun 15, 2022
a019552
Debugging env
AntoniosBarotsis Jun 15, 2022
1a43716
Never using inline if elses ever again
AntoniosBarotsis Jun 15, 2022
181da43
work ffs
AntoniosBarotsis Jun 15, 2022
cf9ac69
Removed debugging stage
AntoniosBarotsis Jun 15, 2022
940f155
TRUEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
AntoniosBarotsis Jun 15, 2022
c0b1a62
Hoping this works, didnt really test it
AntoniosBarotsis Jul 7, 2022
80d26d4
fix veritas
pijuskri Jul 19, 2022
7f417b9
very basic start
pijuskri Jul 20, 2022
12e69d8
working variables
pijuskri Jul 21, 2022
09935e8
ifs
pijuskri Jul 21, 2022
ab06865
arrays, and, or, while
pijuskri Jul 22, 2022
b8dbd41
function calls
pijuskri Jul 23, 2022
7a02349
Enabled config caching
AntoniosBarotsis Jul 25, 2022
84ab105
Moved dependencies to the beginning
AntoniosBarotsis Jul 25, 2022
71fb932
Fixed some warning
AntoniosBarotsis Jul 25, 2022
689ee96
done with objects
pijuskri Jul 26, 2022
ef8d896
Merged LLVM
AntoniosBarotsis Jul 28, 2022
4b95674
Fixed tests ?
AntoniosBarotsis Jul 28, 2022
90da936
Updated some gradle stuff
AntoniosBarotsis Jul 30, 2022
3fb413f
Moved some code around and fixed pipeline bug
AntoniosBarotsis Jul 30, 2022
b2ed088
Created docker image for running the tests
AntoniosBarotsis Jul 30, 2022
e8b317f
Updated toast file
AntoniosBarotsis Jul 30, 2022
664313a
Merge branch 'llvm' into linuxepic
AntoniosBarotsis Jul 30, 2022
3cf7441
Fixed missing file issue
AntoniosBarotsis Jul 30, 2022
13dae04
Made the gradle wrapper executable
AntoniosBarotsis Jul 30, 2022
88ffd3a
Made the gradle wrapper executable?
AntoniosBarotsis Jul 30, 2022
2226449
Made the gradle wrapper executable!
AntoniosBarotsis Jul 30, 2022
e39368d
Fixed env variable
AntoniosBarotsis Jul 30, 2022
944e299
Merge pull request #11 from pijuskri/linuxepic
pijuskri Jul 31, 2022
da72aec
overloading and type inference
pijuskri Sep 12, 2022
4d9a5fa
strings, exceptions
pijuskri Sep 12, 2022
3a6b07b
imports, arrays with default
pijuskri Sep 18, 2022
7672cae
dumb
pijuskri Oct 17, 2022
ddcfe6e
no more segment
pijuskri Oct 19, 2022
5280b73
bug found, arrays working
pijuskri Oct 20, 2022
f6cd90c
casts
pijuskri Oct 22, 2022
b745986
fixed multiple files
pijuskri Oct 31, 2022
8f95f9c
Merge branch 'llvm' into dev
pijuskri Oct 31, 2022
bd6d436
small fix to overloading
pijuskri Oct 31, 2022
b345860
Added `opaque pointers` flag (requires LLVM 15)
AntoniosBarotsis Oct 31, 2022
ca78224
Fixed warnings
AntoniosBarotsis Oct 31, 2022
a654f8d
gradle pls
pijuskri Nov 4, 2022
a3eb413
Bumped versions
AntoniosBarotsis Nov 4, 2022
0cc5578
stuff
AntoniosBarotsis Nov 4, 2022
005b0cb
Removed 'cat'
AntoniosBarotsis Nov 8, 2022
30df5da
Removed old comment
AntoniosBarotsis Nov 8, 2022
7efde68
Consistent badge style
AntoniosBarotsis Nov 8, 2022
d982d3f
Most advanced error prevention
AntoniosBarotsis Nov 8, 2022
c0ca297
gradle deth
pijuskri Jan 5, 2023
592e1b2
Fixed CI badge
AntoniosBarotsis Jan 6, 2023
e7a7f5a
more doc
pijuskri Feb 28, 2023
82021de
templating for funcs
pijuskri Mar 3, 2023
17454f2
better generic function impl
pijuskri Dec 22, 2023
83eb344
implemented generic classes
pijuskri Dec 24, 2023
a15c12f
added test
pijuskri Dec 25, 2023
a43c36c
reflection based ast tree traversal
pijuskri Dec 26, 2023
a9ed1ee
cleanup
pijuskri Dec 26, 2023
c523a52
conversion structure rework
pijuskri Jan 4, 2024
d41c579
all usertypes presume current file namespace
pijuskri Jan 5, 2024
bacb913
module prefix implemented
pijuskri Jan 5, 2024
707ff11
template imports work, changed constructor syntax
pijuskri Jan 6, 2024
6593173
fix var access parsing
pijuskri Jan 10, 2024
c8e1b60
Merge branch 'import-rework' into dev
pijuskri Jan 10, 2024
d6f0af3
Remove `scala-reflect`
AntoniosBarotsis Jan 11, 2024
575c5a6
Fix outdated test code
AntoniosBarotsis Jan 11, 2024
b73e368
migrated to scala 3
pijuskri Jan 11, 2024
96f6994
Merge branch 'dev' into removeScalaReflect
pijuskri Jan 11, 2024
dd25f40
unreflect the testing framework
AntoniosBarotsis Jan 11, 2024
40e93af
Move test classes to top const
AntoniosBarotsis Jan 11, 2024
213a713
document test class discoverability
AntoniosBarotsis Jan 11, 2024
2652600
Move readme up
AntoniosBarotsis Jan 11, 2024
c83cf29
Merge pull request #14 from pijuskri/removeScalaReflect
pijuskri Jan 13, 2024
bf0e03b
lambdas without closures
pijuskri Jan 15, 2024
00093ef
lambdas with closures
pijuskri Jan 16, 2024
ca46ec9
recursive lambdas
pijuskri Jan 16, 2024
4320a18
cleanup
pijuskri Feb 12, 2024
288e69e
Dynamic array lib
pijuskri May 9, 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: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bin/
build/
69 changes: 11 additions & 58 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,19 @@
name: Build and Test

on:
workflow_dispatch:
push:
branches:
- "master"
pull_request:

jobs:
gradle:
runs-on: windows-2022
steps:
- uses: actions/checkout@v2

- name: Set up WSL
uses: Vampire/setup-wsl@v1

- uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 17

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
with:
gradle-version: 7.3

- name: Execute Gradle build
run: gradle build

- name: Install dependencies
shell: wsl-bash {0}
run: |
apt update
apt install make nasm gcc -y

- name: Run tests
run: gradle runTests


# Ubuntu workflow, something goes wrong in the test, perhaps fix in the future
# gradle:
# runs-on: ubuntu-20.04
# steps:
# - uses: actions/checkout@v2

# - uses: actions/setup-java@v2
# with:
# distribution: temurin
# java-version: 17

# - name: Setup Gradle
# uses: gradle/gradle-build-action@v2
# with:
# gradle-version: 7.3

# - name: Execute Gradle build
# run: gradle build

# - name: Install dependencies
# run: |
# sudo apt update
# sudo apt install make nasm gcc -y

# - name: Run tests
# run: gradle runTests
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: stepchowfun/toast/.github/actions/toast@main
env:
args: -PextraArgs=export -q
- uses: codecov/codecov-action@v2
with:
files: coverage.json
9 changes: 7 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ project/plugins/project/
.cache
.lib/

/compiled
**/compiled
/.bsp


Expand All @@ -168,4 +168,9 @@ gradle-app.setting
# JDT-specific (Eclipse Java Development Tools)
.classpath

toCompile.txt
app/po_src
po_src/*
!po_src/lib
coverage.json
pwndbg/
debugir
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# antoniosbarotsis/posharp-veritas
# Packages all project dependencies

FROM openjdk:17-jdk-slim

RUN apt-get update -y && \
apt-get install -y gcc make curl dos2unix lsb-release wget software-properties-common gnupg

COPY llvm.sh llvm.sh
RUN chmod +x llvm.sh
RUN dos2unix llvm.sh
RUN ./llvm.sh 15

RUN mv /usr/bin/llc-15 /usr/bin/llc

COPY *.gradle gradle.* gradlew ./
COPY gradle/ ./gradle/
29 changes: 15 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
TARGET_FILE = 'hello'

all: run
all: run_llvm

#assemble hello.asm
build:
mkdir -p compiled && \
cd compiled/ && \
nasm -felf64 $(TARGET_FILE).asm && \
gcc -O0 -ggdb -no-pie $(TARGET_FILE).o -o $(TARGET_FILE)

#compile and run asm
run: build
llc $(TARGET_FILE).ll -opaque-pointers && \
gcc -O0 -ggdb -no-pie $(TARGET_FILE).s -o $(TARGET_FILE)
compiled/$(TARGET_FILE)

#compile Po# using sbt and then run it, also running the generated .asm
full: sbt run
#compile all files in directory
.PHONY: build_all
build_all:
bash ./build.sh

build_all_llvm:
bash ./build-llvm.sh

#compile Po# compiler
sbt:
sbt --batch -Dsbt.server.forcestart=true run
#compile and run asm
run_llvm: build_all_llvm
compiled/$(TARGET_FILE)

# for some example on the internet, the gcc compiler has issues
standalone:
nasm -f elf hello.asm && ld -m elf_i386 hello.o -o hello && ./hello
run_asm: build_all
compiled/$(TARGET_FILE)

#valgrind --leak-check=full --track-origins=yes --dsymutil=yes ./hello
60 changes: 32 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
-->

<p align="center">
<img src='logo.png' alt="">
<img src='docs/logo.png' alt="">
</p>

[![Contributors][contributors-shield]][contributors-url]
[![Issues][issues-shield]][issues-url]
[![MIT License][license-shield]][license-url]
[![LinkedIn][linkedin-shield]][linkedin-url]
[![Build and Test](https://github.com/pijuskri/Po-Sharp/actions/workflows/workflow.yml/badge.svg?branch=master)](https://github.com/pijuskri/Po-Sharp/actions/workflows/workflow.yml)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/pijuskri/Po-Sharp/workflow.yml?label=Build%20and%20Test&style=for-the-badge)](https://github.com/pijuskri/Po-Sharp/actions/workflows/workflow.yml)


<h2 align="center">Po#</h2>
<div>
<p align="center">
Custom language compiler to X86_64 nasm assembly, written in Scala
Custom language frontend for LLVM IR, written in Scala
<br />
<br />
</p>
Expand Down Expand Up @@ -83,36 +83,38 @@ to translate to assembly.

* [Scala](https://www.scala-lang.org/)
* [FastParse](https://github.com/com-lihaoyi/fastparse)
* [LLVM](https://llvm.org/)

<!-- GETTING STARTED -->
### Prerequisites
<div id="prerequisites"></div>

* [Ubuntu 18.04]() and/or [WSL](https://docs.microsoft.com/en-us/windows/wsl/install)
* [Ubuntu 18.04 or newer]() and/or [WSL](https://docs.microsoft.com/en-us/windows/wsl/install)
* [JDK 13+](https://www.oracle.com/java/technologies/downloads/)
* [Scala 2.13](https://www.scala-lang.org/download/)
* [SBT 1.6.1](https://www.scala-sbt.org/download.html)
* [NASM](https://www.nasm.us/)
* [Scala 2.13+](https://www.scala-lang.org/download/)
* [JDK 11+](https://www.oracle.com/java/technologies/downloads/)
* [Gradle 7.5](https://gradle.org/install/)
* [GCC](https://gcc.gnu.org/)
* [Clang 15+](https://releases.llvm.org/)
* [LLVM 15+](https://releases.llvm.org/download.html)

### Getting Started
<div id="getting-started"></div>

Currently, I run the scala compiler through IntelliJ. The conversion from
assembly to binary is handled by a makefile, that i run in WSL with ubuntu 18;
1. All prerequisites should be installed and verified.
2. Create a .txt file in ``/po_src/`` which will act as the main source file
3. Create a main function
4. To compile to llvm, run ```gradle app:run```
5. To run,

There is also an option to compile with a single command using sbt. Just run `make full`
in the main directory

For now the code that is interpreted can be typed in the Main object. The assembly file
will be generated in `compiled/hello.asm` (do not ask why I named it that).
With gradle
* In root directory call `make full`

With IntelliJ
* Run `Main.scala`
* In root directory call `make`
[//]: # (TODO Does this still work? Probably a good idea to use gradle instead)

With sbt
* In root directory call `make full`
A [testing framework](./veritas/src/main/scala/core/) is also included in the project.
To run the language tests do `gradle runTests`. The documentation can be found
[here](./veritas/src/main/scala/README.md).

### Language specification
<div id="language"></div>
Expand Down Expand Up @@ -150,26 +152,28 @@ def fib(n: int): int {
* Strings
* Enums
* Objects
* runtime exceptions
* multiple files
* lambda functions
* Generics

### To do
<div id="todo"></div>

#### Major

* Generics
* runtime exceptions
* Object inheritance
* lambda functions
* library functions
* typeof
* Garbage collector
* multiple files
* Fully functional import/export system
* Extension methods
* Garbage collector/manual memory
* packages
* File i/o
* library functions
* Optimisation

#### Minor

* Tuples
* typeof
* Structs
* ref/out
* Type alias
Expand All @@ -195,4 +199,4 @@ def fib(n: int): int {
[forks-url]: https://github.com/github_username/repo_name/network/members
[stars-shield]: https://img.shields.io/github/stars/github_username/repo_name.svg?style=for-the-badge
[stars-url]: https://github.com/github_username/repo_name/stargazers
[product-screenshot]: logo.png
[product-screenshot]: docs/logo.png
29 changes: 0 additions & 29 deletions app/Makefile

This file was deleted.

50 changes: 0 additions & 50 deletions app/build.gradle

This file was deleted.

18 changes: 18 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
plugins {
scala
application
}

repositories {
mavenCentral()
}

dependencies {
implementation("org.scala-lang:scala3-library_3:3.3.1")
implementation("com.lihaoyi:fastparse_3:3.0.2")
implementation("co.blocke:scala-reflection_3:2.0.0")
}

application {
mainClass.set("posharp.Main")
}
1 change: 1 addition & 0 deletions app/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "app"
Loading