small optimizaitons
This commit is contained in:
+2
-1
@@ -111,7 +111,7 @@ proc built_in_import(String* file_name) -> Lisp_Object* {
|
||||
return Memory::nil;
|
||||
}
|
||||
|
||||
proc load_built_ins_into_environment() -> void {
|
||||
proc load_built_ins_into_environment() -> void* {
|
||||
String* file_name_built_ins = Memory::create_string(__FILE__);
|
||||
|
||||
define((helper), "") {
|
||||
@@ -1065,4 +1065,5 @@ proc load_built_ins_into_environment() -> void {
|
||||
|
||||
return Memory::create_lisp_object_string(resulting_string);
|
||||
};
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -114,13 +114,13 @@
|
||||
Parser::parser_col = 0; \
|
||||
auto label(params,__LINE__) = Parser::parse_single_expression( \
|
||||
Memory::get_c_str(Memory::create_string(#def))); \
|
||||
if_error_log_location_and_return(); \
|
||||
if_error_log_location_and_return(nullptr); \
|
||||
assert_type(label(params,__LINE__), Lisp_Object_Type::Pair); \
|
||||
assert_type(label(params,__LINE__)->value.pair.first, Lisp_Object_Type::Symbol); \
|
||||
auto label(sym,__LINE__) = label(params,__LINE__)->value.pair.first; \
|
||||
auto label(sfun,__LINE__) = Memory::create_lisp_object_cfunction(special); \
|
||||
create_arguments_from_lambda_list_and_inject(label(params,__LINE__)->value.pair.rest, label(sfun,__LINE__)); \
|
||||
if_error_log_location_and_return(); \
|
||||
if_error_log_location_and_return(nullptr); \
|
||||
label(sfun,__LINE__)->docstring = Memory::create_string(docs); \
|
||||
define_symbol(label(sym,__LINE__), label(sfun,__LINE__)); \
|
||||
label(sfun,__LINE__)->value.cFunction->body = []() -> Lisp_Object*
|
||||
|
||||
+5
-5
@@ -92,11 +92,11 @@ proc print_environment_indent(Environment* env, int indent) -> void {
|
||||
}
|
||||
};
|
||||
|
||||
if(env == get_root_environment()) {
|
||||
print_indent(indent);
|
||||
printf("[built-ins]-Environment (%lld)\n", (long long)env);
|
||||
return;
|
||||
}
|
||||
// if(env == get_root_environment()) {
|
||||
// print_indent(indent);
|
||||
// printf("[built-ins]-Environment (%lld)\n", (long long)env);
|
||||
// return;
|
||||
// }
|
||||
|
||||
for_hash_map (env->hm) {
|
||||
print_indent(indent);
|
||||
|
||||
@@ -10,7 +10,7 @@ Lisp_Object* eval_arguments(Lisp_Object*);
|
||||
Lisp_Object* eval_expr(Lisp_Object*);
|
||||
bool is_truthy (Lisp_Object*);
|
||||
int list_length(Lisp_Object*);
|
||||
void load_built_ins_into_environment();
|
||||
void* load_built_ins_into_environment();
|
||||
void create_arguments_from_lambda_list_and_inject(Lisp_Object* formal_arguments, Lisp_Object* function);
|
||||
|
||||
Lisp_Object* lookup_symbol(Lisp_Object* symbol, Environment*);
|
||||
|
||||
+1
-4
@@ -116,7 +116,7 @@ proc unescape_string(char* in) -> int {
|
||||
|
||||
/* Set the end of string. */
|
||||
*out = '\0';
|
||||
return out - in;
|
||||
return (int)(out - in);
|
||||
}
|
||||
|
||||
proc read_entire_file(char* filename) -> char* {
|
||||
@@ -456,7 +456,4 @@ proc log_error() -> void {
|
||||
fputs(" in: ", stdout);
|
||||
print_call_stack();
|
||||
puts(console_normal);
|
||||
|
||||
// HACK(Felix): we should control the stack size in eval_expr not here
|
||||
// Globals::Current_Execution::call_stack.next_index = 0;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -12,10 +11,8 @@
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <new>
|
||||
// #include <functional>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <crtdbg.h>
|
||||
# include <direct.h>
|
||||
# include <windows.h>
|
||||
#else
|
||||
|
||||
@@ -6,9 +6,6 @@ int main(int argc, char* argv[]) {
|
||||
int res = Slime::run_all_tests();
|
||||
Slime::built_in_load(Slime::Memory::create_string("generate-docs.slime"));
|
||||
Slime::Memory::free_everything();
|
||||
#ifdef _MSC_VER
|
||||
_CrtDumpMemoryLeaks();
|
||||
#endif
|
||||
return res ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -28,12 +28,12 @@ int vasprintf(char **strp, const char *fmt, va_list ap) {
|
||||
return -1;
|
||||
}
|
||||
size_t size = (size_t)len + 1;
|
||||
char *str = malloc(size);
|
||||
char *str = (char*)malloc(size);
|
||||
if (!str) {
|
||||
return -1;
|
||||
}
|
||||
// _vsprintf_s is the "secure" version of vsprintf
|
||||
int r = _vsprintf_s(str, len + 1, fmt, ap);
|
||||
int r = vsprintf_s(str, len + 1, fmt, ap);
|
||||
if (r == -1) {
|
||||
free(str);
|
||||
return -1;
|
||||
|
||||
+3
-3
@@ -609,9 +609,9 @@ proc run_all_tests() -> bool {
|
||||
try Memory::init(409600);
|
||||
|
||||
printf("-- Util --\n");
|
||||
// invoke_test(test_array_lists_adding_and_removing);
|
||||
// invoke_test(test_array_lists_sorting);
|
||||
// invoke_test(test_array_lists_searching);
|
||||
invoke_test(test_array_lists_adding_and_removing);
|
||||
invoke_test(test_array_lists_sorting);
|
||||
invoke_test(test_array_lists_searching);
|
||||
|
||||
printf("\n -- Parsing --\n");
|
||||
invoke_test(test_parse_atom);
|
||||
|
||||
Reference in New Issue
Block a user