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]>
41 lines
1.1 KiB
C
41 lines
1.1 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#ifndef SCRIPT_BUILTIN_SCRIPTBUILTINREGISTER_H
|
|
#define SCRIPT_BUILTIN_SCRIPTBUILTINREGISTER_H
|
|
|
|
#include "core/scriptcore.h"
|
|
#include "value/scriptfunction.h"
|
|
|
|
/**
|
|
* Adds one built in function to the builtin scope.
|
|
*
|
|
* @param runtime The runtime.
|
|
* @param name The function name.
|
|
* @param native The C function.
|
|
*/
|
|
void scriptBuiltinAdd(scriptruntime_t *runtime, const char *name, scriptnative_t native);
|
|
|
|
/**
|
|
* Adds a whole number to the builtin scope, which a script can read but not declare again.
|
|
* For what the game has that scripts name: the scenes, say.
|
|
*
|
|
* @param runtime The runtime.
|
|
* @param name The constant's name.
|
|
* @param value The number.
|
|
*/
|
|
void scriptBuiltinAddInt(scriptruntime_t *runtime, const char *name, const int16_t value);
|
|
|
|
/**
|
|
* Puts all the built in functions and constants in the builtin scope.
|
|
*
|
|
* @param runtime The runtime.
|
|
*/
|
|
void scriptBuiltinsRegister(scriptruntime_t *runtime);
|
|
|
|
#endif
|