Brings over the duskscript VM and compiler from dusk-vm: the runtime (core/vm) lives under src/dusk/script, gated by DUSK_SCRIPT and wired into the engine lifecycle with print()/consolePrint() routed to the console; the standalone duskscriptcc compiler stays a lean host tool (linux/knulli only). Collapses int/fixed/bignum into a single float-backed SCRIPT_VALUE_NUMBER throughout the lexer, compiler, bytecode format and VM, removing the old int16-rollover fast paths and the type-conversion builtins they needed. Fixes a real big-endian bug in the bytecode's 32-bit number reader (found while adding GameCube/Wii endian support via util/endian.h) and converts src/dusk/script and duskscriptcc to dusk's memory/string/assert utilities, which surfaced two more latent bugs: a conservative GC stack scan reading its own local variable's address, and an uninitialized path buffer in scriptReadScript when the caller path has no directory component. Co-Authored-By: Claude Sonnet 5 <[email protected]>
36 lines
1.4 KiB
CMake
36 lines
1.4 KiB
CMake
# Copyright (c) 2026 Dominic Masters
|
|
#
|
|
# This software is released under the MIT License.
|
|
# https://opensource.org/licenses/MIT
|
|
|
|
include(dusktest)
|
|
|
|
dusktest(test_duskscript.c)
|
|
|
|
# Compile the fixture scripts to bytecode with duskscriptcc at build time, so
|
|
# the test exercises the real compiler -> runtime -> consolePrint pipeline.
|
|
set(DUSKSCRIPT_TEST_FIXTURE_DS ${CMAKE_CURRENT_LIST_DIR}/fixture.ds)
|
|
set(DUSKSCRIPT_TEST_FIXTURE_DSB ${CMAKE_CURRENT_BINARY_DIR}/fixture.dsb)
|
|
set(DUSKSCRIPT_TEST_NUMBERS_DS ${CMAKE_CURRENT_LIST_DIR}/fixture_numbers.ds)
|
|
set(DUSKSCRIPT_TEST_NUMBERS_DSB ${CMAKE_CURRENT_BINARY_DIR}/fixture_numbers.dsb)
|
|
|
|
add_custom_command(
|
|
OUTPUT ${DUSKSCRIPT_TEST_FIXTURE_DSB}
|
|
COMMAND duskscriptcc ${DUSKSCRIPT_TEST_FIXTURE_DS} -o ${DUSKSCRIPT_TEST_FIXTURE_DSB}
|
|
DEPENDS duskscriptcc ${DUSKSCRIPT_TEST_FIXTURE_DS}
|
|
COMMENT "Compiling duskscript test fixture"
|
|
)
|
|
add_custom_command(
|
|
OUTPUT ${DUSKSCRIPT_TEST_NUMBERS_DSB}
|
|
COMMAND duskscriptcc ${DUSKSCRIPT_TEST_NUMBERS_DS} -o ${DUSKSCRIPT_TEST_NUMBERS_DSB}
|
|
DEPENDS duskscriptcc ${DUSKSCRIPT_TEST_NUMBERS_DS}
|
|
COMMENT "Compiling duskscript numbers test fixture"
|
|
)
|
|
add_custom_target(duskscript_test_fixture DEPENDS ${DUSKSCRIPT_TEST_FIXTURE_DSB} ${DUSKSCRIPT_TEST_NUMBERS_DSB})
|
|
add_dependencies(test_duskscript duskscript_test_fixture)
|
|
|
|
target_compile_definitions(test_duskscript PRIVATE
|
|
DUSKSCRIPT_TEST_FIXTURE="${DUSKSCRIPT_TEST_FIXTURE_DSB}"
|
|
DUSKSCRIPT_TEST_NUMBERS="${DUSKSCRIPT_TEST_NUMBERS_DSB}"
|
|
)
|