Skip to content

Commit 2a1995c

Browse files
committed
Remove the preemptive module
1 parent 05db7eb commit 2a1995c

19 files changed

+19
-1513
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ chaos: lex.yy.c parser.tab.c parser.tab.h
101101
ifeq ($(UNAME_S), Darwin)
102102
export CHAOS_STACK_SIZE=-Wl,-stack_size,0x100000000
103103
endif
104-
${CHAOS_COMPILER} -Werror -Wall -pedantic -fcommon ${CHAOS_STACK_SIZE} -DCHAOS_INTERPRETER -o chaos parser.tab.c lex.yy.c parser/*.c utilities/*.c ast/*.c preemptive/*.c interpreter/*.c compiler/*.c vm/*.c Chaos.c -lreadline -L/usr/local/opt/readline/lib -I/usr/local/opt/readline/include -ldl ${CHAOS_EXTRA_FLAGS}
104+
${CHAOS_COMPILER} -Werror -Wall -pedantic -fcommon ${CHAOS_STACK_SIZE} -DCHAOS_INTERPRETER -o chaos parser.tab.c lex.yy.c parser/*.c utilities/*.c ast/*.c interpreter/*.c compiler/*.c vm/*.c Chaos.c -lreadline -L/usr/local/opt/readline/lib -I/usr/local/opt/readline/include -ldl ${CHAOS_EXTRA_FLAGS}
105105

106106
clean:
107107
rm -rf chaos parser.tab.c lex.yy.c parser.tab.h

coverage.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@ llvm-cov show /usr/local/bin/chaos -instr-profile=chaos.profdata \
2424
./interpreter/*.c \
2525
./lexer/*.c \
2626
./parser/*.c \
27-
./preemptive/*.c \
2827
./utilities/*.c \
2928
-path-equivalence -use-color --format html > /tmp/coverage.html

help.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ Usage: chaos [options] <file> [--] [args...]
88
-o, --output Binary output filename. Must be used with the -c / --compile option.
99
-e, --extra Extra flags to inject into C compiler command.
1010
-k, --keep Don't remove the C source and header files (temporary files) after compilation.
11-
-u, --unsafe Unsafe mode (fast warm up). Disables the preemptive error checks.
1211
-a, --ast Print Abstract Syntax Tree (AST) in JSON format and exit immediately.
1312

interpreter/interpreter.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern unsigned long long nested_loop_counter;
3131
int kaos_lineno = 0;
3232

3333
#ifndef CHAOS_COMPILER
34-
void interpret(char *module, enum Phase phase_arg, bool is_interactive, bool unsafe) {
34+
void interpret(char *module, enum Phase phase_arg, bool is_interactive) {
3535
#else
3636
void interpret(char *module, enum Phase phase_arg) {
3737
#endif
@@ -51,16 +51,6 @@ void interpret(char *module, enum Phase phase_arg) {
5151
case PREPARSE:
5252
phase = PREPARSE;
5353
register_functions(ast_node, module);
54-
#ifndef CHAOS_COMPILER
55-
if (!unsafe) {
56-
if (is_interactive) {
57-
if (end_function != NULL)
58-
preemptive_check();
59-
} else {
60-
preemptive_check();
61-
}
62-
}
63-
#endif
6454
phase = PROGRAM;
6555
break;
6656
case PROGRAM:
@@ -74,16 +64,6 @@ void interpret(char *module, enum Phase phase_arg) {
7464
if (phase_arg == INIT_PREPARSE) {
7565
phase = PREPARSE;
7666
register_functions(ast_node, module);
77-
#ifndef CHAOS_COMPILER
78-
if (!unsafe) {
79-
if (is_interactive) {
80-
if (end_function != NULL)
81-
preemptive_check();
82-
} else {
83-
preemptive_check();
84-
}
85-
}
86-
#endif
8767
phase = PROGRAM;
8868
eval_node(ast_node, module);
8969
}

interpreter/interpreter.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,11 @@
2929

3030
#include "../ast/ast.h"
3131

32-
#ifndef CHAOS_COMPILER
33-
#include "../preemptive/preemptive.h"
34-
#endif
35-
3632
extern unsigned long long nested_loop_counter;
3733
extern ASTNode* loop_end_ast_node;
3834

3935
#ifndef CHAOS_COMPILER
40-
void interpret(char *module, enum Phase phase_arg, bool is_interactive, bool unsafe);
36+
void interpret(char *module, enum Phase phase_arg, bool is_interactive);
4137
#else
4238
void interpret(char *module, enum Phase phase_arg);
4339
#endif

lexer/lexer.l

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ extern void recordToken(char *token, int length);
3737
extern int oerrno;
3838
extern void yyerror(const char* s);
3939
extern FILE* tmp_stdin;
40-
extern bool global_unsafe;
4140
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
4241

4342
#include "parser.tab.h"
@@ -63,7 +62,7 @@ void injectCode(char *code, enum Phase phase_arg) {
6362
char *interpreted_module = malloc(1 + strlen(module_path_stack.arr[module_path_stack.size - 1]));
6463
strcpy(interpreted_module, module_path_stack.arr[module_path_stack.size - 1]);
6564
// #ifndef CHAOS_COMPILER
66-
// interpret(interpreted_module, phase_arg, false, global_unsafe);
65+
// interpret(interpreted_module, phase_arg, false);
6766
// #else
6867
// interpret(interpreted_module, phase_arg);
6968
// #endif

make.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ win_bison -d parser\parser.y
169169
IF errorlevel 1 (
170170
EXIT /B 1
171171
)
172-
%compiler% -fcommon -DCHAOS_INTERPRETER -o chaos.exe parser.tab.c lex.yy.c parser/*.c utilities/*.c utilities/windows/*.c ast/*.c preemptive/*.c interpreter/*.c compiler/*.c Chaos.c -lshell32 -lole32 %extra_flags%
172+
%compiler% -fcommon -DCHAOS_INTERPRETER -o chaos.exe parser.tab.c lex.yy.c parser/*.c utilities/*.c utilities/windows/*.c ast/*.c interpreter/*.c compiler/*.c Chaos.c -lshell32 -lole32 %extra_flags%
173173
IF errorlevel 1 (
174174
EXIT /B 1
175175
)

parser/parser.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ extern bool disable_complex_mode;
2626
extern char *suggestions[1000];
2727
extern unsigned long long suggestions_length;
2828

29-
bool global_unsafe = false;
30-
3129
#ifndef CHAOS_COMPILER
3230
static struct option long_options[] =
3331
{
@@ -39,7 +37,6 @@ static struct option long_options[] =
3937
{"output", required_argument, NULL, 'o'},
4038
{"extra", required_argument, NULL, 'e'},
4139
{"keep", no_argument, NULL, 'k'},
42-
{"unsafe", no_argument, NULL, 'u'},
4340
{"ast", no_argument, NULL, 'a'},
4441
{NULL, 0, NULL, 0}
4542
};
@@ -52,11 +49,10 @@ int initParser(int argc, char** argv) {
5249
char *program_file = NULL;
5350
char *bin_file = NULL;
5451
// bool keep = false;
55-
// bool unsafe = false;
5652
// char *extra_flags = NULL;
5753

5854
char opt;
59-
while ((opt = getopt_long(argc, argv, "hvldc:o:e:k:u:a:", long_options, NULL)) != -1)
55+
while ((opt = getopt_long(argc, argv, "hvldc:o:e:k:a:", long_options, NULL)) != -1)
6056
{
6157
switch (opt) {
6258
case 'h':
@@ -88,10 +84,6 @@ int initParser(int argc, char** argv) {
8884
case 'k':
8985
// keep = true;
9086
break;
91-
case 'u':
92-
// unsafe = true;
93-
global_unsafe = true;
94-
break;
9587
case 'a':
9688
print_ast = true;
9789
break;
@@ -222,9 +214,9 @@ int initParser(int argc, char** argv) {
222214
free_cpu(c);
223215
// if (!is_interactive) {
224216
// if (compiler_mode) {
225-
// compile(main_interpreted_module, INIT_PREPARSE, bin_file, extra_flags, keep, unsafe);
217+
// compile(main_interpreted_module, INIT_PREPARSE, bin_file, extra_flags, keep);
226218
// } else {
227-
// interpret(main_interpreted_module, INIT_PREPARSE, false, unsafe);
219+
// interpret(main_interpreted_module, INIT_PREPARSE, false);
228220
// }
229221
// }
230222
if (!is_interactive) break;
@@ -320,7 +312,6 @@ void absorbError() {
320312

321313
phase = INIT_PROGRAM;
322314
disable_complex_mode = false;
323-
preemptive_freeAllSymbols();
324315
freeComplexModeStack();
325316
freeLeftRightBracketStackSymbols();
326317
resetFunctionParametersMode();

parser/parser.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ char *program_code;
6060
char *main_interpreted_module;
6161
jmp_buf InteractiveShellErrorAbsorber;
6262

63-
bool global_unsafe;
64-
6563
int initParser(int argc, char** argv);
6664
void freeEverything();
6765
void yyerror(const char* s);

0 commit comments

Comments
 (0)