From 46b37246ff4427c4fca52dfba44a9f535a4ff2a7 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Fri, 17 Jan 2025 18:07:42 +0700 Subject: [PATCH 01/19] Publish Code --- .github/workflows/build.yml | 6 + .gitmodules | 4 + CMakeLists.txt | 1 + assets.bat | 4 + build/assets/yuedemo.tic.dat | 1 + build/assets/yuemark.tic.dat | 1 + cmake/core.cmake | 5 + cmake/lua.cmake | 2 +- cmake/yue.cmake | 56 ++++++++++ demos/bunny/yuemark.yue | 114 +++++++++++++++++++ demos/yuedemo.yue | 55 ++++++++++ src/api/yue.cpp | 207 +++++++++++++++++++++++++++++++++++ src/script.c | 8 ++ vendor/yuescript | 1 + 14 files changed, 464 insertions(+), 1 deletion(-) create mode 100644 build/assets/yuedemo.tic.dat create mode 100644 build/assets/yuemark.tic.dat create mode 100644 cmake/yue.cmake create mode 100644 demos/bunny/yuemark.yue create mode 100644 demos/yuedemo.yue create mode 100644 src/api/yue.cpp create mode 160000 vendor/yuescript diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index abd53cba4..341927a53 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -532,6 +532,12 @@ jobs: cd build emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_MOON=ON -DTIC80_TARGET=tic80moon .. --fresh cmake --build . --parallel + + - name: Build yue + run: | + cd build + emcmake cmake -DBUILD_SDLGPU=On -DCMAKE_BUILD_TYPE=Release -DBUILD_WITH_LUA=OFF -DBUILD_WITH_YUE=ON -DTIC80_TARGET=tic80yue .. --fresh + cmake --build . --parallel - name: Build fennel run: | diff --git a/.gitmodules b/.gitmodules index 0c67231e1..c3b20932a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -90,3 +90,7 @@ path = vendor/pocketpy url = https://github.com/PrimedErwin/pocketpy.git shallow = true +[submodule "vendor/yuescript"] + path = vendor/yuescript + url = https://github.com/IppClub/YueScript.git + shallow = true \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f08b9c9f..ed48ba690 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,6 +153,7 @@ include(cmake/tools.cmake) include(cmake/lua.cmake) include(cmake/moon.cmake) +include(cmake/yue.cmake) include(cmake/fennel.cmake) include(cmake/wren.cmake) include(cmake/mruby.cmake) diff --git a/assets.bat b/assets.bat index fdaad397f..9b553cb8f 100644 --- a/assets.bat +++ b/assets.bat @@ -21,6 +21,7 @@ build\bin\prj2cart demos\sfx.lua build\sfx.tic build\bin\prj2cart demos\squirreldemo.nut build\squirreldemo.tic build\bin\prj2cart demos\tetris.lua build\tetris.tic build\bin\prj2cart demos\wrendemo.wren build\wrendemo.tic +build\bin\prj2cart demos\yuedemo.yue build\yuedemo.tic build\bin\wasmp2cart demos\wasm\wasmdemo.wasmp build\wasmdemo.tic --binary demos\wasm\wasmdemo.wasm build\bin\wasmp2cart demos\bunny\wasmmark\wasmmark.wasmp build\wasmmark.tic --binary demos\bunny\wasmmark\wasmmark.wasm @@ -34,6 +35,7 @@ build\bin\prj2cart demos\bunny\rubymark.rb build\rubymark.tic build\bin\prj2cart demos\bunny\schememark.scm build\schememark.tic build\bin\prj2cart demos\bunny\squirrelmark.nut build\squirrelmark.tic build\bin\prj2cart demos\bunny\wrenmark.wren build\wrenmark.tic +build\bin\prj2cart demos\bunny\yuemark.yue build\yuemark.tic build\bin\bin2txt build\config.tic build\assets\config.tic.dat -z build\bin\bin2txt build\luademo.tic build\assets\luademo.tic.dat -z @@ -69,5 +71,7 @@ build\bin\bin2txt build\squirrelmark.tic build\assets\squirrelmark.tic.dat -z build\bin\bin2txt build\wasmmark.tic build\assets\wasmmark.tic.dat -z build\bin\bin2txt build\wrenmark.tic build\assets\wrenmark.tic.dat -z build\bin\bin2txt build\wasmdemo.tic build\assets\wasmdemo.tic.dat -z +build\bin\bin2txt build\yuedemo.tic build\assets\yuedemo.tic.dat -z +build\bin\bin2txt build\yuemark.tic build\assets\yuemark.tic.dat -z build\bin\bin2txt build\cart.png build\assets\cart.png.dat diff --git a/build/assets/yuedemo.tic.dat b/build/assets/yuedemo.tic.dat new file mode 100644 index 000000000..aec00eab2 --- /dev/null +++ b/build/assets/yuedemo.tic.dat @@ -0,0 +1 @@ +0x78, 0xda, 0xbd, 0x54, 0x6d, 0x4f, 0xdb, 0x30, 0x10, 0xde, 0x97, 0xed, 0x43, 0x7e, 0x85, 0x87, 0x34, 0x09, 0x46, 0x0a, 0x67, 0x3b, 0x89, 0x93, 0x88, 0x22, 0x21, 0xe8, 0x34, 0xb4, 0x4e, 0x4c, 0x50, 0x8d, 0x7d, 0x75, 0x1c, 0x9b, 0x46, 0x2b, 0x4d, 0x95, 0xb8, 0xac, 0xfd, 0xf7, 0xf3, 0x4b, 0xd2, 0xb2, 0xb2, 0x4d, 0x9b, 0x84, 0xb8, 0x24, 0xba, 0x7b, 0xee, 0xce, 0xcf, 0x3d, 0x49, 0x4f, 0x7d, 0x1d, 0xbe, 0x79, 0x35, 0x18, 0x20, 0x5d, 0xe9, 0x99, 0xcc, 0x11, 0x42, 0x77, 0xfc, 0x5e, 0x7a, 0x14, 0x98, 0x34, 0x5f, 0xea, 0x69, 0xdd, 0xe4, 0x5d, 0xba, 0x94, 0x0f, 0x72, 0x56, 0x2f, 0x64, 0x13, 0x22, 0x79, 0xcf, 0xab, 0x99, 0x71, 0x5a, 0x1c, 0xd9, 0xbe, 0x52, 0xb6, 0xc2, 0x9e, 0x46, 0xad, 0x69, 0xd7, 0x0e, 0x36, 0xd5, 0x42, 0x57, 0xf5, 0xdc, 0x56, 0xdb, 0x4a, 0x3b, 0x6e, 0xf4, 0x43, 0x16, 0x36, 0x46, 0xb3, 0x6a, 0xfe, 0xdd, 0x16, 0x66, 0x95, 0x90, 0xf3, 0xd6, 0xd4, 0x3e, 0x5f, 0x4e, 0xd0, 0xd8, 0x03, 0xb4, 0x2f, 0xa6, 0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, 0x33, 0xcc, 0x32, 0x92, 0xd1, 0x24, 0x51, 0xb4, 0x88, 0x4b, 0x91, 0x45, 0x98, 0x27, 0x2a, 0x61, 0xe6, 0x84, 0x62, 0x2a, 0xb2, 0x57, 0x16, 0x15, 0x20, 0x48, 0x9c, 0x24, 0x22, 0x4d, 0x28, 0xa5, 0x22, 0x66, 0x7e, 0xfe, 0x66, 0xaa, 0xff, 0x2f, 0xb8, 0x3e, 0x3b, 0xff, 0xb4, 0xfd, 0xd1, 0xf0, 0x8b, 0x7c, 0x94, 0x6e, 0x75, 0xba, 0xd1, 0x3f, 0x01, 0x0f, 0xe1, 0xb0, 0x18, \ No newline at end of file diff --git a/build/assets/yuemark.tic.dat b/build/assets/yuemark.tic.dat new file mode 100644 index 000000000..caffc7ab5 --- /dev/null +++ b/build/assets/yuemark.tic.dat @@ -0,0 +1 @@ +0x78, 0xda, 0xad, 0x55, 0x6d, 0x6f, 0xdb, 0x36, 0x10, 0xde, 0x97, 0x7d, 0x11, 0xf6, 0x23, 0x2e, 0x1d, 0x06, 0xd8, 0xa9, 0xed, 0x90, 0x92, 0x25, 0xc5, 0x82, 0x1d, 0x64, 0x5d, 0x53, 0x2c, 0x40, 0x06, 0x14, 0x8d, 0xf7, 0x12, 0xa0, 0x5f, 0x68, 0x92, 0x8a, 0x85, 0xda, 0x92, 0x21, 0x51, 0x49, 0x8d, 0xa1, 0xff, 0x7d, 0xc7, 0x17, 0x29, 0xb2, 0xf3, 0xe2, 0xa2, 0x2b, 0x23, 0xeb, 0xa8, 0xe3, 0x73, 0x0f, 0xef, 0x8e, 0xc7, 0xcb, 0x8f, 0xbf, 0xfc, 0xf4, 0xc3, 0x70, 0x08, 0x2a, 0x53, 0x2b, 0x99, 0xc0, 0x9b, 0x3a, 0xcf, 0xb7, 0x6b, 0x56, 0x7e, 0x82, 0x2c, 0x87, 0x9b, 0x5a, 0x5e, 0xf3, 0x32, 0xdb, 0x28, 0x0f, 0x01, 0xac, 0x56, 0xcb, 0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0x8e, 0xc6, 0x7e, 0x18, 0xd3, 0x78, 0xe2, 0x4f, 0x82, 0x28, 0x4a, 0x83, 0x45, 0x28, 0xf8, 0x64, 0x4c, 0x59, 0x94, 0x46, 0x31, 0x5a, 0xa4, 0x71, 0x3a, 0xd6, 0x7f, 0x93, 0xf1, 0x82, 0x70, 0x3f, 0x8c, 0x22, 0x7e, 0x1a, 0x05, 0x41, 0xc0, 0xc3, 0xd8, 0x7a, 0xd0, 0xee, 0xfa, 0x1f, 0xde, 0xaf, 0x43, 0xf4, \ No newline at end of file diff --git a/cmake/core.cmake b/cmake/core.cmake index 19ac5a4d0..ac2f49cfe 100644 --- a/cmake/core.cmake +++ b/cmake/core.cmake @@ -50,6 +50,7 @@ target_include_directories(tic80core PRIVATE ${THIRDPARTY_DIR}/moonscript ${THIRDPARTY_DIR}/fennel + ${THIRDPARTY_DIR}/yuescript ${POCKETPY_DIR}/src PUBLIC ${CMAKE_SOURCE_DIR}/include @@ -70,6 +71,10 @@ if(BUILD_STATIC) target_link_libraries(tic80core PRIVATE moon) endif() + if(BUILD_WITH_YUE) + target_link_libraries(tic80core PRIVATE yuescript) + endif() + if(BUILD_WITH_FENNEL) target_link_libraries(tic80core PRIVATE fennel) endif() diff --git a/cmake/lua.cmake b/cmake/lua.cmake index fae378a0e..10da90645 100644 --- a/cmake/lua.cmake +++ b/cmake/lua.cmake @@ -5,7 +5,7 @@ option(BUILD_WITH_LUA "Lua Enabled" ON) message("BUILD_WITH_LUA: ${BUILD_WITH_LUA}") -if(BUILD_WITH_LUA OR BUILD_WITH_MOON OR BUILD_WITH_FENNEL) +if(BUILD_WITH_LUA OR BUILD_WITH_MOON OR BUILD_WITH_YUE OR BUILD_WITH_FENNEL) set(LUA_DIR ${THIRDPARTY_DIR}/lua) set(LUA_SRC ${LUA_DIR}/lapi.c diff --git a/cmake/yue.cmake b/cmake/yue.cmake new file mode 100644 index 000000000..63ef9b98b --- /dev/null +++ b/cmake/yue.cmake @@ -0,0 +1,56 @@ +################################ +# YUESCRIPT +################################ + +option(BUILD_WITH_YUE "Yue Enabled" ${BUILD_WITH_ALL}) +message("BUILD_WITH_YUE: ${BUILD_WITH_YUE}") + +if(BUILD_WITH_YUE) + set(YUESCRIPT_DIR ${THIRDPARTY_DIR}/yuescript) + set(YUESCRIPT_SRC + ${YUESCRIPT_DIR}/src/yuescript/ast.cpp + ${YUESCRIPT_DIR}/src/yuescript/parser.cpp + ${YUESCRIPT_DIR}/src/yuescript/yue_ast.cpp + ${YUESCRIPT_DIR}/src/yuescript/yue_parser.cpp + ${YUESCRIPT_DIR}/src/yuescript/yue_compiler.cpp + ${YUESCRIPT_DIR}/src/yuescript/yuescript.cpp + ) + + list(APPEND YUESCRIPT_SRC ${CMAKE_SOURCE_DIR}/src/api/yue.cpp) + list(APPEND YUESCRIPT_SRC ${CMAKE_SOURCE_DIR}/src/api/parse_note.c) + + add_library(yuescript ${TIC_RUNTIME} ${YUESCRIPT_SRC}) + + if(NOT BUILD_STATIC) + set_target_properties(yuescript PROPERTIES PREFIX "") + else() + target_compile_definitions(yuescript INTERFACE TIC_BUILD_WITH_YUE) + endif() + + target_link_libraries(yuescript PRIVATE runtime luaapi) + + set_target_properties(yuescript PROPERTIES + LINKER_LANGUAGE CXX + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED ON + ) + + target_include_directories(yuescript + PRIVATE + ${YUESCRIPT_DIR}/src + ${YUESCRIPT_DIR}/src/yuescript + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/src + ) + + if(MSVC) + target_compile_definitions(yuescript PRIVATE _SCL_SECURE_NO_WARNINGS) + else() + target_compile_options(yuescript PRIVATE -Wall -Wno-long-long -fPIC -O3) + endif() + + if(APPLE) + target_compile_definitions(yuescript PRIVATE -Wno-deprecated-declarations) + endif() + +endif() \ No newline at end of file diff --git a/demos/bunny/yuemark.yue b/demos/bunny/yuemark.yue new file mode 100644 index 000000000..2ec65f403 --- /dev/null +++ b/demos/bunny/yuemark.yue @@ -0,0 +1,114 @@ +-- title: Bunnymark in YueScript +-- author: Rob Loach, Dania Rifki +-- desc: Benchmarking tool to see how many bunnies can fly around the screen, using YueScript. +-- license: MIT License +-- input: gamepad +-- script: yue +-- version: 1.1.0 + +screenWidth = 240 +screenHeight = 136 +toolbarHeight = 6 +t = 0 + +class Bunny + @width: 26 + @height: 32 + + new: => + @x = math.random(0, screenWidth - @@width) + @y = math.random(0, screenHeight - @@height) + @speedX = math.random(-100, 100) / 60 + @speedY = math.random(-100, 100) / 60 + @sprite = 1 + + draw: () => + spr(@sprite, @x, @y, 1, 1, 0, 0, 4, 4) + + update: () => + @x += @speedX + @y += @speedY + + if @x + @@width > screenWidth + @x = screenWidth - @@width + @speedX *= -1 + if @x < 0 + @x = 0 + @speedX *= -1 + if @y + @@height > screenHeight + @y = screenHeight - @@height + @speedY *= -1 + if @y < toolbarHeight + @y = toolbarHeight + @speedY *= -1 + +class FPS + new: => + @value = 0 + @frames = 0 + @lastTime = 0 + + getValue: () => + if time() - @lastTime <= 1000 + @frames += 1 + else + @value = @frames + @frames = 0 + @lastTime = time() + return @value + +fps = FPS! +bunnies = {} +table.insert(bunnies, Bunny!) + +export TIC=-> + -- music + if t == 0 then + music(0) + if t == 6*64*2.375 then + music(1) + t = t + 1 + + -- Input + if btn(0) + for i = 1, 5 + table.insert(bunnies, Bunny!) + elseif btn(1) + for i = 1, 5 + table.remove(bunnies, 1) + + -- Update + for i, item in pairs bunnies + item\update! + + -- Draw + cls(15) + for i, item in pairs bunnies + item\draw! + + rect(0, 0, screenWidth, toolbarHeight, 0) + print("Bunnies: " .. #bunnies, 1, 0, 11, false, 1, false) + print("FPS: " .. fps\getValue!, screenWidth / 2, 0, 11, false, 1, false) + +-- +-- 001:11111100111110dd111110dc111110dc111110dc111110dc111110dd111110dd +-- 002:00011110ddd0110dccd0110dccd0110dccd0110dccd0110dcddd00dddddddddd +-- 003:00001111dddd0111cccd0111cccd0111cccd0111cccd0111dcdd0111dddd0111 +-- 004:1111111111111111111111111111111111111111111111111111111111111111 +-- 017:111110dd111110dd111110dd111110dd10000ddd1eeeeddd1eeeeedd10000eed +-- 018:d0ddddddd0ddddddddddddddddd0000dddddccddddddccdddddddddddddddddd +-- 019:0ddd01110ddd0111dddd0111dddd0111ddddd000ddddddddddddddddddddd000 +-- 020:1111111111111111111111111111111101111111d0111111d011111101111111 +-- 033:111110ee111110ee111110ee111110ee111110ee111110ee111110ee111110ee +-- 034:dddcccccddccccccddccccccddccccccddccccccdddcccccdddddddddddddddd +-- 035:dddd0111cddd0111cddd0111cddd0111cddd0111dddd0111dddd0111dddd0111 +-- 036:1111111111111111111111111111111111111111111111111111111111111111 +-- 049:111110ee111110ee111110ee111110ee111110ee111110ee111110ee11111100 +-- 050:dddeeeeeddeeeeeed00000000111111101111111011111110111111111111111 +-- 051:eddd0111eedd01110eed011110ee011110ee011110ee011110ee011111001111 +-- 052:1111111111111111111111111111111111111111111111111111111111111111 +-- + +-- +-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57 +-- diff --git a/demos/yuedemo.yue b/demos/yuedemo.yue new file mode 100644 index 000000000..a45219697 --- /dev/null +++ b/demos/yuedemo.yue @@ -0,0 +1,55 @@ +-- title: game title +-- author: game developer, email, etc. +-- desc: short description +-- site: website link +-- license: MIT License (change this to your license of choice) +-- version: 0.1 +-- script: yue + +t=0 +x=96 +y=24 + +export TIC=-> + if btn 0 + y-=1 + if btn 1 + y+=1 + if btn 2 + x-=1 + if btn 3 + x+=1 + + cls 13 + spr 1+(t%60)//30*2,x,y,14,3,0,0,2,2 + print "HELLO WORLD!",84,84 + t+=1 + +-- +-- 001:eccccccccc888888caaaaaaaca888888cacccccccacc0ccccacc0ccccacc0ccc +-- 002:ccccceee8888cceeaaaa0cee888a0ceeccca0ccc0cca0c0c0cca0c0c0cca0c0c +-- 003:eccccccccc888888caaaaaaaca888888cacccccccacccccccacc0ccccacc0ccc +-- 004:ccccceee8888cceeaaaa0cee888a0ceeccca0cccccca0c0c0cca0c0c0cca0c0c +-- 017:cacccccccaaaaaaacaaacaaacaaaaccccaaaaaaac8888888cc000cccecccccec +-- 018:ccca00ccaaaa0ccecaaa0ceeaaaa0ceeaaaa0cee8888ccee000cceeecccceeee +-- 019:cacccccccaaaaaaacaaacaaacaaaaccccaaaaaaac8888888cc000cccecccccec +-- 020:ccca00ccaaaa0ccecaaa0ceeaaaa0ceeaaaa0cee8888ccee000cceeecccceeee +-- + +-- +-- 000:00000000ffffffff00000000ffffffff +-- 001:0123456789abcdeffedcba9876543210 +-- 002:0123456789abcdef0123456789abcdef +-- + +-- +-- 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000 +-- + +-- +-- 000:1a1c2c5d275db13e53ef7d57ffcd75a7f07038b76425717929366f3b5dc941a6f673eff7f4f4f494b0c2566c86333c57 +-- + +-- +-- 000:100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +-- diff --git a/src/api/yue.cpp b/src/api/yue.cpp new file mode 100644 index 000000000..dbaf16e97 --- /dev/null +++ b/src/api/yue.cpp @@ -0,0 +1,207 @@ +#include "core/core.h" +#include "luaapi.h" +#include "yuescript/yue_compiler.h" + +static inline bool isalnum_(char c) +{ + return isalnum(c) || c == '_'; +} + +#define YUE_CODE(...) #__VA_ARGS__ + +static void evalYuescript(tic_mem* tic, const char* code) +{ + tic_core* core = (tic_core*)tic; + lua_State* lua = (lua_State*)core->currentVM; + + yue::YueCompiler compiler; + auto result = compiler.compile(code, yue::YueConfig()); + + if (result.error) + { + core->data->error(core->data->data, result.error->displayMessage.c_str()); + return; + } + + const char* luaCode = result.codes.c_str(); + if (luaL_loadstring(lua, luaCode) == LUA_OK) + { + if (lua_pcall(lua, 0, 0, 0) != LUA_OK) + { + const char* msg = lua_tostring(lua, -1); + if (msg) + { + core->data->error(core->data->data, msg); + } + } + } +} + +static bool initYuescript(tic_mem* tic, const char* code) +{ + tic_core* core = (tic_core*)tic; + luaapi_close(tic); + + core->currentVM = luaL_newstate(); + lua_State* lua = (lua_State*)core->currentVM; + luaapi_open(lua); + + luaapi_init(core); + + evalYuescript(tic, code); + + return true; +} + +static const char* const YueKeywords[] = + { + "false", + "true", + "nil", + "local", + "global", + "return", + "break", + "continue", + "for", + "while", + "repeat", + "until", + "if", + "else", + "elseif", + "then", + "switch", + "when", + "unless", + "and", + "or", + "in", + "not", + "super", + "try", + "catch", + "with", + "export", + "import", + "from", + "class", + "extends", + "using", + "do", + "macro", +}; + +static const tic_outline_item* getYueOutline(const char* code, s32* size) +{ + enum + { + Size = sizeof(tic_outline_item) + }; + + *size = 0; + + static tic_outline_item* items = NULL; + + if (items) + { + free(items); + items = NULL; + } + + const char* ptr = code; + + while (true) + { + static const char FuncString[] = "->"; + + ptr = strstr(ptr, FuncString); + + if (ptr) + { + const char* end = ptr; + + ptr += sizeof FuncString - 1; + + while (end >= code && !isalnum_(*end)) + end--; + + const char* start = end; + + for (const char* val = start - 1; val >= code && (isalnum_(*val)); val--, start--) + ; + + if (end > start) + { + tic_outline_item* new_items = (tic_outline_item*)realloc(items, (*size + 1) * Size); + if (new_items) { + items = new_items; + items[*size].pos = start; + items[*size].size = (s32)(end - start + 1); + (*size)++; + } + } + } + else + break; + } + + return items; +} + +static const u8 DemoRom[] = + { +#include "../build/assets/yuedemo.tic.dat" +}; + +static const u8 MarkRom[] = + { +#include "../build/assets/yuemark.tic.dat" +}; + +TIC_EXPORT const tic_script EXPORT_SCRIPT(Yue) = { + 21, // id + "yue", // name + ".yue", // fileExtension + "--", // projectComment + { + initYuescript, // init + luaapi_close, // close + luaapi_tick, // tick + luaapi_boot, // boot + { // callback + luaapi_scn, // scanline + luaapi_bdr, // border + luaapi_menu // menu + } + }, + getYueOutline, // getOutline + evalYuescript, // eval + nullptr, // blockCommentStart + nullptr, // blockCommentEnd + "--[[", // blockCommentStart2 + "]]", // blockCommentEnd2 + nullptr, // blockStringStart + nullptr, // blockStringEnd + nullptr, // stdStringStartEnd + "--", // singleComment + nullptr, // blockEnd + YueKeywords, // keywords + COUNT_OF(YueKeywords), // keywordsCount + nullptr, // lang_isalnum + false, // useStructuredEdition + false, // useBinarySection + 0, // api_keywordsCount + nullptr, // api_keywords + { // demo + DemoRom, + sizeof DemoRom, + nullptr + }, + { // mark + MarkRom, + sizeof MarkRom, + "yuemark.tic" + }, + nullptr // demos +}; \ No newline at end of file diff --git a/src/script.c b/src/script.c index 1377a7141..136dba3e1 100644 --- a/src/script.c +++ b/src/script.c @@ -45,6 +45,10 @@ extern tic_script EXPORT_SCRIPT(Js); extern tic_script EXPORT_SCRIPT(Moon); #endif +#if defined(TIC_BUILD_WITH_YUE) +extern tic_script EXPORT_SCRIPT(Yue); +#endif + #if defined(TIC_BUILD_WITH_FENNEL) extern tic_script EXPORT_SCRIPT(Fennel); #endif @@ -94,6 +98,10 @@ static const tic_script *Scripts[MAX_SUPPORTED_LANGS + 1] = &EXPORT_SCRIPT(Moon), #endif + #if defined(TIC_BUILD_WITH_YUE) + &EXPORT_SCRIPT(Yue), + #endif + #if defined(TIC_BUILD_WITH_FENNEL) &EXPORT_SCRIPT(Fennel), #endif diff --git a/vendor/yuescript b/vendor/yuescript new file mode 160000 index 000000000..da0260390 --- /dev/null +++ b/vendor/yuescript @@ -0,0 +1 @@ +Subproject commit da0260390989165f6fdf7c31322edb605fb16470 From c213639b925f383482b6db122caab9baf6869942 Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 21 Jan 2025 11:39:46 +0800 Subject: [PATCH 02/19] Fixed YueScript build. --- build/baremetalpi/toolchain.cmake | 2 +- cmake/yue.cmake | 2 +- src/api/yue.cpp | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build/baremetalpi/toolchain.cmake b/build/baremetalpi/toolchain.cmake index 86c74d2c3..4132275bb 100644 --- a/build/baremetalpi/toolchain.cmake +++ b/build/baremetalpi/toolchain.cmake @@ -30,7 +30,7 @@ get_filename_component(ARM_TOOLCHAIN_DIR ${BINUTILS_PATH} DIRECTORY) # Now squirrel works. # Ideally should use the CFLAGS defined in circle build files, not hardwire them here too. # For RPI2 -#set(CMAKE_C_FLAGS " -DMINIZ_NO_TIME -DTIC_BUILD_WITH_FENNEL -DTIC_BUILD_WITH_MOON -DTIC_BUILD_WITH_JS -DTIC_BUILD_WITH_WREN -DTIC_BUILD_WITH_LUA -DLUA_32BITS -std=c99 -march=armv7-a+neon-vfpv4 -D AARCH=32 -D __circle__ -D BAREMETALPI --specs=nosys.specs -O3 -mabi=aapcs -marm -mfloat-abi=hard -mfpu=neon-vfpv4 -D__DYNAMIC_REENT__") +#set(CMAKE_C_FLAGS " -DMINIZ_NO_TIME -DTIC_BUILD_WITH_FENNEL -DTIC_BUILD_WITH_MOON -DTIC_BUILD_WITH_YUE -DTIC_BUILD_WITH_JS -DTIC_BUILD_WITH_WREN -DTIC_BUILD_WITH_LUA -DLUA_32BITS -std=c99 -march=armv7-a+neon-vfpv4 -D AARCH=32 -D __circle__ -D BAREMETALPI --specs=nosys.specs -O3 -mabi=aapcs -marm -mfloat-abi=hard -mfpu=neon-vfpv4 -D__DYNAMIC_REENT__") # For RPI3 # investigate -funsafe-math-optimizations and -march=armv8-a+crc -mcpu=cortex-a53 set(CMAKE_C_FLAGS " -DMINIZ_NO_TIME -DLUA_32BITS -std=c99 -march=armv8-a -D AARCH=32 -mtune=cortex-a53 -D __circle__ -D BAREMETALPI --specs=nosys.specs -O3 -marm -mfloat-abi=hard -mfpu=neon-fp-armv8 -funsafe-math-optimizations -D__DYNAMIC_REENT__") diff --git a/cmake/yue.cmake b/cmake/yue.cmake index 63ef9b98b..8f5605f3d 100644 --- a/cmake/yue.cmake +++ b/cmake/yue.cmake @@ -50,7 +50,7 @@ if(BUILD_WITH_YUE) endif() if(APPLE) - target_compile_definitions(yuescript PRIVATE -Wno-deprecated-declarations) + target_compile_options(yuescript PRIVATE -Wno-deprecated-declarations) endif() endif() \ No newline at end of file diff --git a/src/api/yue.cpp b/src/api/yue.cpp index dbaf16e97..dc0ae2691 100644 --- a/src/api/yue.cpp +++ b/src/api/yue.cpp @@ -1,5 +1,8 @@ +extern "C" { #include "core/core.h" #include "luaapi.h" +} + #include "yuescript/yue_compiler.h" static inline bool isalnum_(char c) @@ -159,7 +162,7 @@ static const u8 MarkRom[] = #include "../build/assets/yuemark.tic.dat" }; -TIC_EXPORT const tic_script EXPORT_SCRIPT(Yue) = { +extern "C" TIC_EXPORT const tic_script EXPORT_SCRIPT(Yue) = { 21, // id "yue", // name ".yue", // fileExtension From f8e60f6b04a00eaca70b237cad9b97f792482ccc Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 21 Jan 2025 12:29:58 +0800 Subject: [PATCH 03/19] Disabled macro feature which crashes runtime. --- cmake/yue.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/yue.cmake b/cmake/yue.cmake index 8f5605f3d..747e93a4b 100644 --- a/cmake/yue.cmake +++ b/cmake/yue.cmake @@ -43,6 +43,8 @@ if(BUILD_WITH_YUE) ${CMAKE_SOURCE_DIR}/src ) + target_compile_definitions(yuescript PRIVATE YUE_NO_MACRO) + if(MSVC) target_compile_definitions(yuescript PRIVATE _SCL_SECURE_NO_WARNINGS) else() From 93966751be87204112bb607ff7885efb3d366bdb Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Tue, 21 Jan 2025 13:56:55 +0700 Subject: [PATCH 04/19] Update YueScript submodule --- vendor/yuescript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/yuescript b/vendor/yuescript index da0260390..42311be3c 160000 --- a/vendor/yuescript +++ b/vendor/yuescript @@ -1 +1 @@ -Subproject commit da0260390989165f6fdf7c31322edb605fb16470 +Subproject commit 42311be3c22631210abec0b6ff653e59501e666c From 94f39aa2c2fe2653197aa7cf504b7f822f4a6c5d Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Tue, 21 Jan 2025 14:06:33 +0700 Subject: [PATCH 05/19] Try to fix the "function TIC()..." isn't found bug, no luck so far... --- src/api/yue.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/api/yue.cpp b/src/api/yue.cpp index dc0ae2691..38627b730 100644 --- a/src/api/yue.cpp +++ b/src/api/yue.cpp @@ -116,7 +116,7 @@ static const tic_outline_item* getYueOutline(const char* code, s32* size) while (true) { - static const char FuncString[] = "->"; + static const char FuncString[] = "=->"; ptr = strstr(ptr, FuncString); @@ -180,10 +180,10 @@ extern "C" TIC_EXPORT const tic_script EXPORT_SCRIPT(Yue) = { }, getYueOutline, // getOutline evalYuescript, // eval - nullptr, // blockCommentStart - nullptr, // blockCommentEnd - "--[[", // blockCommentStart2 - "]]", // blockCommentEnd2 + "--[[", // blockCommentStart + "]]", // blockCommentEnd + nullptr, // blockCommentStart2 + nullptr, // blockCommentEnd2 nullptr, // blockStringStart nullptr, // blockStringEnd nullptr, // stdStringStartEnd From 2f9a25a3d141a5832e8d4fba5a1da1ef71379a3f Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Tue, 21 Jan 2025 18:09:03 +0700 Subject: [PATCH 06/19] Fix Demo and Mark --- build/assets/yuedemo.tic.dat | 2 +- build/assets/yuemark.tic.dat | 2 +- demos/bunny/yuemark.yue | 142 +++++++++++++++++------------------ demos/yuedemo.yue | 28 +++---- 4 files changed, 87 insertions(+), 87 deletions(-) diff --git a/build/assets/yuedemo.tic.dat b/build/assets/yuedemo.tic.dat index aec00eab2..df05b60fc 100644 --- a/build/assets/yuedemo.tic.dat +++ b/build/assets/yuedemo.tic.dat @@ -1 +1 @@ -0x78, 0xda, 0xbd, 0x54, 0x6d, 0x4f, 0xdb, 0x30, 0x10, 0xde, 0x97, 0xed, 0x43, 0x7e, 0x85, 0x87, 0x34, 0x09, 0x46, 0x0a, 0x67, 0x3b, 0x89, 0x93, 0x88, 0x22, 0x21, 0xe8, 0x34, 0xb4, 0x4e, 0x4c, 0x50, 0x8d, 0x7d, 0x75, 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, 0x74, 0x3a, 0xad, 0x93, 0x9e, 0x27, 0x7b, 0x1e, 0x3d, 0x04, 0x9e, 0x45, 0xcf, 0xc9, 0x71, 0xb7, 0x4b, 0x0e, 0xdc, 0x9e, 0x7d, 0xdd, 0xec, 0x15, 0xe4, 0xd0, 0x99, 0xea, 0x6c, 0x17, 0xf7, 0xfb, 0x07, 0x98, 0xd0, 0x28, 0x4e, 0x58, 0x9a, 0xf1, 0x42, 0x94, 0x52, 0x29, 0x59, 0x8a, 0x82, 0x67, 0x29, 0x4b, 0xe2, 0x88, 0x12, 0x0c, 0xfd, 0x7e, 0xed, 0xf6, 0xed, 0x62, 0xaf, 0xa7, 0xd3, 0xe0, 0xc0, 0xcd, 0x87, 0x6f, 0x4f, 0xd4, 0xbc, 0xb4, 0x51, 0x88, 0x36, 0xb1, 0x57, 0xe8, 0x54, 0xb9, 0xf0, 0xcb, 0xd9, 0x78, 0x34, 0x99, 0x8c, 0x36, 0x1a, 0x31, 0xc7, 0x82, 0x88, 0xb8, 0x24, 0x2c, 0x2e, 0x0b, 0x4c, 0x65, 0x4c, 0xa5, 0x62, 0x65, 0xcc, 0x94, 0x12, 0x25, 0x8b, 0x39, 0x53, 0xc0, 0x80, 0xa6, 0x05, 0x4b, 0x22, 0x12, 0x33, 0xcc, 0x32, 0x92, 0xd1, 0x24, 0x51, 0xb4, 0x88, 0x4b, 0x91, 0x45, 0x98, 0x27, 0x2a, 0x61, 0xe6, 0x84, 0x62, 0x2a, 0xb2, 0x57, 0x16, 0x15, 0x20, 0x48, 0x9c, 0x24, 0x22, 0x4d, 0x28, 0xa5, 0x22, 0x66, 0x7e, 0xfe, 0x66, 0xaa, 0xff, 0x2f, 0xb8, 0x3e, 0x3b, 0xff, 0xb4, 0xfd, 0xd1, 0xf0, 0x8b, 0x7c, 0x94, 0x6e, 0x75, 0xba, 0xd1, 0x3f, 0x01, 0x0f, 0xe1, 0xb0, 0x18, \ No newline at end of file +0x78, 0xda, 0xed, 0x52, 0xcd,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 0x99, 0x13, 0x33, 0x31, 0xed, 0x86, 0x59, 0x37, 0x2d, 0x5c, 0x35, 0x13, 0x6f, 0x19, 0x46, 0x3c, 0x10, 0xb0, 0x7d, 0x75, 0xd9, 0x6e, 0x77, 0xe0, 0xb6, 0x73, 0xd3, 0xbe, 0xd8, 0xda, 0x36, 0x4f, 0x1a, 0xf8, 0x51, 0x43, 0xe8, 0xfb, 0xde, 0x01, 0x2b, 0x07, 0x25, 0xd7, \ No newline at end of file diff --git a/build/assets/yuemark.tic.dat b/build/assets/yuemark.tic.dat index caffc7ab5..6f7ac1c2f 100644 --- a/build/assets/yuemark.tic.dat +++ b/build/assets/yuemark.tic.dat @@ -1 +1 @@ -0x78, 0xda, 0xad, 0x55, 0x6d, 0x6f, 0xdb, 0x36, 0x10, 0xde, 0x97, 0x7d, 0x11, 0xf6, 0x23, 0x2e, 0x1d, 0x06, 0xd8, 0xa9, 0xed, 0x90, 0x92, 0x25, 0xc5, 0x82, 0x1d, 0x64, 0x5d, 0x53, 0x2c, 0x40, 0x06, 0x14, 0x8d, 0xf7, 0x12, 0xa0, 0x5f, 0x68, 0x92, 0x8a, 0x85, 0xda, 0x92, 0x21, 0x51, 0x49, 0x8d, 0xa1, 0xff, 0x7d, 0xc7, 0x17, 0x29, 0xb2, 0xf3, 0xe2, 0xa2, 0x2b, 0x23, 0xeb, 0xa8, 0xe3, 0x73, 0x0f, 0xef, 0x8e, 0xc7, 0xcb, 0x8f, 0xbf, 0xfc, 0xf4, 0xc3, 0x70, 0x08, 0x2a, 0x53, 0x2b, 0x99, 0xc0, 0x9b, 0x3a, 0xcf, 0xb7, 0x6b, 0x56, 0x7e, 0x82, 0x2c, 0x87, 0x9b, 0x5a, 0x5e, 0xf3, 0x32, 0xdb, 0x28, 0x0f, 0x01, 0xac, 0x56, 0xcb, 0xa2, 0x4c, 0xe0, 0x43, 0xb1, 0x80, 0xab, 0x82, 0xf1, 0xe5, 0x00, 0xde, 0xb2, 0x3c, 0x63, 0xf0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, 0xe6, 0xe5, 0x74, 0x46, 0xfd, 0xf0, 0x88, 0xce, 0xe8, 0x66, 0x5d, 0xc6, 0xff, 0x22, 0x1b, 0x13, 0x4d, 0xb2, 0x1a, 0x80, 0x63, 0xe5, 0x8b, 0x8b, 0x76, 0x4c, 0x5c, 0x16, 0x15, 0x97, 0xa4, 0xa8, 0x21, 0xea, 0x1f, 0xca, 0x91, 0x5a, 0x95, 0xc4, 0x8f, 0x70, 0x2c, 0x35, 0xd5, 0xf6, 0xa2, 0x9a, 0xb9, 0x59, 0x7f, 0x3d, 0xbe, 0x98, 0x64, 0xc1, 0x66, 0xd4, 0xe6, 0x35, 0x39, 0xad, 0x73, 0xe3, 0xd4, 0x58, 0x6c, 0x4d, 0x34, 0xa3, 0x5b, 0x1c, 0xf4, 0x80, 0xd7, 0x6e, 0xde, 0x93, 0x8e, 0x2c, 0xb8, 0x09, 0xad, 0x16, 0xbc, 0x33, 0x3b, 0x45, 0xe6, 0xc4, 0xc4, 0x3f, 0x43, 0x82, 0x69, 0xc8, 0x14, 0xd9, 0xdb, 0x8c, 0x8a, 0x85, 0xcf, 0x69, 0xd8, 0x08, 0x0f, 0x8b, 0xee, 0x5c, 0x5d, 0xbc, 0xfd, 0xee, 0x40, 0xfb, 0x72, 0x4f, 0xff, 0x00, 0xc8, 0xda, 0xa8, 0x50, \ No newline at end of file diff --git a/demos/bunny/yuemark.yue b/demos/bunny/yuemark.yue index 2ec65f403..b7c1d6ea9 100644 --- a/demos/bunny/yuemark.yue +++ b/demos/bunny/yuemark.yue @@ -1,5 +1,5 @@ -- title: Bunnymark in YueScript --- author: Rob Loach, Dania Rifki +-- author: Rob Loach -- desc: Benchmarking tool to see how many bunnies can fly around the screen, using YueScript. -- license: MIT License -- input: gamepad @@ -12,83 +12,83 @@ toolbarHeight = 6 t = 0 class Bunny - @width: 26 - @height: 32 - - new: => - @x = math.random(0, screenWidth - @@width) - @y = math.random(0, screenHeight - @@height) - @speedX = math.random(-100, 100) / 60 - @speedY = math.random(-100, 100) / 60 - @sprite = 1 - - draw: () => - spr(@sprite, @x, @y, 1, 1, 0, 0, 4, 4) - - update: () => - @x += @speedX - @y += @speedY - - if @x + @@width > screenWidth - @x = screenWidth - @@width - @speedX *= -1 - if @x < 0 - @x = 0 - @speedX *= -1 - if @y + @@height > screenHeight - @y = screenHeight - @@height - @speedY *= -1 - if @y < toolbarHeight - @y = toolbarHeight - @speedY *= -1 + @width: 26 + @height: 32 + + new: => + @x = math.random(0, screenWidth - @@width) + @y = math.random(0, screenHeight - @@height) + @speedX = math.random(-100, 100) / 60 + @speedY = math.random(-100, 100) / 60 + @sprite = 1 + + draw: () => + spr(@sprite, @x, @y, 1, 1, 0, 0, 4, 4) + + update: () => + @x += @speedX + @y += @speedY + + if @x + @@width > screenWidth + @x = screenWidth - @@width + @speedX *= -1 + if @x < 0 + @x = 0 + @speedX *= -1 + if @y + @@height > screenHeight + @y = screenHeight - @@height + @speedY *= -1 + if @y < toolbarHeight + @y = toolbarHeight + @speedY *= -1 class FPS - new: => - @value = 0 - @frames = 0 - @lastTime = 0 - - getValue: () => - if time() - @lastTime <= 1000 - @frames += 1 - else - @value = @frames - @frames = 0 - @lastTime = time() - return @value + new: => + @value = 0 + @frames = 0 + @lastTime = 0 + + getValue: () => + if time() - @lastTime <= 1000 + @frames += 1 + else + @value = @frames + @frames = 0 + @lastTime = time() + return @value fps = FPS! bunnies = {} table.insert(bunnies, Bunny!) -export TIC=-> - -- music - if t == 0 then - music(0) - if t == 6*64*2.375 then - music(1) - t = t + 1 - - -- Input - if btn(0) - for i = 1, 5 - table.insert(bunnies, Bunny!) - elseif btn(1) - for i = 1, 5 - table.remove(bunnies, 1) - - -- Update - for i, item in pairs bunnies - item\update! - - -- Draw - cls(15) - for i, item in pairs bunnies - item\draw! - - rect(0, 0, screenWidth, toolbarHeight, 0) - print("Bunnies: " .. #bunnies, 1, 0, 11, false, 1, false) - print("FPS: " .. fps\getValue!, screenWidth / 2, 0, 11, false, 1, false) +global TIC=-> + -- music + if t == 0 then + music(0) + if t == 6*64*2.375 then + music(1) + t = t + 1 + + -- Input + if btn(0) + for i = 1, 5 + table.insert(bunnies, Bunny!) + elseif btn(1) + for i = 1, 5 + table.remove(bunnies, 1) + + -- Update + for i, item in pairs bunnies + item\update! + + -- Draw + cls(15) + for i, item in pairs bunnies + item\draw! + + rect(0, 0, screenWidth, toolbarHeight, 0) + print("Bunnies: " .. #bunnies, 1, 0, 11, false, 1, false) + print("FPS: " .. fps\getValue!, screenWidth / 2, 0, 11, false, 1, false) -- -- 001:11111100111110dd111110dc111110dc111110dc111110dc111110dd111110dd diff --git a/demos/yuedemo.yue b/demos/yuedemo.yue index a45219697..fe18bca1b 100644 --- a/demos/yuedemo.yue +++ b/demos/yuedemo.yue @@ -10,20 +10,20 @@ t=0 x=96 y=24 -export TIC=-> - if btn 0 - y-=1 - if btn 1 - y+=1 - if btn 2 - x-=1 - if btn 3 - x+=1 - - cls 13 - spr 1+(t%60)//30*2,x,y,14,3,0,0,2,2 - print "HELLO WORLD!",84,84 - t+=1 +global TIC=-> + if btn 0 + y-=1 + if btn 1 + y+=1 + if btn 2 + x-=1 + if btn 3 + x+=1 + + cls 13 + spr 1+(t%60)//30*2,x,y,14,3,0,0,2,2 + print "HELLO WORLD!",84,84 + t+=1 -- -- 001:eccccccccc888888caaaaaaaca888888cacccccccacc0ccccacc0ccccacc0ccc From b5c0e806658e5c7678e2dda10f419d2bfb5e9f4d Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Tue, 21 Jan 2025 18:29:35 +0700 Subject: [PATCH 07/19] Format yue.cpp --- src/api/yue.cpp | 90 ++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/src/api/yue.cpp b/src/api/yue.cpp index 38627b730..388af7aaf 100644 --- a/src/api/yue.cpp +++ b/src/api/yue.cpp @@ -1,4 +1,5 @@ -extern "C" { +extern "C" +{ #include "core/core.h" #include "luaapi.h" } @@ -137,7 +138,8 @@ static const tic_outline_item* getYueOutline(const char* code, s32* size) if (end > start) { tic_outline_item* new_items = (tic_outline_item*)realloc(items, (*size + 1) * Size); - if (new_items) { + if (new_items) + { items = new_items; items[*size].pos = start; items[*size].size = (s32)(end - start + 1); @@ -163,48 +165,46 @@ static const u8 MarkRom[] = }; extern "C" TIC_EXPORT const tic_script EXPORT_SCRIPT(Yue) = { - 21, // id - "yue", // name - ".yue", // fileExtension - "--", // projectComment + 21, // id + "yue", // name + ".yue", // fileExtension + "--", // projectComment { - initYuescript, // init - luaapi_close, // close - luaapi_tick, // tick - luaapi_boot, // boot - { // callback - luaapi_scn, // scanline - luaapi_bdr, // border - luaapi_menu // menu - } - }, - getYueOutline, // getOutline - evalYuescript, // eval - "--[[", // blockCommentStart - "]]", // blockCommentEnd - nullptr, // blockCommentStart2 - nullptr, // blockCommentEnd2 - nullptr, // blockStringStart - nullptr, // blockStringEnd - nullptr, // stdStringStartEnd - "--", // singleComment - nullptr, // blockEnd - YueKeywords, // keywords - COUNT_OF(YueKeywords), // keywordsCount - nullptr, // lang_isalnum - false, // useStructuredEdition - false, // useBinarySection - 0, // api_keywordsCount - nullptr, // api_keywords - { // demo - DemoRom, - sizeof DemoRom, - nullptr - }, - { // mark - MarkRom, - sizeof MarkRom, - "yuemark.tic" - }, - nullptr // demos + initYuescript, // init + luaapi_close, // close + luaapi_tick, // tick + luaapi_boot, // boot + { + // callback + luaapi_scn, // scanline + luaapi_bdr, // border + luaapi_menu // menu + }}, + getYueOutline, // getOutline + evalYuescript, // eval + "--[[", // blockCommentStart + "]]", // blockCommentEnd + nullptr, // blockCommentStart2 + nullptr, // blockCommentEnd2 + nullptr, // blockStringStart + nullptr, // blockStringEnd + nullptr, // stdStringStartEnd + "--", // singleComment + nullptr, // blockEnd + YueKeywords, // keywords + COUNT_OF(YueKeywords), // keywordsCount + nullptr, // lang_isalnum + false, // useStructuredEdition + false, // useBinarySection + 0, // api_keywordsCount + nullptr, // api_keywords + { // demo + DemoRom, + sizeof DemoRom, + nullptr}, + {// mark + MarkRom, + sizeof MarkRom, + "yuemark.tic"}, + nullptr // demos }; \ No newline at end of file From 935c10afe4ff2624095e8866b38cfafda8c42356 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Wed, 22 Jan 2025 04:10:05 +0700 Subject: [PATCH 08/19] Make it work in C99, let's hope this compiles in Win XP et cetera --- cmake/yue.cmake | 31 +++- src/api/yue.c | 251 ++++++++++++++++++++++++++++ src/api/yue.cpp | 210 ----------------------- src/api/yue_wrapper/yue_wrapper.cpp | 131 +++++++++++++++ src/api/yue_wrapper/yue_wrapper.h | 98 +++++++++++ 5 files changed, 502 insertions(+), 219 deletions(-) create mode 100644 src/api/yue.c delete mode 100644 src/api/yue.cpp create mode 100644 src/api/yue_wrapper/yue_wrapper.cpp create mode 100644 src/api/yue_wrapper/yue_wrapper.h diff --git a/cmake/yue.cmake b/cmake/yue.cmake index 747e93a4b..3a4d21015 100644 --- a/cmake/yue.cmake +++ b/cmake/yue.cmake @@ -16,7 +16,7 @@ if(BUILD_WITH_YUE) ${YUESCRIPT_DIR}/src/yuescript/yuescript.cpp ) - list(APPEND YUESCRIPT_SRC ${CMAKE_SOURCE_DIR}/src/api/yue.cpp) + list(APPEND YUESCRIPT_SRC ${CMAKE_SOURCE_DIR}/src/api/yue.c) list(APPEND YUESCRIPT_SRC ${CMAKE_SOURCE_DIR}/src/api/parse_note.c) add_library(yuescript ${TIC_RUNTIME} ${YUESCRIPT_SRC}) @@ -27,9 +27,13 @@ if(BUILD_WITH_YUE) target_compile_definitions(yuescript INTERFACE TIC_BUILD_WITH_YUE) endif() - target_link_libraries(yuescript PRIVATE runtime luaapi) + target_link_libraries(yuescript + PRIVATE + runtime + luaapi + ) - set_target_properties(yuescript PROPERTIES + set_target_properties(yuescript PROPERTIES LINKER_LANGUAGE CXX CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON @@ -37,13 +41,22 @@ if(BUILD_WITH_YUE) target_include_directories(yuescript PRIVATE - ${YUESCRIPT_DIR}/src - ${YUESCRIPT_DIR}/src/yuescript - ${CMAKE_SOURCE_DIR}/include - ${CMAKE_SOURCE_DIR}/src + ${YUESCRIPT_DIR}/src + ${YUESCRIPT_DIR}/src/yuescript + ${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/api ) - target_compile_definitions(yuescript PRIVATE YUE_NO_MACRO) + target_compile_definitions(yuescript PRIVATE YUE_NO_MACRO YUE_WRAPPER_EXPORTS + $<$:_SCL_SECURE_NO_WARNINGS>) + + target_sources(yuescript PRIVATE + ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.cpp + ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.h + ) + + target_link_libraries(yuescript PRIVATE runtime luaapi) if(MSVC) target_compile_definitions(yuescript PRIVATE _SCL_SECURE_NO_WARNINGS) @@ -55,4 +68,4 @@ if(BUILD_WITH_YUE) target_compile_options(yuescript PRIVATE -Wno-deprecated-declarations) endif() -endif() \ No newline at end of file +endif() diff --git a/src/api/yue.c b/src/api/yue.c new file mode 100644 index 000000000..485c1acca --- /dev/null +++ b/src/api/yue.c @@ -0,0 +1,251 @@ +// MIT License + +// Copyright (c) 2017 Vadim Grigoruk @nesbox // grigoruk@gmail.com + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include "core/core.h" +#include "luaapi.h" +#include "yue_wrapper/yue_wrapper.h" + +static inline bool isalnum_(char c) +{ + return isalnum(c) || c == '_'; +} + +#define YUE_CODE(...) #__VA_ARGS__ + +static void evalYuescript(tic_mem* tic, const char* code) +{ + tic_core* core = (tic_core*)tic; + lua_State* lua = (lua_State*)core->currentVM; + + YueCompiler_t* compiler = yue_compiler_create(NULL, NULL, false); + YueConfig_t* config = yue_config_create(); + CompileInfo_t* result = yue_compile(compiler, code, config); + + if (result->error_msg) + { + core->data->error(core->data->data, result->error_display_message); + yue_compile_info_free(result); + yue_config_free(config); + yue_compiler_destroy(compiler); + return; + } + + const char* luaCode = result->codes; + if (luaL_loadstring(lua, luaCode) == LUA_OK) + { + if (lua_pcall(lua, 0, 0, 0) != LUA_OK) + { + const char* msg = lua_tostring(lua, -1); + if (msg) + { + core->data->error(core->data->data, msg); + } + } + } + + yue_compile_info_free(result); + yue_config_free(config); + yue_compiler_destroy(compiler); +} + +static bool initYuescript(tic_mem* tic, const char* code) +{ + tic_core* core = (tic_core*)tic; + luaapi_close(tic); + + core->currentVM = luaL_newstate(); + lua_State* lua = (lua_State*)core->currentVM; + luaapi_open(lua); + + // Create compiler with the Lua state and luaapi_open + YueCompiler_t* compiler = yue_compiler_create(lua, luaapi_open, false); + YueConfig_t* config = yue_config_create(); + CompileInfo_t* result = yue_compile(compiler, code, config); + + luaapi_init(core); + + if (result->error_msg) + { + core->data->error(core->data->data, result->error_display_message); + yue_compile_info_free(result); + yue_config_free(config); + yue_compiler_destroy(compiler); + return false; + } + + bool success = true; + if (luaL_loadstring(lua, result->codes) != LUA_OK || + lua_pcall(lua, 0, 0, 0) != LUA_OK) + { + const char* msg = lua_tostring(lua, -1); + if (msg) core->data->error(core->data->data, msg); + success = false; + } + + yue_compile_info_free(result); + yue_config_free(config); + yue_compiler_destroy(compiler); + return success; +} +static const char* const YueKeywords[] = { + "false", + "true", + "nil", + "local", + "global", + "return", + "break", + "continue", + "for", + "while", + "repeat", + "until", + "if", + "else", + "elseif", + "then", + "switch", + "when", + "unless", + "and", + "or", + "in", + "not", + "super", + "try", + "catch", + "with", + "export", + "import", + "from", + "class", + "extends", + "using", + "do", + "macro", +}; + +static const tic_outline_item* getYueOutline(const char* code, s32* size) +{ + enum + { + Size = sizeof(tic_outline_item) + }; + + *size = 0; + + static tic_outline_item* items = NULL; + + if (items) + { + free(items); + items = NULL; + } + + const char* ptr = code; + + while (1) + { + static const char FuncString[] = "=->"; + + ptr = strstr(ptr, FuncString); + + if (ptr) + { + const char* end = ptr; + + ptr += sizeof FuncString - 1; + + while (end >= code && !isalnum_(*end)) + end--; + + const char* start = end; + + for (const char* val = start - 1; val >= code && isalnum_(*val); val--, start--) + ; + + if (end > start) + { + tic_outline_item* new_items = (tic_outline_item*)realloc(items, (*size + 1) * Size); + if (new_items) + { + items = new_items; + items[*size].pos = start; + items[*size].size = (s32)(end - start + 1); + (*size)++; + } + } + } + else + break; + } + + return items; +} + +static const u8 DemoRom[] = { +#include "../build/assets/yuedemo.tic.dat" +}; + +static const u8 MarkRom[] = { +#include "../build/assets/yuemark.tic.dat" +}; + +TIC_EXPORT const tic_script EXPORT_SCRIPT(Yue) = +{ + .id = 21, + .name = "yue", + .fileExtension = ".yue", + .projectComment = "--", + { + .init = initYuescript, + .close = luaapi_close, + .tick = luaapi_tick, + .boot = luaapi_boot, + + .callback = + { + .scanline = luaapi_scn, + .border = luaapi_bdr, + .menu = luaapi_menu, + }, + }, + + .getOutline = getYueOutline, + .eval = evalYuescript, + + .blockCommentStart = "--[[", + .blockCommentEnd = "]]", + .blockCommentStart2 = NULL, + .blockCommentEnd2 = NULL, + + .blockStringStart = NULL, + .blockStringEnd = NULL, + .singleComment = "--", + .blockEnd = NULL, + + .keywords = YueKeywords, + .keywordsCount = COUNT_OF(YueKeywords), + + .demo = {DemoRom, sizeof DemoRom}, + .mark = {MarkRom, sizeof MarkRom, "yuemark.tic"}, +}; \ No newline at end of file diff --git a/src/api/yue.cpp b/src/api/yue.cpp deleted file mode 100644 index 388af7aaf..000000000 --- a/src/api/yue.cpp +++ /dev/null @@ -1,210 +0,0 @@ -extern "C" -{ -#include "core/core.h" -#include "luaapi.h" -} - -#include "yuescript/yue_compiler.h" - -static inline bool isalnum_(char c) -{ - return isalnum(c) || c == '_'; -} - -#define YUE_CODE(...) #__VA_ARGS__ - -static void evalYuescript(tic_mem* tic, const char* code) -{ - tic_core* core = (tic_core*)tic; - lua_State* lua = (lua_State*)core->currentVM; - - yue::YueCompiler compiler; - auto result = compiler.compile(code, yue::YueConfig()); - - if (result.error) - { - core->data->error(core->data->data, result.error->displayMessage.c_str()); - return; - } - - const char* luaCode = result.codes.c_str(); - if (luaL_loadstring(lua, luaCode) == LUA_OK) - { - if (lua_pcall(lua, 0, 0, 0) != LUA_OK) - { - const char* msg = lua_tostring(lua, -1); - if (msg) - { - core->data->error(core->data->data, msg); - } - } - } -} - -static bool initYuescript(tic_mem* tic, const char* code) -{ - tic_core* core = (tic_core*)tic; - luaapi_close(tic); - - core->currentVM = luaL_newstate(); - lua_State* lua = (lua_State*)core->currentVM; - luaapi_open(lua); - - luaapi_init(core); - - evalYuescript(tic, code); - - return true; -} - -static const char* const YueKeywords[] = - { - "false", - "true", - "nil", - "local", - "global", - "return", - "break", - "continue", - "for", - "while", - "repeat", - "until", - "if", - "else", - "elseif", - "then", - "switch", - "when", - "unless", - "and", - "or", - "in", - "not", - "super", - "try", - "catch", - "with", - "export", - "import", - "from", - "class", - "extends", - "using", - "do", - "macro", -}; - -static const tic_outline_item* getYueOutline(const char* code, s32* size) -{ - enum - { - Size = sizeof(tic_outline_item) - }; - - *size = 0; - - static tic_outline_item* items = NULL; - - if (items) - { - free(items); - items = NULL; - } - - const char* ptr = code; - - while (true) - { - static const char FuncString[] = "=->"; - - ptr = strstr(ptr, FuncString); - - if (ptr) - { - const char* end = ptr; - - ptr += sizeof FuncString - 1; - - while (end >= code && !isalnum_(*end)) - end--; - - const char* start = end; - - for (const char* val = start - 1; val >= code && (isalnum_(*val)); val--, start--) - ; - - if (end > start) - { - tic_outline_item* new_items = (tic_outline_item*)realloc(items, (*size + 1) * Size); - if (new_items) - { - items = new_items; - items[*size].pos = start; - items[*size].size = (s32)(end - start + 1); - (*size)++; - } - } - } - else - break; - } - - return items; -} - -static const u8 DemoRom[] = - { -#include "../build/assets/yuedemo.tic.dat" -}; - -static const u8 MarkRom[] = - { -#include "../build/assets/yuemark.tic.dat" -}; - -extern "C" TIC_EXPORT const tic_script EXPORT_SCRIPT(Yue) = { - 21, // id - "yue", // name - ".yue", // fileExtension - "--", // projectComment - { - initYuescript, // init - luaapi_close, // close - luaapi_tick, // tick - luaapi_boot, // boot - { - // callback - luaapi_scn, // scanline - luaapi_bdr, // border - luaapi_menu // menu - }}, - getYueOutline, // getOutline - evalYuescript, // eval - "--[[", // blockCommentStart - "]]", // blockCommentEnd - nullptr, // blockCommentStart2 - nullptr, // blockCommentEnd2 - nullptr, // blockStringStart - nullptr, // blockStringEnd - nullptr, // stdStringStartEnd - "--", // singleComment - nullptr, // blockEnd - YueKeywords, // keywords - COUNT_OF(YueKeywords), // keywordsCount - nullptr, // lang_isalnum - false, // useStructuredEdition - false, // useBinarySection - 0, // api_keywordsCount - nullptr, // api_keywords - { // demo - DemoRom, - sizeof DemoRom, - nullptr}, - {// mark - MarkRom, - sizeof MarkRom, - "yuemark.tic"}, - nullptr // demos -}; \ No newline at end of file diff --git a/src/api/yue_wrapper/yue_wrapper.cpp b/src/api/yue_wrapper/yue_wrapper.cpp new file mode 100644 index 000000000..13c78d70b --- /dev/null +++ b/src/api/yue_wrapper/yue_wrapper.cpp @@ -0,0 +1,131 @@ +#define YUE_WRAPPER_EXPORTS +#include "yue_wrapper.h" +#include "yuescript/yue_compiler.h" +#include +#include + +extern "C" { + +YueConfig_t* yue_config_create(void) { + YueConfig_t* config = new (std::nothrow) YueConfig_t(); + if (config) { + config->lint_global_variable = false; + config->implicit_return_root = true; + config->reserve_line_number = true; + config->use_space_over_tab = false; + config->reserve_comment = false; + config->exporting = false; + config->profiling = false; + config->line_offset = 0; + config->module = nullptr; + } + return config; +} + +void yue_config_free(YueConfig_t* config) { + delete config; +} + +YueCompiler_t* yue_compiler_create(void* lua_state, void (*lua_open)(void*), bool same_module) { + auto cpp_lua_open = lua_open ? + std::function([lua_open](void* l) { lua_open(l); }) : + std::function(); + + auto* compiler = new (std::nothrow) yue::YueCompiler(lua_state, cpp_lua_open, same_module); + return reinterpret_cast(compiler); +} + +void yue_compiler_destroy(YueCompiler_t* compiler) { + delete reinterpret_cast(compiler); +} + +CompileInfo_t* yue_compile(YueCompiler_t* compiler, const char* codes, const YueConfig_t* config) { + yue::YueConfig cpp_config; + if (config) { + cpp_config.lintGlobalVariable = config->lint_global_variable; + cpp_config.implicitReturnRoot = config->implicit_return_root; + cpp_config.reserveLineNumber = config->reserve_line_number; + cpp_config.useSpaceOverTab = config->use_space_over_tab; + cpp_config.reserveComment = config->reserve_comment; + cpp_config.exporting = config->exporting; + cpp_config.profiling = config->profiling; + cpp_config.lineOffset = config->line_offset; + if (config->module) { + cpp_config.module = config->module; + } + } + + auto cpp_compiler = reinterpret_cast(compiler); + auto result = cpp_compiler->compile(codes, cpp_config); + + auto* info = new (std::nothrow) CompileInfo_t(); + if (!info) return nullptr; + + // Copy the data + info->codes = strdup(result.codes.c_str()); + if (result.error) { + info->error_msg = strdup(result.error->msg.c_str()); + info->error_line = result.error->line; + info->error_col = result.error->col; + info->error_display_message = strdup(result.error->displayMessage.c_str()); + } else { + info->error_msg = nullptr; + info->error_line = 0; + info->error_col = 0; + info->error_display_message = nullptr; + } + + info->parse_time = result.parseTime; + info->compile_time = result.compileTime; + info->used_var = result.usedVar; + + if (result.globals) { + info->globals_count = result.globals->size(); + info->globals = new GlobalVar_t[info->globals_count]; + for (size_t i = 0; i < result.globals->size(); ++i) { + info->globals[i].name = strdup((*result.globals)[i].name.c_str()); + info->globals[i].line = (*result.globals)[i].line; + info->globals[i].col = (*result.globals)[i].col; + info->globals[i].access_type = static_cast( + static_cast((*result.globals)[i].accessType)); + } + } else { + info->globals = nullptr; + info->globals_count = 0; + } + + return info; +} + +void yue_compile_info_free(CompileInfo_t* info) { + if (!info) return; + + free((void*)info->codes); + free((void*)info->error_msg); + free((void*)info->error_display_message); + + if (info->globals) { + for (int i = 0; i < info->globals_count; ++i) { + free((void*)info->globals[i].name); + } + delete[] info->globals; + } + + delete info; +} + +void yue_compiler_clear(void* lua_state) { + yue::YueCompiler::clear(lua_state); +} + +const char* yue_get_version(void) { + static std::string version_str(yue::version); + return version_str.c_str(); +} + +const char* yue_get_extension(void) { + static std::string extension_str(yue::extension); + return extension_str.c_str(); +} + +} \ No newline at end of file diff --git a/src/api/yue_wrapper/yue_wrapper.h b/src/api/yue_wrapper/yue_wrapper.h new file mode 100644 index 000000000..1ced12bff --- /dev/null +++ b/src/api/yue_wrapper/yue_wrapper.h @@ -0,0 +1,98 @@ +// yue_wrapper.h +#ifndef YUE_WRAPPER_H +#define YUE_WRAPPER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _WIN32 + #ifdef YUE_WRAPPER_EXPORTS + #define YUE_WRAPPER_API __declspec(dllexport) + #else + #define YUE_WRAPPER_API __declspec(dllimport) + #endif +#else + #define YUE_WRAPPER_API +#endif + +typedef struct YueCompiler_t YueCompiler_t; +typedef struct YueConfig_t YueConfig_t; +typedef struct CompileInfo_t CompileInfo_t; +typedef struct GlobalVar_t GlobalVar_t; + +// Access type enum +typedef enum { + YUE_ACCESS_NONE, + YUE_ACCESS_READ, + YUE_ACCESS_CAPTURE, + YUE_ACCESS_WRITE +} YueAccessType; + +// Global variable structure +struct GlobalVar_t { + const char* name; + int line; + int col; + YueAccessType access_type; +}; + +// Configuration structure +struct YueConfig_t { + bool lint_global_variable; + bool implicit_return_root; + bool reserve_line_number; + bool use_space_over_tab; + bool reserve_comment; + bool exporting; + bool profiling; + int line_offset; + const char* module; +}; + +// Compile info structure +struct CompileInfo_t { + const char* codes; + const char* error_msg; + int error_line; + int error_col; + const char* error_display_message; + GlobalVar_t* globals; + int globals_count; + double parse_time; + double compile_time; + bool used_var; +}; + +// Create default config +YUE_WRAPPER_API YueConfig_t* yue_config_create(void); + +// Free config +YUE_WRAPPER_API void yue_config_free(YueConfig_t* config); + +// Create compiler +YUE_WRAPPER_API YueCompiler_t* yue_compiler_create(void* lua_state, void (*lua_open)(void*), bool same_module); + +// Destroy compiler +YUE_WRAPPER_API void yue_compiler_destroy(YueCompiler_t* compiler); + +// Compile code +YUE_WRAPPER_API CompileInfo_t* yue_compile(YueCompiler_t* compiler, const char* codes, const YueConfig_t* config); + +// Free compile info +YUE_WRAPPER_API void yue_compile_info_free(CompileInfo_t* info); + +// Clear compiler state +YUE_WRAPPER_API void yue_compiler_clear(void* lua_state); + +// Version and extension getters +YUE_WRAPPER_API const char* yue_get_version(void); +YUE_WRAPPER_API const char* yue_get_extension(void); + +#ifdef __cplusplus +} +#endif + +#endif // YUE_WRAPPER_H \ No newline at end of file From 938979a66b8468f16e38e72bf72666657f159f32 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Wed, 22 Jan 2025 05:01:23 +0700 Subject: [PATCH 09/19] Fix Compilation Issues --- src/api/yue.c | 8 +++++--- src/api/yue_wrapper/yue_wrapper.cpp | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/api/yue.c b/src/api/yue.c index 485c1acca..cf5791810 100644 --- a/src/api/yue.c +++ b/src/api/yue.c @@ -74,10 +74,12 @@ static bool initYuescript(tic_mem* tic, const char* code) core->currentVM = luaL_newstate(); lua_State* lua = (lua_State*)core->currentVM; - luaapi_open(lua); - // Create compiler with the Lua state and luaapi_open - YueCompiler_t* compiler = yue_compiler_create(lua, luaapi_open, false); + void (*open_func)(void*) = (void (*)(void*))luaapi_open; + open_func(lua); + + // Create compiler with the Lua state and open_func + YueCompiler_t* compiler = yue_compiler_create(lua, open_func, false); YueConfig_t* config = yue_config_create(); CompileInfo_t* result = yue_compile(compiler, code, config); diff --git a/src/api/yue_wrapper/yue_wrapper.cpp b/src/api/yue_wrapper/yue_wrapper.cpp index 13c78d70b..f93933e67 100644 --- a/src/api/yue_wrapper/yue_wrapper.cpp +++ b/src/api/yue_wrapper/yue_wrapper.cpp @@ -1,4 +1,3 @@ -#define YUE_WRAPPER_EXPORTS #include "yue_wrapper.h" #include "yuescript/yue_compiler.h" #include From 3efc2061d0c3600aa67d3bf8e93889ec8aca2131 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Wed, 22 Jan 2025 09:23:01 +0700 Subject: [PATCH 10/19] Try fixing rpi-baremetal(4) and nintendo-3ds builds --- cmake/yue.cmake | 12 +++++-- src/api/yue.c | 13 +++++++- src/api/yue_wrapper/yue_wrapper.cpp | 52 ++++++++++++++++++++++++++++- src/api/yue_wrapper/yue_wrapper.h | 4 +++ 4 files changed, 77 insertions(+), 4 deletions(-) diff --git a/cmake/yue.cmake b/cmake/yue.cmake index 3a4d21015..f0adc372c 100644 --- a/cmake/yue.cmake +++ b/cmake/yue.cmake @@ -48,8 +48,16 @@ if(BUILD_WITH_YUE) ${CMAKE_SOURCE_DIR}/src/api ) - target_compile_definitions(yuescript PRIVATE YUE_NO_MACRO YUE_WRAPPER_EXPORTS - $<$:_SCL_SECURE_NO_WARNINGS>) + target_compile_definitions(yuescript PRIVATE + YUE_NO_MACRO + YUE_WRAPPER_EXPORTS + $<$:_SCL_SECURE_NO_WARNINGS> + ) + + # Disable thread-safe statics on embedded platforms + if(BAREMETALPI OR NINTENDO_3DS) + target_compile_options(yuescript PRIVATE -fno-threadsafe-statics) + endif() target_sources(yuescript PRIVATE ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.cpp diff --git a/src/api/yue.c b/src/api/yue.c index cf5791810..8dddc0c77 100644 --- a/src/api/yue.c +++ b/src/api/yue.c @@ -36,6 +36,8 @@ static void evalYuescript(tic_mem* tic, const char* code) tic_core* core = (tic_core*)tic; lua_State* lua = (lua_State*)core->currentVM; + yue_get_parser_instance(); + YueCompiler_t* compiler = yue_compiler_create(NULL, NULL, false); YueConfig_t* config = yue_config_create(); CompileInfo_t* result = yue_compile(compiler, code, config); @@ -72,6 +74,8 @@ static bool initYuescript(tic_mem* tic, const char* code) tic_core* core = (tic_core*)tic; luaapi_close(tic); + yue_get_parser_instance(); + core->currentVM = luaL_newstate(); lua_State* lua = (lua_State*)core->currentVM; @@ -108,6 +112,13 @@ static bool initYuescript(tic_mem* tic, const char* code) yue_compiler_destroy(compiler); return success; } + +static void closeYuescript(tic_mem* tic) +{ + luaapi_close(tic); + yue_cleanup(); +} + static const char* const YueKeywords[] = { "false", "true", @@ -220,7 +231,7 @@ TIC_EXPORT const tic_script EXPORT_SCRIPT(Yue) = .projectComment = "--", { .init = initYuescript, - .close = luaapi_close, + .close = closeYuescript, .tick = luaapi_tick, .boot = luaapi_boot, diff --git a/src/api/yue_wrapper/yue_wrapper.cpp b/src/api/yue_wrapper/yue_wrapper.cpp index f93933e67..7a570e9bb 100644 --- a/src/api/yue_wrapper/yue_wrapper.cpp +++ b/src/api/yue_wrapper/yue_wrapper.cpp @@ -1,13 +1,28 @@ #include "yue_wrapper.h" #include "yuescript/yue_compiler.h" +#include "yuescript/yue_parser.h" #include #include +// Wrapper class to expose YueParser functionality +class YueParserWrapper : public yue::YueParser { +public: + YueParserWrapper() : YueParser() {} + static YueParserWrapper* create() { return new YueParserWrapper(); } +}; + +namespace { + // Global parser instance for reuse + YueParserWrapper* g_parser_instance = nullptr; +} + extern "C" { +// Creates and initializes a new YueConfig with default values YueConfig_t* yue_config_create(void) { YueConfig_t* config = new (std::nothrow) YueConfig_t(); if (config) { + // Set default configuration values config->lint_global_variable = false; config->implicit_return_root = true; config->reserve_line_number = true; @@ -21,11 +36,14 @@ YueConfig_t* yue_config_create(void) { return config; } +// Frees memory allocated for YueConfig void yue_config_free(YueConfig_t* config) { delete config; } +// Creates a new YueCompiler instance with optional Lua state and callbacks YueCompiler_t* yue_compiler_create(void* lua_state, void (*lua_open)(void*), bool same_module) { + // Convert C callback to C++ std::function auto cpp_lua_open = lua_open ? std::function([lua_open](void* l) { lua_open(l); }) : std::function(); @@ -34,11 +52,17 @@ YueCompiler_t* yue_compiler_create(void* lua_state, void (*lua_open)(void*), boo return reinterpret_cast(compiler); } +// Destroys a YueCompiler instance void yue_compiler_destroy(YueCompiler_t* compiler) { delete reinterpret_cast(compiler); } +// Compiles Yuescript code using provided compiler and configuration CompileInfo_t* yue_compile(YueCompiler_t* compiler, const char* codes, const YueConfig_t* config) { + // Get parser instance for compilation + auto parser = static_cast(yue_get_parser_instance()); + + // Convert C config to C++ config yue::YueConfig cpp_config; if (config) { cpp_config.lintGlobalVariable = config->lint_global_variable; @@ -54,14 +78,18 @@ CompileInfo_t* yue_compile(YueCompiler_t* compiler, const char* codes, const Yue } } + // Perform compilation auto cpp_compiler = reinterpret_cast(compiler); auto result = cpp_compiler->compile(codes, cpp_config); + // Create and populate compilation info auto* info = new (std::nothrow) CompileInfo_t(); if (!info) return nullptr; - // Copy the data + // Copy compiled code info->codes = strdup(result.codes.c_str()); + + // Handle compilation errors if any if (result.error) { info->error_msg = strdup(result.error->msg.c_str()); info->error_line = result.error->line; @@ -74,10 +102,12 @@ CompileInfo_t* yue_compile(YueCompiler_t* compiler, const char* codes, const Yue info->error_display_message = nullptr; } + // Copy timing information info->parse_time = result.parseTime; info->compile_time = result.compileTime; info->used_var = result.usedVar; + // Copy global variables information if (result.globals) { info->globals_count = result.globals->size(); info->globals = new GlobalVar_t[info->globals_count]; @@ -96,13 +126,16 @@ CompileInfo_t* yue_compile(YueCompiler_t* compiler, const char* codes, const Yue return info; } +// Frees all memory associated with compilation info void yue_compile_info_free(CompileInfo_t* info) { if (!info) return; + // Free all dynamically allocated strings free((void*)info->codes); free((void*)info->error_msg); free((void*)info->error_display_message); + // Free global variables information if (info->globals) { for (int i = 0; i < info->globals_count; ++i) { free((void*)info->globals[i].name); @@ -113,18 +146,35 @@ void yue_compile_info_free(CompileInfo_t* info) { delete info; } +// Clears compiler state for given Lua state void yue_compiler_clear(void* lua_state) { yue::YueCompiler::clear(lua_state); } +// Returns Yuescript version string const char* yue_get_version(void) { static std::string version_str(yue::version); return version_str.c_str(); } +// Returns Yuescript file extension const char* yue_get_extension(void) { static std::string extension_str(yue::extension); return extension_str.c_str(); } +// Returns (creating if necessary) the global parser instance +void* yue_get_parser_instance() { + if (!g_parser_instance) { + g_parser_instance = YueParserWrapper::create(); + } + return g_parser_instance; +} + +// Cleanup global parser instance +void yue_cleanup() { + delete g_parser_instance; + g_parser_instance = nullptr; +} + } \ No newline at end of file diff --git a/src/api/yue_wrapper/yue_wrapper.h b/src/api/yue_wrapper/yue_wrapper.h index 1ced12bff..f0f31228c 100644 --- a/src/api/yue_wrapper/yue_wrapper.h +++ b/src/api/yue_wrapper/yue_wrapper.h @@ -91,6 +91,10 @@ YUE_WRAPPER_API void yue_compiler_clear(void* lua_state); YUE_WRAPPER_API const char* yue_get_version(void); YUE_WRAPPER_API const char* yue_get_extension(void); +// Add before other declarations: +YUE_WRAPPER_API void* yue_get_parser_instance(void); +YUE_WRAPPER_API void yue_cleanup(void); + #ifdef __cplusplus } #endif From 4d455a09b98ef4983d9c9dd6a1b6c4faca14eca0 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Wed, 22 Jan 2025 09:37:42 +0700 Subject: [PATCH 11/19] Try fixing linking --- cmake/yue.cmake | 22 ++++++++++++++++++++-- src/api/yue_wrapper/yue_wrapper.h | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/cmake/yue.cmake b/cmake/yue.cmake index f0adc372c..ccd17744f 100644 --- a/cmake/yue.cmake +++ b/cmake/yue.cmake @@ -51,12 +51,30 @@ if(BUILD_WITH_YUE) target_compile_definitions(yuescript PRIVATE YUE_NO_MACRO YUE_WRAPPER_EXPORTS + YUE_STATIC_CONFIG $<$:_SCL_SECURE_NO_WARNINGS> ) - # Disable thread-safe statics on embedded platforms + # Platform specific configurations if(BAREMETALPI OR NINTENDO_3DS) - target_compile_options(yuescript PRIVATE -fno-threadsafe-statics) + # Disable thread-safe statics for C++ files + set_source_files_properties( + ${YUESCRIPT_SRC} + ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.cpp + PROPERTIES COMPILE_FLAGS "-fno-threadsafe-statics" + ) + + # Force static linking for baremetal + set_target_properties(yuescript PROPERTIES + STATIC_LIBRARY TRUE + POSITION_INDEPENDENT_CODE FALSE + ) + + # Add baremetal specific compile flags + target_compile_options(yuescript PRIVATE + -fno-exceptions + -fno-rtti + ) endif() target_sources(yuescript PRIVATE diff --git a/src/api/yue_wrapper/yue_wrapper.h b/src/api/yue_wrapper/yue_wrapper.h index f0f31228c..8aaecc782 100644 --- a/src/api/yue_wrapper/yue_wrapper.h +++ b/src/api/yue_wrapper/yue_wrapper.h @@ -8,6 +8,9 @@ extern "C" { #endif +#ifdef YUE_STATIC_CONFIG +#define YUE_WRAPPER_API +#else #ifdef _WIN32 #ifdef YUE_WRAPPER_EXPORTS #define YUE_WRAPPER_API __declspec(dllexport) @@ -17,6 +20,7 @@ extern "C" { #else #define YUE_WRAPPER_API #endif +#endif typedef struct YueCompiler_t YueCompiler_t; typedef struct YueConfig_t YueConfig_t; From 05ab4f609054eab5bd7f5cc407ff03fea09731b0 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Wed, 22 Jan 2025 09:43:51 +0700 Subject: [PATCH 12/19] Reenable Exceptions --- cmake/yue.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/yue.cmake b/cmake/yue.cmake index ccd17744f..1cddf792f 100644 --- a/cmake/yue.cmake +++ b/cmake/yue.cmake @@ -72,7 +72,6 @@ if(BUILD_WITH_YUE) # Add baremetal specific compile flags target_compile_options(yuescript PRIVATE - -fno-exceptions -fno-rtti ) endif() From 7e8b501fecec1e08dc3b5b9316a0865b5c24cd20 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Wed, 22 Jan 2025 10:03:26 +0700 Subject: [PATCH 13/19] Override YueParser --- cmake/yue.cmake | 24 ++++++++++----------- src/api/yue_wrapper/yue_parser_override.cpp | 9 ++++++++ src/api/yue_wrapper/yue_wrapper.h | 4 ---- 3 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 src/api/yue_wrapper/yue_parser_override.cpp diff --git a/cmake/yue.cmake b/cmake/yue.cmake index 1cddf792f..15d11d667 100644 --- a/cmake/yue.cmake +++ b/cmake/yue.cmake @@ -51,17 +51,16 @@ if(BUILD_WITH_YUE) target_compile_definitions(yuescript PRIVATE YUE_NO_MACRO YUE_WRAPPER_EXPORTS - YUE_STATIC_CONFIG $<$:_SCL_SECURE_NO_WARNINGS> ) # Platform specific configurations if(BAREMETALPI OR NINTENDO_3DS) - # Disable thread-safe statics for C++ files + # Disable thread-safe statics on embedded platforms for C++ files set_source_files_properties( ${YUESCRIPT_SRC} ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.cpp - PROPERTIES COMPILE_FLAGS "-fno-threadsafe-statics" + PROPERTIES COMPILE_FLAGS "-fno-threadsafe-statics -fno-rtti" ) # Force static linking for baremetal @@ -69,18 +68,19 @@ if(BUILD_WITH_YUE) STATIC_LIBRARY TRUE POSITION_INDEPENDENT_CODE FALSE ) - - # Add baremetal specific compile flags - target_compile_options(yuescript PRIVATE - -fno-rtti + + target_sources(yuescript PRIVATE + ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.cpp + ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.h + ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_parser_override.cpp + ) + else() + target_sources(yuescript PRIVATE + ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.cpp + ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.h ) endif() - target_sources(yuescript PRIVATE - ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.cpp - ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.h - ) - target_link_libraries(yuescript PRIVATE runtime luaapi) if(MSVC) diff --git a/src/api/yue_wrapper/yue_parser_override.cpp b/src/api/yue_wrapper/yue_parser_override.cpp new file mode 100644 index 000000000..41f30cbd8 --- /dev/null +++ b/src/api/yue_wrapper/yue_parser_override.cpp @@ -0,0 +1,9 @@ +#include "yuescript/yue_parser.h" + +namespace yue { + // Override the shared() implementation to use our global instance + YueParser& YueParser::shared() { + extern void* yue_get_parser_instance(); + return *static_cast(yue_get_parser_instance()); + } +} diff --git a/src/api/yue_wrapper/yue_wrapper.h b/src/api/yue_wrapper/yue_wrapper.h index 8aaecc782..f0f31228c 100644 --- a/src/api/yue_wrapper/yue_wrapper.h +++ b/src/api/yue_wrapper/yue_wrapper.h @@ -8,9 +8,6 @@ extern "C" { #endif -#ifdef YUE_STATIC_CONFIG -#define YUE_WRAPPER_API -#else #ifdef _WIN32 #ifdef YUE_WRAPPER_EXPORTS #define YUE_WRAPPER_API __declspec(dllexport) @@ -20,7 +17,6 @@ extern "C" { #else #define YUE_WRAPPER_API #endif -#endif typedef struct YueCompiler_t YueCompiler_t; typedef struct YueConfig_t YueConfig_t; From 4edcd9c9fd00a8c47bdbafa93117daa1528929b2 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Thu, 23 Jan 2025 23:36:16 +0700 Subject: [PATCH 14/19] Try forcing newer glibc? --- cmake/yue.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmake/yue.cmake b/cmake/yue.cmake index 15d11d667..ec6685c24 100644 --- a/cmake/yue.cmake +++ b/cmake/yue.cmake @@ -69,6 +69,8 @@ if(BUILD_WITH_YUE) POSITION_INDEPENDENT_CODE FALSE ) + target_compile_features(yuescript PRIVATE cxx_std_20) + target_sources(yuescript PRIVATE ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.cpp ${CMAKE_SOURCE_DIR}/src/api/yue_wrapper/yue_wrapper.h From 8ca8581f0f0fae41942521e6a35955f9344467b8 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Fri, 24 Jan 2025 08:00:40 +0700 Subject: [PATCH 15/19] Debugging Build Step --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 341927a53..b066b2328 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -378,7 +378,7 @@ jobs: - name: Build run: | - cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/cmake/3DS.cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DBUILD_WITH_ALL=ON -DBUILD_WITH_SCHEME=OFF -DBUILD_WITH_JS=OFF -DBUILD_WITH_PYTHON=OFF .. + cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=$DEVKITPRO/cmake/3DS.cmake -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_WITH_ALL=ON -DBUILD_WITH_SCHEME=OFF -DBUILD_WITH_JS=OFF -DBUILD_WITH_PYTHON=OFF .. cmake --build build --parallel - name: Deploy From 06a5358f1a9826f0e1a632effc73d9916b1f2fb2 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Thu, 20 Feb 2025 14:09:16 +0700 Subject: [PATCH 16/19] Update YueScript version --- vendor/yuescript | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/yuescript b/vendor/yuescript index 42311be3c..d1878f2b8 160000 --- a/vendor/yuescript +++ b/vendor/yuescript @@ -1 +1 @@ -Subproject commit 42311be3c22631210abec0b6ff653e59501e666c +Subproject commit d1878f2b8eb1644205c5e0b641fd092e8b222766 From f1babe0fc873ec82ae33dca9097f7fa6a5bf7dda Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Thu, 20 Feb 2025 14:35:38 +0700 Subject: [PATCH 17/19] Simplify build --- cmake/yue.cmake | 23 ++++++++++++++++++++++- vendor/yuescript | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cmake/yue.cmake b/cmake/yue.cmake index 747e93a4b..463020ab4 100644 --- a/cmake/yue.cmake +++ b/cmake/yue.cmake @@ -43,7 +43,28 @@ if(BUILD_WITH_YUE) ${CMAKE_SOURCE_DIR}/src ) - target_compile_definitions(yuescript PRIVATE YUE_NO_MACRO) + target_compile_definitions(yuescript PRIVATE + YUE_NO_MACRO + $<$:_SCL_SECURE_NO_WARNINGS> + ) + + # Platform specific configurations + if(BAREMETALPI OR NINTENDO_3DS) + # Disable thread-safe statics on embedded platforms for C++ files + set_source_files_properties( + ${YUESCRIPT_SRC} + PROPERTIES COMPILE_FLAGS "-fno-threadsafe-statics -fno-rtti -fno-thread-local-storage" + ) + + # Force static linking for baremetal + set_target_properties(yuescript PROPERTIES + STATIC_LIBRARY TRUE + POSITION_INDEPENDENT_CODE FALSE + ) + + target_compile_features(yuescript PRIVATE cxx_std_17) + target_compile_options(yuescript PRIVATE -fno-thread-local-storage -fno-rtti) + endif() if(MSVC) target_compile_definitions(yuescript PRIVATE _SCL_SECURE_NO_WARNINGS) diff --git a/vendor/yuescript b/vendor/yuescript index 42311be3c..d1878f2b8 160000 --- a/vendor/yuescript +++ b/vendor/yuescript @@ -1 +1 @@ -Subproject commit 42311be3c22631210abec0b6ff653e59501e666c +Subproject commit d1878f2b8eb1644205c5e0b641fd092e8b222766 From f4064a90de8598388951b73369644dbc0fc86c8c Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Thu, 20 Feb 2025 14:39:50 +0700 Subject: [PATCH 18/19] Add yue.cpp --- src/api/yue.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/api/yue.cpp b/src/api/yue.cpp index 388af7aaf..ccae8e155 100644 --- a/src/api/yue.cpp +++ b/src/api/yue.cpp @@ -1,3 +1,25 @@ +// MIT License + +// Copyright (c) 2017 Vadim Grigoruk @nesbox // grigoruk@gmail.com + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + extern "C" { #include "core/core.h" From ab64890b130ee2ce71f0cf7fa13a763cbe548152 Mon Sep 17 00:00:00 2001 From: Dania Rifki Date: Thu, 20 Feb 2025 14:43:03 +0700 Subject: [PATCH 19/19] Whoops --- cmake/yue.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/yue.cmake b/cmake/yue.cmake index 8da633fa3..d45bf6b22 100644 --- a/cmake/yue.cmake +++ b/cmake/yue.cmake @@ -16,7 +16,7 @@ if(BUILD_WITH_YUE) ${YUESCRIPT_DIR}/src/yuescript/yuescript.cpp ) - list(APPEND YUESCRIPT_SRC ${CMAKE_SOURCE_DIR}/src/api/yue.c) + list(APPEND YUESCRIPT_SRC ${CMAKE_SOURCE_DIR}/src/api/yue.cpp) list(APPEND YUESCRIPT_SRC ${CMAKE_SOURCE_DIR}/src/api/parse_note.c) add_library(yuescript ${TIC_RUNTIME} ${YUESCRIPT_SRC})