file names passed to krk_interpret, krk_compile, krk_runfile can be const

This commit is contained in:
K. Lange 2024-01-08 10:53:38 +09:00
parent 0a9a3c7129
commit c530cf20fd
4 changed files with 6 additions and 6 deletions

View File

@ -4090,7 +4090,7 @@ void _createAndBind_compilerClass(void) {
* @return A compiled code object, or NULL on error.
* @exception SyntaxError if @p src could not be compiled.
*/
KrkCodeObject * krk_compile(const char * src, char * fileName) {
KrkCodeObject * krk_compile(const char * src, const char * fileName) {
struct GlobalState * state = (void*)krk_newInstance(KRK_BASE_CLASS(CompilerState));
krk_push(OBJECT_VAL(state));

View File

@ -14,5 +14,5 @@
* @param fileName Path name of the source file or a representative string like "<stdin>"
* @return The code object resulting from the compilation, or NULL if compilation failed.
*/
extern KrkCodeObject * krk_compile(const char * src, char * fileName);
extern KrkCodeObject * krk_compile(const char * src, const char * fileName);

View File

@ -316,7 +316,7 @@ extern void krk_resetStack(void);
* indicate @c KRK_THREAD_HAS_EXCEPTION and @c krk_currentThread.currentException
* should contain the raised exception value.
*/
extern KrkValue krk_interpret(const char * src, char * fromFile);
extern KrkValue krk_interpret(const char * src, const char * fromFile);
/**
* @brief Load and run a source file and return when execution completes.
@ -330,7 +330,7 @@ extern KrkValue krk_interpret(const char * src, char * fromFile);
* @return As with @c krk_interpret, an object representing the newly created module,
* or the final return value of the VM execution.
*/
extern KrkValue krk_runfile(const char * fileName, char * fromFile);
extern KrkValue krk_runfile(const char * fileName, const char * fromFile);
/**
* @brief Push a stack value.

View File

@ -3229,7 +3229,7 @@ KrkInstance * krk_startModule(const char * name) {
return module;
}
KrkValue krk_interpret(const char * src, char * fromFile) {
KrkValue krk_interpret(const char * src, const char * fromFile) {
KrkCodeObject * function = krk_compile(src, fromFile);
if (!function) {
if (!krk_currentThread.frameCount) handleException();
@ -3246,7 +3246,7 @@ KrkValue krk_interpret(const char * src, char * fromFile) {
}
#ifndef KRK_NO_FILESYSTEM
KrkValue krk_runfile(const char * fileName, char * fromFile) {
KrkValue krk_runfile(const char * fileName, const char * fromFile) {
FILE * f = fopen(fileName,"r");
if (!f) {
fprintf(stderr, "%s: could not open file '%s': %s\n", "kuroko", fileName, strerror(errno));