Compare commits
4 Commits
release-v4
...
release-v4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1908d9bbbb | ||
|
|
47db2ca27d | ||
|
|
2e7b3b4baa | ||
|
|
24163e3389 |
@@ -33,8 +33,16 @@ add_custom_command(
|
|||||||
# Step 2: Custom target for lexer
|
# Step 2: Custom target for lexer
|
||||||
add_custom_target(GenerateLexer DEPENDS ${LEXER_C} ${LEXER_H})
|
add_custom_target(GenerateLexer DEPENDS ${LEXER_C} ${LEXER_H})
|
||||||
|
|
||||||
|
set(SOURCES
|
||||||
|
external/xxhash/xxhash.c external/cwalk/src/cwalk.c external/libdye/src/dye.c ${CFILES} ${LEXER_C}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT WIN32)
|
||||||
|
list(APPEND SOURCES external/linenoise/linenoise.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Step 3: Add executable
|
# Step 3: Add executable
|
||||||
add_executable(argon external/xxhash/xxhash.c external/cwalk/src/cwalk.c external/libdye/src/dye.c external/linenoise/linenoise.c ${CFILES} ${LEXER_C})
|
add_executable(argon ${SOURCES})
|
||||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||||
target_include_directories(argon PRIVATE ${CMAKE_SOURCE_DIR}/external/cwalk/include)
|
target_include_directories(argon PRIVATE ${CMAKE_SOURCE_DIR}/external/cwalk/include)
|
||||||
target_include_directories(argon PRIVATE ${CMAKE_SOURCE_DIR}/external/libdye/include)
|
target_include_directories(argon PRIVATE ${CMAKE_SOURCE_DIR}/external/libdye/include)
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
#include "number.h"
|
#include "number.h"
|
||||||
#include "../../memory.h"
|
#include "../../memory.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <gmp-x86_64.h>
|
|
||||||
#include <gmp.h>
|
|
||||||
#include <gmp.h>
|
#include <gmp.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|||||||
24
src/shell.c
24
src/shell.c
@@ -3,7 +3,6 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
*/
|
*/
|
||||||
#include "../external/linenoise/linenoise.h"
|
|
||||||
#include "./lexer/lexer.h"
|
#include "./lexer/lexer.h"
|
||||||
#include "./runtime/call/call.h"
|
#include "./runtime/call/call.h"
|
||||||
#include "./runtime/objects/functions/functions.h"
|
#include "./runtime/objects/functions/functions.h"
|
||||||
@@ -19,6 +18,20 @@
|
|||||||
#if defined(__linux__)
|
#if defined(__linux__)
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
FILE *fmemopen(void *buf, size_t size, const char *mode) {
|
||||||
|
FILE *fp = tmpfile();
|
||||||
|
if (!fp) return NULL;
|
||||||
|
|
||||||
|
if (strchr(mode, 'w') || strchr(mode, '+')) {
|
||||||
|
fwrite(buf, 1, size, fp);
|
||||||
|
rewind(fp);
|
||||||
|
}
|
||||||
|
return fp;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#include "../external/linenoise/linenoise.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
volatile sig_atomic_t interrupted = 0;
|
volatile sig_atomic_t interrupted = 0;
|
||||||
|
|
||||||
@@ -96,6 +109,7 @@ int execute_code(FILE *stream, char *path, Stack *scope,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
// Simple input function
|
// Simple input function
|
||||||
char *input(const char *prompt) {
|
char *input(const char *prompt) {
|
||||||
printf("%s", prompt);
|
printf("%s", prompt);
|
||||||
@@ -117,6 +131,7 @@ char *input(const char *prompt) {
|
|||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
char *read_all_stdin(size_t *out_len) {
|
char *read_all_stdin(size_t *out_len) {
|
||||||
size_t size = 1024;
|
size_t size = 1024;
|
||||||
@@ -194,7 +209,11 @@ int shell() {
|
|||||||
memcpy(prompt, textBefore, strlen(textBefore));
|
memcpy(prompt, textBefore, strlen(textBefore));
|
||||||
memcpy(prompt + strlen(textBefore), indentStr, isz + 1);
|
memcpy(prompt + strlen(textBefore), indentStr, isz + 1);
|
||||||
|
|
||||||
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
char *inp = input(prompt);
|
||||||
|
#else
|
||||||
char *inp = linenoise(prompt);
|
char *inp = linenoise(prompt);
|
||||||
|
#endif
|
||||||
free(prompt);
|
free(prompt);
|
||||||
|
|
||||||
if (!inp) {
|
if (!inp) {
|
||||||
@@ -205,10 +224,13 @@ int shell() {
|
|||||||
free(indentStr);
|
free(indentStr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
|
#else
|
||||||
if (inp[0] != '\0') {
|
if (inp[0] != '\0') {
|
||||||
// Optionally add line to history
|
// Optionally add line to history
|
||||||
linenoiseHistoryAdd(inp);
|
linenoiseHistoryAdd(inp);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Append line to totranslate
|
// Append line to totranslate
|
||||||
size_t length = strlen(inp);
|
size_t length = strlen(inp);
|
||||||
|
|||||||
Reference in New Issue
Block a user