diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ee2879243..7470b28c8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -499,6 +499,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 cff7a51c7..d446e1c30 100644 --- a/.gitmodules +++ b/.gitmodules @@ -82,6 +82,10 @@ path = vendor/pocketpy url = https://github.com/pocketpy/pocketpy.git shallow = true +[submodule "vendor/yuescript"] + path = vendor/yuescript + url = https://github.com/IppClub/YueScript.git + shallow = true [submodule "vendor/lpeg"] path = vendor/lpeg url = https://github.com/roberto-ieru/LPeg.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 47f7262cc..b4f14c1ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,6 +157,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..df05b60fc --- /dev/null +++ b/build/assets/yuedemo.tic.dat @@ -0,0 +1 @@ +0x78, 0xda, 0xed, 0x52, 0xcd, 0x4a, 0xc3, 0x40, 0x10, 0xde, 0xfa, 0x73, 0xc8, 0x1e, 0x04, 0xdf, 0x60, 0x14, 0x04, 0x7f, 0x52, 0x4d, 0xda, 0x22, 0x5a, 0x88, 0x17, 0x15, 0x2c, 0x54, 0x0a, 0x52, 0xf0, 0x9c, 0xc6, 0xb5, 0x5d, 0x8c, 0x49, 0x49, 0xb6, 0xb5, 0x79, 0x83, 0x1c, 0x7c, 0x08, 0x8f, 0x12, 0xf2, 0x10, 0x7b, 0x96, 0xa5, 0x4f, 0x52, 0xf2, 0x0c,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x3e, 0x83, 0xcf, 0x83, 0x07, 0x5d, 0xf0, 0xb9, 0xc7, 0x82, 0x18, 0x6b, 0xd7, 0xad, 0x2e, 0xb4, 0x3f, 0x00, 0xec, 0x7a, 0x03, 0x37, 0xe8, 0xe3, 0x23, 0x06, 0x3c, 0x06, 0x11, 0x42, 0x12, 0x8e, 0xa2, 0xcf, 0x4e, 0x08, 0xef, 0xc1, 0x1b, 0x84, 0x08, 0xf6, 0xb4, 0x7e, 0xcc, 0xa2, 0x18, 0x67, 0x34, 0xc1, 0x3a, 0xb4, 0xcb, 0x41, 0xe5, 0x54, 0x1c, 0x95, 0x8c, 0x18, 0xa5, 0xc2, 0xb1, 0xe8, 0xc4, 0x39, 0x3d, 0xa6, 0x89, 0x53, 0x6b, 0x50, 0xda, 0xf7, 0xc3, 0x9e, 0xeb, 0x43, 0xb7, 0x75, 0xee, 0x54, 0xcf, 0xa8, 0xc1, 0xef, 0xa1, 0x27, 0x02, 0xb0, 0xa8, 0x61, 0x24, 0x55, 0xc7, 0x5e, 0x10, 0xb6, 0x26, 0x0e, 0x96, 0x88, 0x1a, 0x12, 0x93, 0xe5, 0x8e, 0xba, 0x26, 0x74, 0x07, 0x35, 0x3c, 0x3f, 0x06, 0x1b, 0x71, 0x3c, 0x8c, 0xc0, 0x3e, 0xd8, 0x15, 0x3b, 0xc7, 0xd6, 0xde, 0xd1, 0x51, 0xdd, 0xda, 0xaf, 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 new file mode 100644 index 000000000..6f7ac1c2f --- /dev/null +++ b/build/assets/yuemark.tic.dat @@ -0,0 +1 @@ +0x78, 0xda, 0xed, 0x55, 0xcd, 0x6f, 0xdc, 0x44, 0x14, 0x77, 0x0e, 0x54, 0xb2, 0xc5, 0x4a, 0xeb, 0x2b, 0xe2, 0xf0, 0x52, 0x84, 0xba, 0x9b, 0xee, 0x6e, 0xed, 0x4d, 0xb2, 0x20, 0x37, 0x1b, 0x2d, 0x05, 0x21, 0x22, 0x15, 0x09, 0x91, 0xd0, 0x10, 0xa9, 0x39, 0xcc, 0x7a, 0x67, 0xd7, 0x16, 0xfe, 0x58, 0xc6, 0xe3, 0xa4, 0x56, 0xd5, 0x6b, 0x4f, 0x1c, 0xf9, 0x03, 0x38, 0xc1, 0x15, 0x4e, 0xdc, 0xb9, 0x21, 0x6d, 0xa4, 0xfc, 0x01, 0x71, 0x54, 0xfe, 0x00, 0xb6, 0x1c, 0x22, 0x38, 0xc2, 0x1b, 0x8f, 0xed, 0xfd, 0x68, 0xd3, 0xf4, 0x06, 0x48, 0x19, 0xed, 0x73, 0xec, 0xf7, 0x7e, 0xbf, 0xf7, 0x66, 0xde, 0xc7, 0xe4, 0x4d, 0x43, 0x51, 0xde, 0x7a, 0xbb, 0x71, 0x78, 0xeb, 0xf0, 0xa7, 0xed, 0xdd, 0xe7, 0x4f, 0xf6, 0xff, 0x3e, 0x89, 0x7f, 0xf8, 0x63, 0xfc, 0xfe, 0xcf, 0x83, 0x77, 0xbf, 0x4e, 0xea, 0x9d, 0xf0, 0xee, 0xe1, 0xaf, 0x1f, 0x7c, 0xff, 0x67, 0xf4, 0xfc, 0xaf, 0x8b, 0x8b, 0x8b, 0x6f, 0x7f, 0xfc, 0xe5, 0x81, 0xf7, 0x74, 0x7d, 0x6b, 0x7f, 0xe5, 0xbb, 0x1b, 0xca, 0x55, 0x4b, 0xd7, 0x75, 0x94, 0x95, 0x14, 0xe5, 0x64, 0x49, 0x84, 0x2e, 0x55, 0xaa, 0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x4c, 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/build/baremetalpi/Makefile b/build/baremetalpi/Makefile index b99a4202e..1cae06e99 100644 --- a/build/baremetalpi/Makefile +++ b/build/baremetalpi/Makefile @@ -30,6 +30,7 @@ LIBS := \ $(TIC80LIB)/libluaapi.a \ $(TIC80LIB)/liblua.a \ $(TIC80LIB)/libmoon.a \ + $(TIC80LIB)/libyuescript.a \ $(TIC80LIB)/libfennel.a \ $(TIC80LIB)/libzip.a \ $(TIC80LIB)/libblipbuf.a \ diff --git a/build/baremetalpi/toolchain.cmake b/build/baremetalpi/toolchain.cmake index 7e5c69e91..a44dd0d9c 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/core.cmake b/cmake/core.cmake index f51117145..894b535d8 100644 --- a/cmake/core.cmake +++ b/cmake/core.cmake @@ -51,6 +51,7 @@ target_include_directories(tic80core PRIVATE ${THIRDPARTY_DIR}/moonscript ${THIRDPARTY_DIR}/fennel + ${THIRDPARTY_DIR}/yuescript ${POCKETPY_DIR}/src PUBLIC ${CMAKE_SOURCE_DIR}/include @@ -72,6 +73,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 9165ff994..9799662c2 100644 --- a/cmake/lua.cmake +++ b/cmake/lua.cmake @@ -29,7 +29,7 @@ if(BUILD_WITH_LUA AND PREFER_SYSTEM_LIBRARIES) endif() endif() -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..2a72a18fa --- /dev/null +++ b/cmake/yue.cmake @@ -0,0 +1,70 @@ +################################ +# 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 + ${CMAKE_SOURCE_DIR}/src/api + ) + + target_compile_definitions(yuescript PRIVATE + YUE_NO_MACRO + $<$:_SCL_SECURE_NO_WARNINGS> + ) + + if(NINTENDO_3DS) + target_compile_options(yuescript PRIVATE -ftls-model=initial-exec) + endif() + + 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_options(yuescript PRIVATE -Wno-deprecated-declarations) + endif() + +endif() diff --git a/demos/bunny/yuemark.yue b/demos/bunny/yuemark.yue new file mode 100644 index 000000000..b7c1d6ea9 --- /dev/null +++ b/demos/bunny/yuemark.yue @@ -0,0 +1,114 @@ +-- title: Bunnymark in YueScript +-- author: Rob Loach +-- 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!) + +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 +-- 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..fe18bca1b --- /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 + +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 +-- 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..ccae8e155 --- /dev/null +++ b/src/api/yue.cpp @@ -0,0 +1,232 @@ +// 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" +#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/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..aca747dff --- /dev/null +++ b/vendor/yuescript @@ -0,0 +1 @@ +Subproject commit aca747dffa1c185c6fc66af4834284e32225751f