fixed some const char*

This commit is contained in:
FelixBrendel
2019-01-28 17:23:45 +01:00
parent 3453a525ef
commit 77fffc7f5e
14 changed files with 66 additions and 38 deletions
+1 -1
View File
@@ -7,7 +7,7 @@
(define-minor-mode context-mode
"A temporary minor mode to be activated only specific to a buffer."
nil
:lighter " Context"
:lighter " [f2]-Context"
context-mode-map)
(context-mode 1)
-1
View File
@@ -22,5 +22,4 @@ if %errorlevel% == 0 (
)
popd
rem rd build /S /Q
popd
Binary file not shown.
+25
View File
@@ -0,0 +1,25 @@
@echo off
@setlocal
pushd %~dp0
set exeName=slime.exe
set binDir=bin
mkdir build 2>nul
pushd build
taskkill /F /IM %exeName% > NUL 2> NUL
echo ---------- Compiling ----------
call timecmd clang++ -std=c++17 ../src/main.cpp -o %exeName% -D_DEBUG libucrtd.lib
if %errorlevel% == 0 (
echo.
echo Done
) else (
echo.
echo Fuckin' ell
)
popd
popd
+3 -5
View File
@@ -270,7 +270,7 @@ proc built_in_exponentiate(Lisp_Object* arguments, Environment* env) -> Lisp_Obj
}
proc built_in_load(char* file_name, Environment* env) -> Lisp_Object* {
proc built_in_load(const char* file_name, Environment* env) -> Lisp_Object* {
char* file_content = read_entire_file(file_name);
if (file_content) {
Lisp_Object* result = Memory::create_lisp_object_nil();
@@ -300,7 +300,7 @@ proc load_built_ins_into_environment(Environment* env) -> void {
return nullptr; \
}
proc defun = [&](char* name, std::function<Lisp_Object*(Lisp_Object*, Environment*)> fun) {
proc defun = [&](const char* name, std::function<Lisp_Object*(Lisp_Object*, Environment*)> fun) {
define_symbol(
Memory::create_lisp_object_symbol(name),
Memory::create_lisp_object_cfunction(fun),
@@ -970,9 +970,7 @@ proc load_built_ins_into_environment(Environment* env) -> void {
});
defun("break", cLambda {
print_environment(env);
if_debug {
__debugbreak();
}
debug_break();
return Memory::create_lisp_object_nil();
});
defun("memstat", cLambda {
+7 -2
View File
@@ -9,15 +9,20 @@ constexpr bool is_debug_build = false;
#define if_debug if constexpr (is_debug_build)
// #ifdef _MSC_VER
# define debug_break() if_debug __debugbreak()
// #else
// # define debug_break() if_debug __builtin_trap()
// #endif
#define assert(cond) \
if_debug { \
if (!cond) { \
printf("Assertion failed: %s %d", __FILE__, __LINE__); \
__debugbreak(); \
debug_break(); \
} \
} else {} \
#define concat_( a, b) a##b
#define label(prefix, lnum) concat_(prefix,lnum)
#define try \
+2 -2
View File
@@ -10,14 +10,14 @@ proc delete_error() -> void {
proc create_error(Error_Type type, Source_Code_Location* location) -> void {
delete_error();
if_debug {
__debugbreak();
debug_break();
}
error = new(Error);
error->type = type;
error->location = location;
}
proc Error_Type_to_string(Error_Type type) -> char* {
proc Error_Type_to_string(Error_Type type) -> const char* {
switch (type) {
case Error_Type::Ill_Formed_Arguments: return "Evaluation-error: Ill formed arguments";
case Error_Type::Ill_Formed_Lambda_List: return "Evaluation-error: Ill formed lambda list";
+3 -3
View File
@@ -1,7 +1,7 @@
proc print_environment(Environment* env) -> void;
proc eval_arguments(Lisp_Object* arguments, Environment* env, int *out_arguments_length) -> Lisp_Object*;
proc print_environment(Environment*) -> void;
proc eval_arguments(Lisp_Object*, Environment*, int*) -> Lisp_Object*;
proc eval_expr(Lisp_Object*, Environment*) -> Lisp_Object*;
proc is_truthy (Lisp_Object* expression, Environment* env) -> bool;
proc is_truthy (Lisp_Object*, Environment*) -> bool;
proc list_length(Lisp_Object*) -> int;
proc load_built_ins_into_environment(Environment*) -> void;
proc parse_argument_list(Lisp_Object*, Function*) -> void;
+6 -5
View File
@@ -1,4 +1,4 @@
proc string_equal(char input[],char check[]) -> bool {
proc string_equal(const char input[], const char check[]) -> bool {
int i;
for(i = 0; input[i] != '\0' || check[i] != '\0'; i++) {
if(input[i] != check[i]) {
@@ -67,7 +67,7 @@ proc unescape_string(char* in) -> bool {
return true;
}
proc read_entire_file (char* filename) -> char* {
proc read_entire_file (const char* filename) -> char* {
char *fileContent = nullptr;
FILE *fp = fopen(filename, "r");
if (fp) {
@@ -132,7 +132,7 @@ proc read_expression() -> char* {
linep = linen;
}
*line++;
line++;
if((*line = (char)c) == '(')
++nesting;
else if((*line = (char)c) == ')')
@@ -144,6 +144,7 @@ proc read_expression() -> char* {
(*line)--; // we dont want the \n actually
*line = '\0';
// BUG(Felix): Why do we have to add 1 here?
return linep + 1;
}
@@ -174,7 +175,7 @@ proc read_line() -> char* {
linep = linen;
}
*line++;
line++;
if((*line = (char)c) == '(')
++nesting;
else if((*line = (char)c) == ')')
@@ -196,7 +197,7 @@ proc log_message(Log_Level type, char* message) -> void {
if (type > log_level)
return;
char* prefix;
const char* prefix;
switch (type) {
case Log_Level::Critical: prefix = "CRITICAL"; break;
case Log_Level::Warning: prefix = "WARNING"; break;
+2 -2
View File
@@ -1,4 +1,4 @@
proc create_source_code_location(char* file, int line, int col) -> Source_Code_Location* {
proc create_source_code_location(const char* file, int line, int col) -> Source_Code_Location* {
if (!file)
return nullptr;
@@ -9,7 +9,7 @@ proc create_source_code_location(char* file, int line, int col) -> Source_Code_L
return ret;
}
proc Lisp_Object_Type_to_string(Lisp_Object_Type type) -> char* {
proc Lisp_Object_Type_to_string(Lisp_Object_Type type) -> const char* {
switch (type) {
case(Lisp_Object_Type::Nil): return "nil";
case(Lisp_Object_Type::T): return "t";
+1 -1
View File
@@ -9,6 +9,6 @@ int main(int argc, char* argv[]) {
}
} else {
run_all_tests();
return interprete_stdin();
interprete_stdin();
}
}
+4 -4
View File
@@ -70,19 +70,19 @@ namespace Memory {
return node;
}
proc create_lisp_object_symbol(char* identifier) -> Lisp_Object* {
proc create_lisp_object_symbol(const char* identifier) -> Lisp_Object* {
Lisp_Object* node = create_lisp_object();
node->type = Lisp_Object_Type::Symbol;
node->value.symbol = new(Symbol);
node->value.symbol->identifier = identifier;
node->value.symbol->identifier = (char*) identifier;
return node;
}
proc create_lisp_object_keyword(char* keyword) -> Lisp_Object* {
proc create_lisp_object_keyword(const char* keyword) -> Lisp_Object* {
Lisp_Object* node = create_lisp_object();
node->type = Lisp_Object_Type::Keyword;
node->value.keyword = new(Keyword);
node->value.keyword->identifier = keyword;
node->value.keyword->identifier = (char*) keyword;
return node;
}
+10 -10
View File
@@ -1,12 +1,12 @@
namespace Parser {
#define inject_scl(_ret) \
ret->sourceCodeLocation = new(Source_Code_Location); \
ret->sourceCodeLocation->file = parser_file; \
ret->sourceCodeLocation->line = parser_line; \
ret->sourceCodeLocation->column = parser_col
#define inject_scl(_ret) \
_ret->sourceCodeLocation = new(Source_Code_Location); \
_ret->sourceCodeLocation->file = parser_file; \
_ret->sourceCodeLocation->line = parser_line; \
_ret->sourceCodeLocation->column = parser_col
char* parser_file;
const char* parser_file;
int parser_line;
int parser_col;
@@ -466,8 +466,8 @@ namespace Parser {
return nullptr;
}
void write_expanded_file(char* file_name, Lisp_Object_Array_List* program) {
char* ext = ".expanded";
void write_expanded_file(const char* file_name, Lisp_Object_Array_List* program) {
const char* ext = ".expanded";
char* newName = (char*)calloc(4 + strlen(file_name), sizeof(char));
strcpy(newName, file_name);
strcat(newName, ext);
@@ -489,9 +489,9 @@ namespace Parser {
fclose(f);
}
Lisp_Object_Array_List* parse_program(char* file_name, char* text) {
Lisp_Object_Array_List* parse_program(const char* file_name, char* text) {
parser_file = (char*)malloc(strlen(file_name) * sizeof(char) + 1);
strcpy(parser_file, file_name);
strcpy((char *)parser_file, file_name);
parser_line = 1;
parser_col = 0;
+2 -2
View File
@@ -50,7 +50,7 @@ enum struct Log_Level {
};
struct Source_Code_Location {
char* file;
const char* file;
int line;
int column;
};
@@ -68,8 +68,8 @@ struct Number {
};
struct String {
char* value;
int length;
char* value;
};
struct Pair {