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

Extend string objects #201

Merged
merged 8 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions .github/workflows/ci-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
build:
name: C++ CI
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: Checkout
Expand All @@ -24,10 +24,10 @@ jobs:
distribution: zulu
java-version: 11

- name: Setup latest GCC and build dependencies
- name: Setup latest Clang and build dependencies
run: |
sudo apt install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11
sudo apt install gcc-12 g++-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 110 --slave /usr/bin/g++ g++ /usr/bin/g++-12 --slave /usr/bin/gcov gcov /usr/bin/gcov-12 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-12 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-12

- name: Setup Ninja
run: sudo apt-get install ninja-build
Expand All @@ -43,14 +43,14 @@ jobs:
uses: actions/cache@v3
with:
path: /home/runner/work/spice/llvm
key: llvm-15.0.0-rc3
key: llvm-15.0.0

- name: Setup LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
cd ..
rm -rf llvm
git clone --depth 1 --branch llvmorg-15.0.0-rc3 https://github.com/llvm/llvm-project llvm
git clone --depth 1 --branch llvmorg-15.0.0 https://github.com/llvm/llvm-project llvm
mkdir ./llvm/build
cd ./llvm/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS_RELEASE="-O2" -GNinja ../llvm
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
analyze-cpp:
name: Analyze C++ Code
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -41,13 +41,13 @@ jobs:
uses: actions/cache@v3
with:
path: /home/runner/work/spice/llvm
key: 15.0.0-rc3
key: 15.0.0

- name: Setup LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
cd ..
git clone --depth 1 --branch llvmorg-15.0.0-rc3 https://github.com/llvm/llvm-project llvm
git clone --depth 1 --branch llvmorg-15.0.0 https://github.com/llvm/llvm-project llvm
mkdir ./llvm/build
cd ./llvm/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS_RELEASE="-O2" -GNinja ../llvm
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:

jobs:
docs-deploy:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -29,4 +29,4 @@ jobs:

- name: Build and deploy
working-directory: docs
run: mkdocs gh-deploy --force
run: mkdocs gh-deploy --force
4 changes: 2 additions & 2 deletions .github/workflows/misspell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ on:

jobs:
spellcheck:
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Misspell
uses: reviewdog/action-misspell@v1
with:
Expand Down
20 changes: 11 additions & 9 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build-compiler-linux:
name: Build compiler binaries - Linux
runs-on: ubuntu-latest
runs-on: ubuntu-22.04

steps:
- name: Checkout
Expand All @@ -30,8 +30,8 @@ jobs:

- name: Setup latest GCC and build dependencies
run: |
sudo apt install gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11
sudo apt install gcc-12 g++-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 110 --slave /usr/bin/g++ g++ /usr/bin/g++-12 --slave /usr/bin/gcov gcov /usr/bin/gcov-12 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-12 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-12

- name: Setup Ninja
uses: seanmiddleditch/gha-setup-ninja@master
Expand All @@ -44,12 +44,12 @@ jobs:
uses: actions/cache@v3
with:
path: /home/runner/work/spice/spice/llvm
key: llvm-15.0.0-rc3-linux-x64
key: llvm-15.0.0-linux-x64

- name: Setup LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch llvmorg-15.0.0-rc3 https://github.com/llvm/llvm-project.git llvm
git clone --depth 1 --branch llvmorg-15.0.0 https://github.com/llvm/llvm-project.git llvm
mkdir ./llvm/build
cd ./llvm/build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS_RELEASE="-O2" -GNinja -Wno-dev -Wattributes ../llvm
Expand Down Expand Up @@ -109,9 +109,9 @@ jobs:
choco uninstall llvm --all-versions
Remove-Item -Recurse -Force C:/Strawberry
echo "Uninstalling done."
Invoke-WebRequest https://chillibits.com/files/gh/mingw64_12_1_0.zip -OutFile mingw64.zip
Invoke-WebRequest https://chillibits.com/files/gh/mingw64_12_2_0.7z -OutFile mingw64.7z
echo "Downloading done."
7z x mingw64.zip -oC:\mingw64
7z x mingw64.7z -oC:\mingw64
echo "Unpacking done."
Copy-Item -Path C:\mingw64\mingw64\bin\mingw32-make.exe -Destination C:\mingw64\mingw64\bin\make.exe
echo "All done."
Expand All @@ -124,12 +124,12 @@ jobs:
uses: actions/cache@v3
with:
path: D:/a/spice/spice/llvm
key: llvm-15.0.0-rc3-win-x64
key: llvm-15.0.0-win-x64

- name: Setup LLVM
if: steps.cache-llvm.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch llvmorg-15.0.0-rc3 https://github.com/llvm/llvm-project.git llvm
git clone --depth 1 --branch llvmorg-15.0.0 https://github.com/llvm/llvm-project.git llvm
setx /M PATH "%PATH%;C:\mingw64\mingw64\bin"
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
echo "Adding MinGW to path done."
Expand Down Expand Up @@ -259,6 +259,7 @@ jobs:

- name: Deploy to Debian / Raspbian repo
run: |
curl -sSf -u "${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}" -H "Content-Type: multipart/form-data" --data-binary "@./spice_${{ matrix.arch }}.deb" "${{ secrets.NEXUS_URL }}/debian-bookworm/"
curl -sSf -u "${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}" -H "Content-Type: multipart/form-data" --data-binary "@./spice_${{ matrix.arch }}.deb" "${{ secrets.NEXUS_URL }}/debian-bullseye/"
curl -sSf -u "${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}" -H "Content-Type: multipart/form-data" --data-binary "@./spice_${{ matrix.arch }}.deb" "${{ secrets.NEXUS_URL }}/debian-buster/"
curl -sSf -u "${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}" -H "Content-Type: multipart/form-data" --data-binary "@./spice_${{ matrix.arch }}.deb" "${{ secrets.NEXUS_URL }}/debian-stretch/"
Expand All @@ -273,6 +274,7 @@ jobs:
curl -sSf -u "${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}" -H "Content-Type: multipart/form-data" --data-binary "@./spice_${{ matrix.arch }}.deb" "${{ secrets.NEXUS_URL }}/ubuntu-bionic/"
curl -sSf -u "${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}" -H "Content-Type: multipart/form-data" --data-binary "@./spice_${{ matrix.arch }}.deb" "${{ secrets.NEXUS_URL }}/ubuntu-xenial/"
curl -sSf -u "${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}" -H "Content-Type: multipart/form-data" --data-binary "@./spice_${{ matrix.arch }}.deb" "${{ secrets.NEXUS_URL }}/ubuntu-trusty/"
curl -sSf -u "${{ secrets.NEXUS_USERNAME }}:${{ secrets.NEXUS_PASSWORD }}" -H "Content-Type: multipart/form-data" --data-binary "@./spice_${{ matrix.arch }}.deb" "${{ secrets.NEXUS_URL }}/ubuntu-jammy/"

- name: Deploy to CentOS repo
run: |
Expand Down
2 changes: 1 addition & 1 deletion .run/Spice_run.run.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Spice_run" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="run -O2 ../../media/test-project/os-test.spice" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Spice" TARGET_NAME="Spice_run" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Spice" RUN_TARGET_NAME="Spice_run">
<configuration default="false" name="Spice_run" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="run -O2 -ir ../../media/test-project/os-test.spice" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Spice" TARGET_NAME="Spice_run" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="Spice" RUN_TARGET_NAME="Spice_run">
<envs>
<env name="RUN_TESTS" value="OFF" />
<env name="SPICE_STD_DIR" value="$PROJECT_DIR$/std" />
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -O2")
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/src/cmake)
add_definitions(-DANTLR4CPP_STATIC)
include(ExternalAntlr4Cpp)
set(ANTLR_EXECUTABLE ${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/antlr-4.10.1-complete.jar)
set(ANTLR_EXECUTABLE ${CMAKE_CURRENT_SOURCE_DIR}/src/thirdparty/antlr-4.11.1-complete.jar)

# Find Google Test
add_subdirectory(lib/googletest)
Expand Down
2 changes: 1 addition & 1 deletion dev-setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ echo done.

REM - Clone LLVM
echo [Step 2] Cloning LLVM (Could take a while) ...
git clone --depth 1 --branch llvmorg-15.0.0-rc3 https://github.com/llvm/llvm-project llvm
git clone --depth 1 --branch llvmorg-15.0.0 https://github.com/llvm/llvm-project llvm
echo done.

REM - Build LLVM
Expand Down
5 changes: 2 additions & 3 deletions dev-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ colored_echo() {
colored_echo "[Step 1] Installing dependencies via Linux packages (Could take a while) ... "
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt update -y
sudo apt-get install -y cmake make ninja-build uuid-dev openjdk-11-jre-headless gcc-11 g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11
sudo apt-get install -y cmake make ninja-build uuid-dev openjdk-11-jre-headless
colored_echo "done."

# Clone LLVM
colored_echo "[Step 2] Cloning LLVM (Could take a while) ... "
git clone --depth 1 --branch llvmorg-15.0.0-rc3 https://github.com/llvm/llvm-project llvm
git clone --depth 1 --branch llvmorg-15.0.0 https://github.com/llvm/llvm-project llvm
colored_echo "done."

# Build LLVM
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/language/enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Enumerations
---

Enumerations in spice work like this:
Enumerations in Spice work like this:

```spice
type Fruit enum {
Expand Down
2 changes: 1 addition & 1 deletion media/setup-guide-windows.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Setup Guide for Windows

- Download and install MinGW64 from [here](https://winlibs.com/)
- Download and install MinGW64 with LLVM from [here](https://winlibs.com/)
- Build LLVM with the included GCC version
- Delete CMake output directories in Spice project and re-build Spice
38 changes: 33 additions & 5 deletions media/test-project/os-test.spice
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
f<int> main() {
printf("Test: %s", "Hi " + "World!");
}

/*import "std/data/vector" as vec;
import "std/data/pair" as pair;

Expand All @@ -17,10 +21,34 @@ f<int> main() {
server.serve("/test", "Hello World!");
}*/

import "std/runtime/string_rt" as _rt_str;
/*import "std/runtime/string_rt" as _rt_str;

f<int> main() {
//_rt_str::String s = _rt_str::String("Test");
//printf("%s", s.getRaw());
// Plus
printf("Result: %s\n", "Hello " + "World!");
string s1 = "Hello " + "World!";
printf("Result: %s\n", s1);
// Mul
printf("Result: %s\n", 4s * "Hi");
string s2 = "Hello " * 5;
printf("Result: %s\n", s2);
printf("Result: %s\n", 20 * 'a');
string s3 = 2 * 'c' * 7;
printf("Result: %s\n", s3);
//printf("%s", s1 + s2);
}*/

/*public f<int> src(int x, int y) {
return x + (x | -x);
}

public f<int> tgt(int x) {
return x & (x - 1);
}

f<int> main() {
string s = "Test";
s *= 3;
printf("%s", s);
}
printf("Src: %d\n", src(21, 10));
printf("Tgt: %d\n", tgt(21));
}*/
2 changes: 1 addition & 1 deletion setup-libs.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
mkdir lib
pushd lib

git clone --depth 1 --branch 4.10.1 https://github.com/antlr/antlr4.git
git clone --depth 1 --branch 4.11.1 https://github.com/antlr/antlr4.git

git clone --depth 1 --branch release-1.12.1 https://github.com/google/googletest.git

Expand Down
2 changes: 1 addition & 1 deletion setup-libs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
mkdir lib
cd lib || exit

git clone --depth 1 --branch 4.10.1 https://github.com/antlr/antlr4.git
git clone --depth 1 --branch 4.11.1 https://github.com/antlr/antlr4.git

git clone --depth 1 --branch release-1.12.1 https://github.com/google/googletest.git

Expand Down
Loading