From cc623779195375883f74b6373017e11048fd5835 Mon Sep 17 00:00:00 2001 From: Mike Nolan Date: Fri, 30 Jan 2026 19:34:45 -0600 Subject: [PATCH] Changing version to 0.0.1 --- .onedev-buildspec.yml | 6 - CMakeLists.txt | 13 +- CrossLangVersion.h.in | 5 + Packaging/CPKG/ConsoleOrServer/CMakeLists.txt | 55 -- Packaging/CPKG/ConsoleOrServer/main.cpp | 76 --- Packaging/CPKG/Wii/CMakeLists.txt | 28 - Packaging/CPKG/Wii/main.cpp | 80 --- Packaging/CPKG/WindowsToolchains/x64.cmake | 7 - Packaging/CPKG/WindowsToolchains/x86.cmake | 7 - Packaging/CPKG/extract_compiler.sh | 9 - Packaging/CPKG/pack.sh | 3 - Packaging/CPKG/pack.tcross | 282 --------- Packaging/CPKG/pack_and_publish.sh | 3 - Packaging/CPKG/publish.sh | 2 - Packaging/CPKG/wiibuild.sh | 8 - Packaging/CPKG/winbuild.sh | 10 - Packaging/Linux/PKGBUILD | 2 +- Packaging/Linux/version.sh | 4 +- docs/CPP_LAYER.md | 1 - docs/EXTENDING_RUNTIME.md | 232 ------- docs/HANDBOOK.md | 598 ------------------ docs/README.md | 7 - docs/WHAT_IS_TOBJECT.md | 16 - include/CrossLang.hpp | 36 +- src/archive.cpp | 2 +- src/assembler/asm.cpp | 2 +- src/compiler/codegen.cpp | 2 +- src/runtime_methods/vm.cpp | 7 +- src/vm/filereader.cpp | 1 + 29 files changed, 38 insertions(+), 1466 deletions(-) create mode 100644 CrossLangVersion.h.in delete mode 100644 Packaging/CPKG/ConsoleOrServer/CMakeLists.txt delete mode 100644 Packaging/CPKG/ConsoleOrServer/main.cpp delete mode 100644 Packaging/CPKG/Wii/CMakeLists.txt delete mode 100644 Packaging/CPKG/Wii/main.cpp delete mode 100644 Packaging/CPKG/WindowsToolchains/x64.cmake delete mode 100644 Packaging/CPKG/WindowsToolchains/x86.cmake delete mode 100644 Packaging/CPKG/extract_compiler.sh delete mode 100644 Packaging/CPKG/pack.sh delete mode 100644 Packaging/CPKG/pack.tcross delete mode 100644 Packaging/CPKG/pack_and_publish.sh delete mode 100644 Packaging/CPKG/publish.sh delete mode 100644 Packaging/CPKG/wiibuild.sh delete mode 100644 Packaging/CPKG/winbuild.sh delete mode 100644 docs/CPP_LAYER.md delete mode 100644 docs/EXTENDING_RUNTIME.md delete mode 100644 docs/HANDBOOK.md delete mode 100644 docs/README.md delete mode 100644 docs/WHAT_IS_TOBJECT.md diff --git a/.onedev-buildspec.yml b/.onedev-buildspec.yml index 311655d..81e5d79 100644 --- a/.onedev-buildspec.yml +++ b/.onedev-buildspec.yml @@ -79,8 +79,6 @@ jobs: cd Packaging/Linux bash build-ubuntu-plucky.sh bash push-ubuntu-plucky.sh - cd ../CPKG - bash winbuild.sh cd ../Windows bash build.sh envVars: @@ -102,10 +100,6 @@ jobs: bash build-ubuntu-jammy.sh bash push-ubuntu-jammy.sh bash build-tars.sh - apt update -y - apt install -y crosslang - cd ../CPKG - bash pack_and_publish.sh envVars: - name: GITEA_AUTH value: '@secret:GITEA_AUTH@' diff --git a/CMakeLists.txt b/CMakeLists.txt index de89638..0e0f89b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.16) -project(TessesCrossLang VERSION 1.0) +set(CROSSLANG_MAJOR_VERSION 0) +set(CROSSLANG_MINOR_VERSION 0) +set(CROSSLANG_PATCH_VERSION 1) + +project(TessesCrossLang VERSION ${CROSSLANG_MAJOR_VERSION}.${CROSSLANG_MINOR_VERSION}.${CROSSLANG_PATCH_VERSION}) set(CMAKE_CXX_STANDARD 17) @@ -78,6 +82,11 @@ if(CROSSLANG_ENABLE_FFI AND CROSSLANG_ENABLE_SHARED) pkg_check_modules(LIBFFI REQUIRED IMPORTED_TARGET libffi) endif() function(CROSSLANG_LINK_DEPS CROSSLANG_TARGET_NAME) +target_include_directories(${CROSSLANG_TARGET_NAME} + PUBLIC + "$" + "$" +) if(CROSSLANG_ENABLE_FFI AND CROSSLANG_ENABLE_SHARED) target_compile_definitions(${CROSSLANG_TARGET_NAME} PUBLIC CROSSLANG_ENABLE_FFI) @@ -245,6 +254,8 @@ install(EXPORT TessesCrossLangTargets configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/TessesCrossLangConfig.cmake" INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/TessesCrossLang) +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/CrossLangVersion.h.in "${CMAKE_CURRENT_BINARY_DIR}/include/CrossLangVersion.h" +INSTALL_DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/CrossLangVersion.h) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/TessesCrossLangConfig.cmake" DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/TessesCrossLang) diff --git a/CrossLangVersion.h.in b/CrossLangVersion.h.in new file mode 100644 index 0000000..dec400e --- /dev/null +++ b/CrossLangVersion.h.in @@ -0,0 +1,5 @@ +#pragma once + +#define CROSSLANG_MAJOR @CROSSLANG_MAJOR_VERSION@ +#define CROSSLANG_MINOR @CROSSLANG_MINOR_VERSION@ +#define CROSSLANG_PATCH @CROSSLANG_PATCH_VERSION@ \ No newline at end of file diff --git a/Packaging/CPKG/ConsoleOrServer/CMakeLists.txt b/Packaging/CPKG/ConsoleOrServer/CMakeLists.txt deleted file mode 100644 index 77452c7..0000000 --- a/Packaging/CPKG/ConsoleOrServer/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(CrossLangPublish) - -option(CROSSAPPPUBLISH_STATIC "Build static version" OFF) - -if(CROSSAPPPUBLISH_STATIC) -set(TESSESFRAMEWORK_ENABLE_RPATH OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_STATIC ON CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_APPS OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_SHARED OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_FETCHCONTENT ON CACHE INTERNAL "For TessesFramework" FORCE) -set(CROSSLANG_ENABLE_BINARIES OFF CACHE INTERNAL "For CrossLang" FORCE) -else() -set(TESSESFRAMEWORK_ENABLE_RPATH OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_STATIC OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_APPS OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_SHARED ON CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_FETCHCONTENT ON CACHE INTERNAL "For TessesFramework" FORCE) -set(CROSSLANG_ENABLE_BINARIES OFF CACHE INTERNAL "For CrossLang" FORCE) -set(CMAKE_INSTALL_BINDIR "." CACHE INTERNAL "For CrossLang" FORCE) -set(CMAKE_INSTALL_LIBDIR "." CACHE INTERNAL "For CrossLang" FORCE) -set(CMAKE_INSTALL_PREFIX "/dir" CACHE INTERNAL "For CrossLang" FORCE) -set(CMAKE_PLATFORM_NO_VERSIONED_SONAME ON CACHE INTERNAL "For CrossLang" FORCE) -set(CMAKE_MACOSX_RPATH 1) -set(CMAKE_BUILD_RPATH_USE_ORIGIN ON CACHE INTERNAL "For CrossLang" FORCE) -if (APPLE) - set(CMAKE_INSTALL_RPATH "@executable_path/" CACHE INTERNAL "For CrossLang" FORCE) -else() - set(CMAKE_INSTALL_RPATH "$ORIGIN/" CACHE INTERNAL "For CrossLang" FORCE) -endif() -endif() - -include(FetchContent) - -FetchContent_Declare( - TessesCrossLang - GIT_REPOSITORY https://onedev.site.tesses.net/crosslang.git -) - -FetchContent_MakeAvailable(TessesCrossLang) - - - -add_executable(crossapp main.cpp) -if(CROSSAPPPUBLISH_STATIC) -target_link_libraries(crossapp PUBLIC crosslang_static) -else() -install(TARGETS crossapp DESTINATION "${CMAKE_INSTALL_BINDIR}") - -target_link_libraries(crossapp PUBLIC crosslang_shared) - -endif() \ No newline at end of file diff --git a/Packaging/CPKG/ConsoleOrServer/main.cpp b/Packaging/CPKG/ConsoleOrServer/main.cpp deleted file mode 100644 index 62b672b..0000000 --- a/Packaging/CPKG/ConsoleOrServer/main.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include -using namespace Tesses::Framework; -using namespace Tesses::CrossLang; -int main(int argc, char** argv) -{ - TF_InitWithConsole(); - if(argc > 0) - TF_AllowPortable(argv[0]); - std::string name = argv[0]; - Tesses::Framework::Filesystem::VFSPath exePath=Tesses::Framework::Filesystem::LocalFS->SystemToVFSPath(name); - exePath.MakeAbsolute(); - exePath.ChangeExtension(".crvm"); - - - - - GC gc; - gc.Start(); - GCList ls(gc); - TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls)); - - TStd::RegisterStd(&gc,env); - env->LoadFileWithDependencies(&gc, Tesses::Framework::Filesystem::LocalFS, exePath); - - - - if(env->HasVariable("WebAppMain")) - { - Args args(argc, argv); - int port = 4206; - for(auto& item : args.options) - { - if(item.first == "port") - { - port = std::stoi(item.second); - } - } - - env->EnsureDictionary(&gc,"Net")->SetValue("WebServerPort", (int64_t)port); - TList* args2 = TList::Create(ls); - args2->Add(exePath.ToString()); - for(auto& item : args.positional) - { - args2->Add(item); - } - - auto res = env->CallFunctionWithFatalError(ls, "WebAppMain", {args2}); - auto svr2 = Tesses::CrossLang::ToHttpServer(&gc,res); - if(svr2 == nullptr) return 1; - Tesses::Framework::Http::HttpServer svr(port,svr2); - svr.StartAccepting(); - TF_RunEventLoop(); - TDictionary* _dict; - TClassObject* _co; - if(GetObjectHeap(res,_dict)) - { - _dict->CallMethod(ls,"Close",{}); - } - if(GetObjectHeap(res,_co)) - { - _co->CallMethod(ls,"","Close",{}); - } - TF_Quit(); - } - else { - TList* args = TList::Create(ls); - args->Add(exePath.ToString()); - for(int arg=1;argAdd(argv[arg]); - auto res = env->CallFunctionWithFatalError(ls,"main",{args}); - int64_t iresult; - if(GetObject(res,iresult)) - return (int)iresult; - } - return 0; -} \ No newline at end of file diff --git a/Packaging/CPKG/Wii/CMakeLists.txt b/Packaging/CPKG/Wii/CMakeLists.txt deleted file mode 100644 index 51dcc8c..0000000 --- a/Packaging/CPKG/Wii/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -cmake_minimum_required(VERSION 3.16) - -project(CrossLangWii) - - -set(TESSESFRAMEWORK_FETCHCONTENT OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_RPATH OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_STATIC ON CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_EXAMPLES OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_APPS OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(TESSESFRAMEWORK_ENABLE_SHARED OFF CACHE INTERNAL "For TessesFramework" FORCE) -set(CROSSLANG_ENABLE_BINARIES OFF CACHE INTERNAL "For CrossLang" FORCE) -set(MBEDTLS_DIR "/opt/devkitpro/portlibs/wii" CACHE INTERNAL "For TessesFramework" FORCE) - -include(FetchContent) - -FetchContent_Declare( - TessesCrossLang - GIT_REPOSITORY https://onedev.site.tesses.net/crosslang.git -) - -FetchContent_MakeAvailable(TessesCrossLang) - - - -add_executable(boot main.cpp) -target_link_libraries(boot PUBLIC crosslang_static) -ogc_create_dol(boot) diff --git a/Packaging/CPKG/Wii/main.cpp b/Packaging/CPKG/Wii/main.cpp deleted file mode 100644 index 4f95c97..0000000 --- a/Packaging/CPKG/Wii/main.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include -using namespace Tesses::Framework; -using namespace Tesses::CrossLang; -int main(int argc, char** argv) -{ - TF_InitWithConsole(); - std::string name = "boot.dol"; - Tesses::Framework::Filesystem::VFSPath exePath=Tesses::Framework::Filesystem::LocalFS->SystemToVFSPath(name); - exePath.MakeAbsolute(); - exePath.ChangeExtension(".crvm"); - - - - - GC gc; - gc.Start(); - GCList ls(gc); - TRootEnvironment* env = TRootEnvironment::Create(ls, TDictionary::Create(ls)); - - TStd::RegisterStd(&gc,env); - env->LoadFileWithDependencies(&gc, Tesses::Framework::Filesystem::LocalFS, exePath); - - - - if(env->HasVariable("WebAppMain")) - { - std::vector argsls={"boot.dol"}; - for(int i = 0; i < argc; i++) - { - argsls.push_back(argv[i]); - } - - Args args(argsls); - int port = 4206; - for(auto& item : args.options) - { - if(item.first == "port") - { - port = std::stoi(item.second); - } - } - - env->EnsureDictionary(&gc,"Net")->SetValue("WebServerPort", (int64_t)port); - TList* args2 = TList::Create(ls); - args2->Add(exePath.ToString()); - for(auto& item : args.positional) - { - args2->Add(item); - } - - auto res = env->CallFunctionWithFatalError(ls, "WebAppMain", {args2}); - auto svr2 = Tesses::CrossLang::ToHttpServer(&gc,res); - if(svr2 == nullptr) return 1; - Tesses::Framework::Http::HttpServer svr(port,svr2); - svr.StartAccepting(); - TF_RunEventLoop(); - TDictionary* _dict; - TClassObject* _co; - if(GetObjectHeap(res,_dict)) - { - _dict->CallMethod(ls,"Close",{}); - } - if(GetObjectHeap(res,_co)) - { - _co->CallMethod(ls,"","Close",{}); - } - TF_Quit(); - } - else { - TList* args = TList::Create(ls); - args->Add(exePath.ToString()); - for(int arg=0;argAdd(argv[arg]); - auto res = env->CallFunctionWithFatalError(ls,"main",{args}); - int64_t iresult; - if(GetObject(res,iresult)) - return (int)iresult; - } - return 0; -} \ No newline at end of file diff --git a/Packaging/CPKG/WindowsToolchains/x64.cmake b/Packaging/CPKG/WindowsToolchains/x64.cmake deleted file mode 100644 index 1d7cc26..0000000 --- a/Packaging/CPKG/WindowsToolchains/x64.cmake +++ /dev/null @@ -1,7 +0,0 @@ -set(CMAKE_C_COMPILER "/usr/bin/x86_64-w64-mingw32-gcc") -set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-w64-mingw32-g++") -set(CMAKE_C_FLAGS "-static-libgcc -static-libstdc++ -static") -set(CMAKE_CXX_FLAGS "-static-libgcc -static-libstdc++ -static") -set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") -set(CMAKE_SYSTEM_NAME Windows) -set(CMAKE_SYSTEM_PROCESSOR x86_64) \ No newline at end of file diff --git a/Packaging/CPKG/WindowsToolchains/x86.cmake b/Packaging/CPKG/WindowsToolchains/x86.cmake deleted file mode 100644 index 86d52ca..0000000 --- a/Packaging/CPKG/WindowsToolchains/x86.cmake +++ /dev/null @@ -1,7 +0,0 @@ -set(CMAKE_C_COMPILER "/usr/bin/i686-w64-mingw32-gcc") -set(CMAKE_CXX_COMPILER "/usr/bin/i686-w64-mingw32-g++") -set(CMAKE_C_FLAGS "-static-libgcc -static-libstdc++ -static") -set(CMAKE_CXX_FLAGS "-static-libgcc -static-libstdc++ -static") -set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static") -set(CMAKE_SYSTEM_NAME Windows) -set(CMAKE_SYSTEM_PROCESSOR i686) \ No newline at end of file diff --git a/Packaging/CPKG/extract_compiler.sh b/Packaging/CPKG/extract_compiler.sh deleted file mode 100644 index c4d190b..0000000 --- a/Packaging/CPKG/extract_compiler.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -rm -r compilers -mkdir -p compilers -cd compilers -wget https://downloads.tesses.net/cache/compilers/$1-cross.tgz -tar xvzf $1-cross.tgz -mv $1-cross/* . -rmdir $1-cross -rm $1-cross.tgz \ No newline at end of file diff --git a/Packaging/CPKG/pack.sh b/Packaging/CPKG/pack.sh deleted file mode 100644 index f1f922d..0000000 --- a/Packaging/CPKG/pack.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -mkdir compilers -crossint pack.tcross \ No newline at end of file diff --git a/Packaging/CPKG/pack.tcross b/Packaging/CPKG/pack.tcross deleted file mode 100644 index 44bb29d..0000000 --- a/Packaging/CPKG/pack.tcross +++ /dev/null @@ -1,282 +0,0 @@ -var VERSION="1.0.0.0-dev"; -var statics = [ - { - target="powerpc-linux-musl", - cpu = "powerpc" - }, - { - target="powerpc64-linux-musl", - cpu = "powerpc64" - }, - { - target="i686-linux-musl", - cpu = "i686" - }, - { - target="arm-linux-musleabihf", - cpu="armv7l" - }, - { - target="riscv32-linux-musl", - cpu="riscv32" - }, - { - target="riscv64-linux-musl", - cpu="riscv64" - }, - { - target="x86_64-linux-musl", - cpu="x86_64" - }, - { - target="mips-linux-musl", - cpu="mips" - }, - { - target="mips64-linux-musl", - cpu="mips64" - }, - { - target="aarch64-linux-musl", - cpu="aarch64" - } - -]; - -func CPUS() -{ - var p = Process.Start({ - FileName = Env.GetRealExecutablePath("nproc").ToString(), - RedirectStandardOutput=true - }); - var ms = new MemoryStream(true); - p.StandardOutput.CopyTo(ms); - return ParseLong(ms.GetBytes().ToString().Replace("\n","").Replace("\r","")); -} -var nproc = CPUS(); -func BuildConsoleOrServerWindowsStatic(arch) -{ - Console.WriteLine($"Building Windows Static {arch}"); - var build_dir = "builds" / $"win-{arch}"; - var publish_dir = "publish" / $"win-{arch}"; - FS.Local.CreateDirectory(build_dir); - FS.Local.CreateDirectory(publish_dir); - - var args = ["-S","ConsoleOrServer","-B",build_dir.ToString(),"-DCROSSAPPPUBLISH_STATIC=ON"]; - - var file= ("WindowsToolchains"/$"{arch}.cmake").MakeAbsolute().ToString(); - - args.Add($"-DCMAKE_TOOLCHAIN_FILE={file}"); - - Process.Start({ - FileName = Env.GetRealExecutablePath("cmake").ToString(), - Arguments = args - }).Join(); - - - var p = new Process(); - p.FileName = Env.GetRealExecutablePath("make").ToString(); - p.WorkingDirectory = build_dir.MakeAbsolute().ToString(); - p.Arguments = [$"-j{nproc}"]; - if(p.Start()) - p.Join(); - - - -} -func BuildConsoleOrServerLinuxStatic(dir,cmake_toolchain) -{ - Console.WriteLine($"Building Linux Static {dir}"); - var build_dir = "builds" / $"linux-{dir}-static"; - var publish_dir = "publish" / $"linux-{dir}-static"; - FS.Local.CreateDirectory(build_dir); - FS.Local.CreateDirectory(publish_dir); - - var args = ["-S","ConsoleOrServer","-B",build_dir.ToString(),"-DCROSSAPPPUBLISH_STATIC=ON"]; - if(TypeOf(cmake_toolchain) == "String") - { - args.Add($"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain}"); - } - Process.Start({ - FileName = Env.GetRealExecutablePath("cmake").ToString(), - Arguments = args - }).Join(); - - - var p = new Process(); - p.FileName = Env.GetRealExecutablePath("make").ToString(); - p.WorkingDirectory = build_dir.MakeAbsolute().ToString(); - p.Arguments = [$"-j{nproc}"]; - if(p.Start()) - p.Join(); - - - mvFile(build_dir/"crossapp", publish_dir / "crossapp"); - var info = { - type = "archive", - maintainer = "Mike Nolan", - repo = "https://onedev.site.tesses.net/crosslang", - homepage = "https://crosslang.tesseslanguage.com/", - executable_name = "crossapp", - executable_can_be_renamed = true, - executable_runtime = $"linux-{dir}-static", - description = $"Runtime files for linux-{dir}-static", - }; - - var name = $"Tesses.CrossLang.Runtime.linux-{dir}-static"; - - var subDir = new SubdirFilesystem(FS.Local,publish_dir); - var pkgStrm = FS.Local.OpenFile("publish"/$"{name}-{VERSION}.crvm","wb"); - FS.CreateArchive(subDir,pkgStrm, name ,VERSION, Json.Encode(info)); - pkgStrm.Close(); -} -func BuildConsoleOrServerLinuxStaticBasedOnTarget(target,cpu) -{ - var compiler = ("compilers"/"bin"/target).MakeAbsolute().ToString(); - var p = new Process(); - p.FileName = Env.GetRealExecutablePath("bash").ToString(); - p.Arguments = ["extract_compiler.sh",target]; - if(p.Start()) - p.Join(); - - var toolchain = $" - set(CMAKE_C_COMPILER \"{compiler}-gcc\") - set(CMAKE_CXX_COMPILER \"{compiler}-g++\") - set(CMAKE_C_FLAGS \"-static-libgcc -static-libstdc++ -static\") - set(CMAKE_CXX_FLAGS \"-static-libgcc -static-libstdc++ -static\") - set(CMAKE_EXE_LINKER_FLAGS \"-static-libgcc -static-libstdc++ -static\") - - - set(CMAKE_SYSTEM_NAME Linux) - set(CMAKE_SYSTEM_PROCESSOR {cpu}) - "; - if(target == "riscv32-linux-musl" || target == "riscv64-linux-musl") - { - toolchain += "set(CMAKE_POSITION_INDEPENDENT_CODE ON)\n"; - } - FS.WriteAllText(FS.Local,"compilers"/$"{target}.cmake", toolchain); - BuildConsoleOrServerLinuxStatic(cpu,("compilers"/$"{target}.cmake").MakeAbsolute().ToString()); -} -func BuildConsoleOrServerLinuxShared(dir,$cmake_toolchain) -{ - Console.WriteLine($"Building Linux Shared {dir}"); - var build_dir = "builds" / $"linux-{dir}"; - var publish_dir = "publish" / $"linux-{dir}"; - FS.Local.CreateDirectory(build_dir); - FS.Local.CreateDirectory(publish_dir); - - var args = ["-S","ConsoleOrServer","-B",build_dir.ToString()]; - if(TypeOf(cmake_toolchain) == "String") - { - args.Add($"-DCMAKE_TOOLCHAIN_FILE={cmake_toolchain}"); - } - Process.Start({ - FileName = Env.GetRealExecutablePath("cmake").ToString(), - Arguments = args - }).Join(); - - - var p = new Process(); - p.FileName = Env.GetRealExecutablePath("make").ToString(); - p.WorkingDirectory = build_dir.MakeAbsolute().ToString(); - p.Arguments = [$"-j{nproc}"]; - if(p.Start()) - p.Join(); - p = new Process(); - p.FileName = Env.GetRealExecutablePath("make").ToString(); - p.WorkingDirectory = build_dir.MakeAbsolute().ToString(); - p.Arguments = ["install","DESTDIR=."]; - if(p.Start()) - p.Join(); - - mvFile(build_dir/"dir"/"crossapp", publish_dir / "crossapp"); - each(var lib : FS.Local.EnumeratePaths(build_dir/"dir")) - { - if(lib.GetExtension() == ".so") - { - mvFile(lib,publish_dir / lib.GetFileName()); - } - } - var info = { - type = "archive", - maintainer = "Mike Nolan", - repo = "https://onedev.site.tesses.net/crosslang", - homepage = "https://crosslang.tesseslanguage.com/", - description = $"Runtime files for linux-{dir}", - executable_name = "crossapp", - executable_can_be_renamed = true, - executable_runtime = $"linux-{dir}" - }; - - var name = $"Tesses.CrossLang.Runtime.linux-{dir}"; - - var subDir = new SubdirFilesystem(FS.Local,publish_dir); - var pkgStrm = FS.Local.OpenFile("publish"/$"{name}-{VERSION}.crvm","wb"); - FS.CreateArchive(subDir,pkgStrm, name ,VERSION, Json.Encode(info)); - pkgStrm.Close(); -} -func mvFile(src,dest) -{ - Process.Start({ - FileName = Env.GetRealExecutablePath("mv").ToString(), - Arguments = [src.MakeAbsolute().ToString(),dest.MakeAbsolute().ToString()] - }).Join(); -} -func main(args) -{ - Console.WriteLine($"Got {nproc} cpus"); - each(var arch : ["x86","x64"]) - { - var build_dir = "build" / $"win-{arch}"; - var publish_dir = "publish" / $"win-{arch}"; - FS.Local.CreateDirectory(publish_dir); - mvFile(build_dir/"crossapp.exe", publish_dir / "crossapp.exe"); - var info = { - type = "archive", - maintainer = "Mike Nolan", - repo = "https://onedev.site.tesses.net/crosslang", - homepage = "https://crosslang.tesseslanguage.com/", - executable_name = "crossapp.exe", - executable_can_be_renamed = true, - executable_runtime = $"win-{arch}", - description = $"Runtime files for win-{arch}", - }; - - var name = $"Tesses.CrossLang.Runtime.win-{arch}"; - - var subDir = new SubdirFilesystem(FS.Local,publish_dir); - var pkgStrm = FS.Local.OpenFile("publish"/$"{name}-{VERSION}.crvm","wb"); - FS.CreateArchive(subDir,pkgStrm, name ,VERSION, Json.Encode(info)); - pkgStrm.Close(); - } - - BuildConsoleOrServerLinuxShared("x86_64"); - BuildConsoleOrServerLinuxShared("aarch64", "/opt/toolchains/arm64.cmake"); - BuildConsoleOrServerLinuxShared("armv7l", "/opt/toolchains/armhf.cmake"); - BuildConsoleOrServerLinuxShared("riscv64", "/opt/toolchains/riscv64.cmake"); - - - each(var static : statics) - { - BuildConsoleOrServerLinuxStaticBasedOnTarget(static.target,static.cpu); - } - - var info = { - type = "archive", - maintainer = "Mike Nolan", - repo = "https://onedev.site.tesses.net/crosslang", - homepage = "https://crosslang.tesseslanguage.com/", - executable_name = "boot.dol", - executable_can_be_renamed = false, - executable_runtime = "wii", - description = $"Runtime files for wii", - }; - - var name = $"Tesses.CrossLang.Runtime.wii"; - - var subDir = new SubdirFilesystem(FS.Local,"publish"/"wii"); - var pkgStrm = FS.Local.OpenFile("publish"/$"{name}-{VERSION}.crvm","wb"); - FS.CreateArchive(subDir,pkgStrm, name ,VERSION, Json.Encode(info)); - pkgStrm.Close(); - -} \ No newline at end of file diff --git a/Packaging/CPKG/pack_and_publish.sh b/Packaging/CPKG/pack_and_publish.sh deleted file mode 100644 index 791ab09..0000000 --- a/Packaging/CPKG/pack_and_publish.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -bash ./pack.sh -bash ./publish.sh \ No newline at end of file diff --git a/Packaging/CPKG/publish.sh b/Packaging/CPKG/publish.sh deleted file mode 100644 index a73c25e..0000000 --- a/Packaging/CPKG/publish.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -find publish -name "*.crvm" -exec crosslang upload-package --token="$CPKG_KEY" --host="https://cpkg.tesseslanguage.com/" "{}" \; \ No newline at end of file diff --git a/Packaging/CPKG/wiibuild.sh b/Packaging/CPKG/wiibuild.sh deleted file mode 100644 index 00b25f6..0000000 --- a/Packaging/CPKG/wiibuild.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -mkdir -p publish/wii -cd Wii -mkdir build -cd build -cmake -S .. -B . -DCMAKE_TOOLCHAIN_FILE=/opt/devkitpro/cmake/Wii.cmake -make -j`nproc` -mv boot.dol ../../publish/wii/boot.dol \ No newline at end of file diff --git a/Packaging/CPKG/winbuild.sh b/Packaging/CPKG/winbuild.sh deleted file mode 100644 index d5816ff..0000000 --- a/Packaging/CPKG/winbuild.sh +++ /dev/null @@ -1,10 +0,0 @@ -echo "Building Windows Static x86" -cmake -S "ConsoleOrServer" -B build/win-x86 -DCROSSAPPPUBLISH_STATIC=ON -DCMAKE_TOOLCHAIN_FILE=`pwd`/WindowsToolchains/x86.cmake -cd build/win-x86 -make -j`nproc` -cd ../.. -echo "Building Windows Static x64" -cmake -S "ConsoleOrServer" -B build/win-x64 -DCROSSAPPPUBLISH_STATIC=ON -DCMAKE_TOOLCHAIN_FILE=`pwd`/WindowsToolchains/x64.cmake -cd build/win-x64 -make -j`nproc` -cd ../.. \ No newline at end of file diff --git a/Packaging/Linux/PKGBUILD b/Packaging/Linux/PKGBUILD index e393dd1..188ee68 100644 --- a/Packaging/Linux/PKGBUILD +++ b/Packaging/Linux/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: Mike Nolan pkgname=crosslang # '-bzr', '-git', '-hg' or '-svn' -pkgver=1.0.0 +pkgver=0.0.1 pkgrel=1 pkgdesc="" arch=('x86_64' 'powerpc') diff --git a/Packaging/Linux/version.sh b/Packaging/Linux/version.sh index 9f9d3ff..27f64a9 100644 --- a/Packaging/Linux/version.sh +++ b/Packaging/Linux/version.sh @@ -1,2 +1,2 @@ -export BUILD=$(($BUILD_NO-142)) -export DEB_VERSION=1.0.0-$BUILD \ No newline at end of file +export BUILD=$(($BUILD_NO-152)) +export DEB_VERSION=0.0.1-$BUILD \ No newline at end of file diff --git a/docs/CPP_LAYER.md b/docs/CPP_LAYER.md deleted file mode 100644 index eb43736..0000000 --- a/docs/CPP_LAYER.md +++ /dev/null @@ -1 +0,0 @@ -# C++ Layer diff --git a/docs/EXTENDING_RUNTIME.md b/docs/EXTENDING_RUNTIME.md deleted file mode 100644 index 31a5f72..0000000 --- a/docs/EXTENDING_RUNTIME.md +++ /dev/null @@ -1,232 +0,0 @@ -Extending the runtime -===================== - -See [this](CPP_LAYER.md) - -There are a couple ways of doing this - -- Creating a shared library (only works if using shared libs) -- Embeding the runtime -- Forking crosslang and adding functionality (I don't support pull requests at this time) - -### Shared Library - -This assumes you are on linux, if on windows use MyPlugin.dll on mac libMyPlugin.dylib in crosslang project (it would be a good idea to check Env.Platform) - -CMakeLists.txt: -```cmake -cmake_minimum_required(VERSION 3.16) - -project(MyPlugin) - -find_package(TessesCrossLang REQUIRED) - -add_library(MyPlugin SHARED lib.cpp) - -target_link_libraries(MyPlugin PUBLIC TessesCrossLang::crosslang_shared) -``` - -lib.cpp: -```c++ -#include - -using namespace Tesses::CrossLang; - -void MyPlugin(GC* gc, TRootEnvironment* env) -{ - GCList ls(gc); - TDictionary* dict = TDictionary::Create(ls,{ - TDItem("MyFunction", TExternalMethod::Create(ls, "A description for function",{"myLong","$optionalList"},[](GCList& ls, std::vector args)->TObject { - int64_t n; - if(GetArgument(args,0,n)) - { - TList* myLs; - if(GetArgumentHeap(args,1,myLs)) - { - //do something with the list - myLs->Add(n); - return TList::Create(ls, {n,myLs}); - } - - - return TList::Create(ls, {n}); - } - - return nullptr; - })) - }); - - gc->BarrierBegin(); - env->SetVariable("MyPlugin",dict); - gc->BarrierEnd(); -} - -CROSSLANG_PLUGIN(MyPlugin); - -``` - -main.tcross: -```go -func main(args) -{ - Reflection.LoadNativePlugin(FS.MakeFull("libMyPlugin.so")); - - var res = MyPlugin.MyFunction(42); - if(TypeOf(res) == "List") - { - Console.WriteLine(res); - } - - var res = MyPlugin.MyFunction(42,["Hello","John"]); - if(TypeOf(res) == "List") - { - Console.WriteLine(res); - } -} -``` - - -### Embeding the runtime - -CMakeLists.txt: -```cmake -cmake_minimum_required(VERSION 3.16) - -project(MyCrossLangBinary) - -find_package(TessesCrossLang REQUIRED) - -add_executable(MyCrossLangBinary SHARED app.cpp) - -target_link_libraries(MyCrossLangBinary PUBLIC TessesCrossLang::crosslang_shared) # or crosslang_static for static linking - - -``` - -app.cpp: -```c++ -#include - -using namespace Tesses::CrossLang; -using namespace Tesses::Framework; - -void MyPlugin(GC* gc, TRootEnvironment* env) -{ - GCList ls(gc); - TDictionary* dict = TDictionary::Create(ls,{ - TDItem("MyFunction", TExternalMethod::Create(ls, "A description for function",{"myLong","$optionalList"},[](GCList& ls, std::vector args)->TObject { - int64_t n; - if(GetArgument(args,0,n)) - { - TList* myLs; - if(GetArgumentHeap(args,1,myLs)) - { - //do something with the list - myLs->Add(n); - return TList::Create(ls, {n,myLs}); - } - - - return TList::Create(ls, {n}); - } - - return nullptr; - })) - }); - - gc->BarrierBegin(); - env->SetVariable("MyPlugin",dict); - gc->BarrierEnd(); -} - -int main(int argc, char** argv) -{ - TF_Init(); - if(argc < 2) - { - printf("USAGE: %s \n",argv[0]); - return 1; - } - GC gc; - gc.RegisterEverythingCallback(MyPlugin); - gc.Start(); - GCList ls(gc); - TRootEnvironment* env = TRootEnvironment::Create(ls,TDictionary::Create(ls)); - Tesses::Framework::Filesystem::LocalFilesystem fs; - TStd::RegisterStd(&gc,env); - env->LoadFileWithDependencies(&gc, &fs, fs.SystemToVFSPath(argv[1])); - - TList* args = TList::Create(ls); - for(int arg=1;argAdd(std::string(argv[arg])); - - auto res = env->CallFunction(ls,"main",{args}); - int64_t iresult; - if(GetObject(res,iresult)) - return (int)iresult; - return 0; -} -``` - -main.tcross (needs to be compiled with crossc): -```go -func main(args) -{ - //no reflection necessary - - var res = MyPlugin.MyFunction(42); - if(TypeOf(res) == "List") - { - Console.WriteLine(res); - } - - var res = MyPlugin.MyFunction(42,["Hello","John"]); - if(TypeOf(res) == "List") - { - Console.WriteLine(res); - } -} -``` - -### Forking (implementing it in runtime library itself) -- edit include/CrossLang.hpp -- in TStd class insert, static void RegisterMyPlugin(GC* gc, TRootEnvironment* env); where MyPlugin is whatever you want -- edit src/runtime_methods/std.cpp -- in TStd::RegisterStd before register everything call TStd::RegisterMyPlugin(gc, env); -- in CMakeLists.txt within list(APPEND CROSSLANG_SOURCE **Many Source Files**) you must add src/runtime_methods/myplugin.cpp - -src/runtime_methods/myplugin.cpp: -```c++ -#include -namespace Tesses::CrossLang -{ - void TStd::RegisterMyPlugin(GC* gc, TRootEnvironment* env) - { - GCList ls(gc); - TDictionary* dict = TDictionary::Create(ls,{ - TDItem("MyFunction", TExternalMethod::Create(ls, "A description for function",{"myLong","$optionalList"},[](GCList& ls, std::vector args)->TObject { - int64_t n; - if(GetArgument(args,0,n)) - { - TList* myLs; - if(GetArgumentHeap(args,1,myLs)) - { - //do something with the list - myLs->Add(n); - return TList::Create(ls, {n,myLs}); - } - - - return TList::Create(ls, {n}); - } - - return nullptr; - })) - }); - - gc->BarrierBegin(); - env->SetVariable("MyPlugin",dict); - gc->BarrierEnd(); - } -} -``` \ No newline at end of file diff --git a/docs/HANDBOOK.md b/docs/HANDBOOK.md deleted file mode 100644 index bd35612..0000000 --- a/docs/HANDBOOK.md +++ /dev/null @@ -1,598 +0,0 @@ -## CrossLang Handbook - -This is a book for my language found [here](https://crosslang.tesseslanguage.com/) - -## Statements and loops - - - -#### Declare a variable (it is an expression) - -You can (the var is optional but should be used if the root environment has the same variable and you don't want to set it) - -```js -var myVariable = 42; -``` - -#### Set a variable (it is an expression) - -```js -myVariable = "I have set the variable to a string"; -``` - -#### Reflective variables - -```js -var nameOfVariable = "Var 1"; -.[nameOfVariable] = 42; //the variable name in this instance will be Var 1 -Console.WriteLine(.[nameOfVariable]); //prints 42 - - -var nameOfVariable2 = "Var 2"; -var nameOfField = "This field has spaces and \n New Lines"; -.[nameOfVariable2] = { - .[nameOfField] = "Hello, world" -}; - -Console.WriteLine(.[nameOfVariable2].[nameOfField]); //should print Hello, world - -``` - - -#### If statements - -The {} are optional if you only need one statement - -```js -var myExpression = 0; -var myOtherExpression = { - mol = 42 -}; - -if(myExpression) -{ - Console.WriteLine("myExpression is truthy"); -} -else if(myOtherExpression) -{ - //this will run based on the condition - Console.WriteLine("myExpression is falsey but myOtherExpression is truthy"); -} -else { - Console.WriteLine("both myExpression and myOtherExpression are falsey"); -} -``` - -#### For loop - -Note: i will leak, also you can use curly brackets like if - -```js -for(var i = 0; i < 42; i++) - Console.WriteLine(i); -``` - -#### Each loop - -```js -enumerable MyItterator() -{ - yield 42; - yield 100; - yield 88; -} -each(var item : MyItterator()) -{ - Console.WriteLine(item); -} - - -each(var item : [3,7,12]) -{ - Console.WriteLine(item); -} - - -/* - This should output - 42 - 100 - 88 - 3 - 7 - 12 -*/ -``` - -#### While loop - -```js -while(conditionLikeIf) -{ - Console.WriteLine("Hi"); -} - -//If conditionLikeIf is falsey we never print Hi -//If conditionLikeIf is truthy we print Hi until it is falsey -``` - -#### Do loop - -```js -do(conditionLikeIf) -{ - Console.WriteLine("Hi"); -} - -//If conditionLikeIf is falsey we print Hi once -//If conditionLikeIf is truthy we print Hi until it is falsey -``` - - - -#### Try statement - -NOTE: you can't return undefined (but you can return other types) (It will just return from try and will still execute the body past the try statement) due to the try statement being a closure (you can still break and continue due to special TObjects being returned) - -```js -try { - Console.WriteLine("God is good."); - throw "my error"; - Console.WriteLine("I am lonely, I am never called."); -} -catch(ex) -{ - Console.WriteLine($"I got an error {ex}."); -} -finally { - Console.WriteLine("For God so loved the world that he gave his only begotten Son, that whoever believes in him should not perish but have eternal life."); -} - - -/* - This should print - God is good. - I got an error my error. - For God so loved the world that he gave his only begotten Son, that whoever believes in him should not perish but have eternal life. -*/ -``` - -#### Switch statement - -NOTE: you can use dictionaries with overloaded equals operator (we will pass the switch's expression as the argument) - -```js -o = { - operator== = (this,v) => { - //this is implicitly passed by runtime, but you must declare it if you want it - return (v * 7) == 42; - } -}; - -var val = 6; - -switch(val) -{ - case 4: - Console.WriteLine("I am four"); - break; - case 5: - Console.WriteLine("I am five"); - break; - case o: - Console.WriteLine("Hitchhiker's guide to the galaxy meaning of life"); - break; - default: - Console.WriteLine("We don't support it we are sorry"); -} -``` - - - -#### Function declaration - -```go -//you can create functions on dictionaries so long as they are on root environment (they are declared there before root scope is evaluated so this is possible) -My.Func.Joel = 59; //Because My.Func.Is.A.Few.Deep creates the dictionaries via runtime - -func My.Func.Is.A.Few.Deep(a, b) -{ - return a * b; -} -func main(args) -{ - Console.WriteLine(My.Func.Is.A.Few.Deep(6,7)); -} -``` - -#### Function inside a function - -Oh yeah functions can have exclusively a expression as a body which does not need a return keyword - -```go -func main(args) -{ - func MyOther(a,b) a * b; - Console.WriteLine(MyOther(a,b)); -} -``` - -#### Document a function - -```go -/^ - This function returns 42 -^/ -func MyFunction() 42; -``` - -#### Return statement - -You can also return nothing - -```js -return 42; -return; -``` - -#### Yield statement - -This will halt the function's execution and return the running function object (were you can pop the item and resume it) - -To automaticly make a function enumerable (with each statement) you must use ``enumerable`` instead of func when declaring your function - -```js -yield 42; -``` - -#### Throw statement - -You can catch this with ``try statement`` with ``catch`` clause - -```js -throw "You can replace me with another string or any other object"; -``` - -#### Defer statement - -Your code will be called when your scope is destroyed - -```go -{ - defer { - Console.WriteLine("In defer"); - } - Console.WriteLine("About to leave scope"); -} -Console.WriteLine("Left scope"); - - -/* -The output should be - -About to leave scope -In defer -Left scope -*/ -``` - -## Expressions - -We will place it as a parameter to a function ``doThing`` but these will work anywhere like setting a variable or another expression - -#### Undefined - -```js -doThing(undefined); -``` - -#### Null - -```js -doThing(null); -``` - -#### Boolean - -```js -doThing(false); -doThing(true); -``` - -#### Long - -A signed 64 bit number - -```js -doThing(94); -doThing(599929022); -``` - -#### Double - -A 64 bit floating pointer number - -```js -doThing(5.25); -doThing(942.90204); -``` - -#### Char - -Yes we support single character strings (this escapes a double quote) - -```csharp -doThing('\"'); -``` - -#### String - -Second is an interopolated string - -```csharp -doThing("Hi"); -doThing($"My name is {name}"); -``` - -#### List - -```js -doThing( - [4,5,9,42,true,"Hi",'\n'] -); -``` - -#### Dictionary - -```js -doThing( - { - a = "This is an option", - b = 42, - c = 9 - } -); -``` - -###### Enumerating a dictionary - -```js -var dict = { a = 5, b = 42}; -each(var item : Dictionary.Items(dict)) -{ - Console.WriteLine($"Key: {item.Key}"); - Console.WriteLine($"Value: {item.Value}"); - Console.WriteLine(); -} -/* -This prints -Key: a -Value: 5 - -Key: b -Value: 42 - -*/ -``` - - - -###### Getting a value from dictionary - -```go -func doThing(data) -{ - Console.WriteLine(data.b); //will print 42 -} -``` - -###### Setting a value to dictionary - -```go -func doThing(data) -{ - data.a = true; //replace a with a different value - data.someFieldThatDoesNotExist = 9; //define a new field entirely - -} -``` - -###### Methods - -Note that this is optional but if you do have it it must be the first argument, the this argument points to the dictionary - -```go -var item = { - myMethod = (this, a, b) => { - return a * b; - } -}; - -Console.WriteLine(item.myMethod(6,7)); //prints 42 -``` - -Or - -```go -var item = {}; -func item.myMethod(this, a, b) -{ - return a * b; -} -Console.WriteLine(item.myMethod(6,7)); //prints 42 -``` - -###### Properties - -They are declared like every other method except they are prefixed with ``get`` or ``set`` - -```go -var item = { - getProp = (this)=>{ - return 42; - }, - setProp = (this,v)=>{ - //do something with v - } -}; - -Console.WriteLine(item.Prop); //equivalent to Console.WriteLine(item.getProp()); - -item.Prop = 100; //equivalent to item.setProp(100); will do nothing in this example - -``` - -###### Operator overloading - -```js -var item = { - operator+ = (this,right) => { - return 4 + a; - } - operator- = (this,right) => { - return 4 - right; //be careful right may be undefined if the negate operator is used - } -}; - -Console.WriteLine(item + 5); //prints 9 -``` - -###### Array operator overloading - -```js -var item = { - GetAt = (index)=>{ - return index * 2; //we multiply index by two and return - }, - SetAt => (index,value)=>{ - Console.WriteLine($"The index was {index} and value was {value}"); - } -}; - -Console.WriteLine(item[21]); //prints 42 -item["Hi"] = "John"; //prints The index was Hi and value was John -``` - -#### ByteArray - -```js -var bA = new ByteArray(1); -ba[0] = 42; -Console.WriteLine(ba.ToString()); //prints * -``` - -###### ByteArray from string - -```js -var bA = new ByteArray("Hi"); -//we can get bytes like this bA[0] which will be 72 -//we can get length by bA.Count or bA.Length -``` - -#### Embedding files (you can't do this easily in C/C++ and C# not as easy as this) - -```js -var bA = embed("myFile.png"); //will embed the file res/myFile.png -//it is stored as a RESO in the crvm file and bA is a ByteArray -//note the argument MUST be a constant string -//note you can access a subdirectory of res as well just use dir/file.bin -``` - -#### Streams - - - -###### From an existing file - -```js -var strm = FS.Local.OpenFile("file.bin","rb"); - -var data = new ByteArray(1024); -var read = strm.Read(data,0,data.Count); -//use ReadBlock to ensure you have 1024 bytes if not near end of stream - -//use WriteBlock to ensure you write the amount you say you need - -strm.Close(); -``` - -#### VFS - -```js -var myVFS = FS.Local; //FS.Local is the local filesystem - - -myVFS.CreateDirectory("myDir"); //creates directory in current dir (only local) - -myVFS.DeleteDirectory("myDir"); //now we delete it - - -myVFS.CreateDirectory(Path.FromString(Env.Downloads) / "Folder in Downloads"); //Create a folder in downloads -``` - - - -#### Path - -```js -var path = / "Path" / "To" / "Directory"; -var relativePath = ./"another"/"path"; -var combined = path / relativePath; -var someString = "joel"; -var combinedAndStr = combined / someString; -var combinedWithExtension = combined + ".mp4"; -Console.WriteLine(combined); // outputs /Path/To/Directory/another/path -Console.WriteLine(combined); // outputs /Path/To/Directory/another/path/joel -Console.WriteLine(combinedWithExtension); //outputs /Path/To/Directory/another/path.mp4 -//these paths are used with vfs - - -//to get parent directory use combined.GetParent(); -//to get filename use combined.GetFileName(); -//to get extension use combinedWithExtension.GetExtension();, it will be the extension including . -//to change the extension use combinedWithExtension.ChangeExtension(".mkv"); -//to remove the extension use combinedWithExtension.ChangeExtension(null); or combinedWithExtension.ChangeExtension(); -``` - -#### Html Litterals -```go -//comments are just crosslang ones - -//we will be setting to myHtml for the html (returns a string) (it is already html escaped) -myHtml =

{someStringExpression}

; - -//a link, in this example we have a dictionary named node with string fields href and text -//lets say node.text equaled List and href contained ./mypage?name=Joel&file=steve.bin myHtml would be equal to "List<int>" (the \ are just there to make this a valid string for demonstration purposes, there aren't really backslashes) -myHtml = {node.text}; - - -//for (works like for loop but is in html form, the for part is not rendered in the final string) -myHtml = -
{i}
- ; - -//each -myHtml = ; - -//do -myHtml = ; - -//while -myHtml = ; - -//if - -myHtml = - - //if expr is 42 - - - //if expr is not 42 - //you would use another if here instead of else if - -; - -myHtml = Hello; //would just be Hello (useful for templating as it works just like div but the null part is not emited into string) - -myHtml = ; //allowing you to emit unescaped html from string into html litteral (useful for templating) -``` diff --git a/docs/README.md b/docs/README.md deleted file mode 100644 index 7fcb9ef..0000000 --- a/docs/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# Tesses CrossLang - -This is the docs for my language - -- [Handbook](HANDBOOK.md) -- [C++ Layer](CPP_LAYER.md) -- [Extend the runtime](EXTENDING_RUNTIME.md) \ No newline at end of file diff --git a/docs/WHAT_IS_TOBJECT.md b/docs/WHAT_IS_TOBJECT.md deleted file mode 100644 index 2527f97..0000000 --- a/docs/WHAT_IS_TOBJECT.md +++ /dev/null @@ -1,16 +0,0 @@ -What is TObject -=============== - -It is a std::variant that can be (not in that order) - -- Undefined (std::monostate) -- Null (std::nullptr_t) -- Long (int64_t) -- Double (double) -- Char (char) -- String (std::string) -- Version (Tesses::CrossLang::TVMVersion) -- Regex (std::regex) -- Path (Tesses::Framework::Filesystem::VFSPath) -- MethodInvoker (Tesses::CrossLang::MethodInvoker) -- HeapObjects (Tesses::CrossLang::THeapObjectHolder) \ No newline at end of file diff --git a/include/CrossLang.hpp b/include/CrossLang.hpp index 4eeb622..f71684c 100644 --- a/include/CrossLang.hpp +++ b/include/CrossLang.hpp @@ -19,31 +19,13 @@ #include #include -/** - * @brief CrossLang Runtime Major version - * - */ -#define TVM_MAJOR 1 -/** - * @brief CrossLang Runtime Minor version - * - */ -#define TVM_MINOR 0 -/** - * @brief CrossLang Runtime Patch version - * - */ -#define TVM_PATCH 0 -/** - * @brief CrossLang Runtime Build version - * - */ -#define TVM_BUILD 0 -/** - * @brief CrossLang Runtime Stage version - * - */ -#define TVM_VERSIONSTAGE DevVersion +#include "CrossLangVersion.h" + +#define CROSSLANG_BYTECODE_MAJOR 1 +#define CROSSLANG_BYTECODE_MINOR 0 +#define CROSSLANG_BYTECODE_PATCH 0 +#define CROSSLANG_BYTECODE_BUILD 0 //SHOULD ALWAYS BE 0 +#define CROSSLANG_BYTECODE_VERSIONSTAGE DevVersion #if defined(_WIN32) #undef Yield @@ -341,13 +323,13 @@ namespace Tesses::CrossLang { return v; } /** - * @brief Compares this to the runtime version + * @brief Compares this to the runtime version (for Bytecode) * * @return int CompareTo(RuntimeVersion) where RuntimeVersion is the runtime version */ int CompareToRuntime() { - TVMVersion version(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE); + TVMVersion version(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE); return CompareTo(version); } /** diff --git a/src/archive.cpp b/src/archive.cpp index 60132fa..5f70e4e 100644 --- a/src/archive.cpp +++ b/src/archive.cpp @@ -130,7 +130,7 @@ namespace Tesses::CrossLang uint8_t main_header[18]; memcpy(main_header,"TCROSSVM",8); - TVMVersion rtVersion(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE); + TVMVersion rtVersion(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE); rtVersion.ToArray(main_header+8); version.ToArray(main_header+13); strm->WriteBlock(main_header,sizeof(main_header)); diff --git a/src/assembler/asm.cpp b/src/assembler/asm.cpp index 9ed5994..1c58fd0 100644 --- a/src/assembler/asm.cpp +++ b/src/assembler/asm.cpp @@ -773,7 +773,7 @@ namespace Tesses::CrossLang { void Save(std::shared_ptr vfs, std::shared_ptr stream) { - TVMVersion runtime_version(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE); + TVMVersion runtime_version(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE); uint8_t buffer[18]; memcpy(buffer,"TCROSSVM",8); runtime_version.ToArray(buffer+8); diff --git a/src/compiler/codegen.cpp b/src/compiler/codegen.cpp index 07cd723..126b625 100644 --- a/src/compiler/codegen.cpp +++ b/src/compiler/codegen.cpp @@ -380,7 +380,7 @@ namespace Tesses::CrossLang void CodeGen::Save(std::shared_ptr stream) { - TVMVersion runtime_version(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE); + TVMVersion runtime_version(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE); uint8_t buffer[18]; memcpy(buffer,"TCROSSVM",8); runtime_version.ToArray(buffer+8); diff --git a/src/runtime_methods/vm.cpp b/src/runtime_methods/vm.cpp index 269f904..461aaeb 100644 --- a/src/runtime_methods/vm.cpp +++ b/src/runtime_methods/vm.cpp @@ -133,7 +133,7 @@ namespace Tesses::CrossLang std::string name = "Out"; std::vector> sources; - TVMVersion version(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE); + TVMVersion version(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE); std::vector> dependencies; std::vector> tools; std::string info; @@ -359,7 +359,10 @@ namespace Tesses::CrossLang dict->DeclareFunction(gc, "SourceToAst", "Convert source to ast", {"source"}, VM_SourceToAst); dict->DeclareFunction(gc, "getRuntimeVersion","Get the runtime version",{},[](GCList& ls,std::vector args)->TObject { - return TVMVersion(TVM_MAJOR,TVM_MINOR,TVM_PATCH,TVM_BUILD,TVM_VERSIONSTAGE); + return TVMVersion(CROSSLANG_MAJOR,CROSSLANG_MINOR,CROSSLANG_PATCH,0,TVMVersionStage::DevVersion); + }); + dict->DeclareFunction(gc, "getBytecodeVersion","Get the bytecode version",{},[](GCList& ls,std::vector args)->TObject { + return TVMVersion(CROSSLANG_BYTECODE_MAJOR,CROSSLANG_BYTECODE_MINOR,CROSSLANG_BYTECODE_PATCH,CROSSLANG_BYTECODE_BUILD,CROSSLANG_BYTECODE_VERSIONSTAGE); }); dict->DeclareFunction(gc, "getIsRunning","Is the program still running",{},[](GCList& ls, std::vector args)->TObject { return Tesses::Framework::TF_IsRunning(); diff --git a/src/vm/filereader.cpp b/src/vm/filereader.cpp index 754b390..b5f5374 100644 --- a/src/vm/filereader.cpp +++ b/src/vm/filereader.cpp @@ -242,6 +242,7 @@ namespace Tesses::CrossLang break; case 11: { + auto data = parseEnt(); TDictionary* dict; if(GetObjectHeap(data,dict))