fixed import bug

This commit is contained in:
fumfar hiwi
2019-12-04 14:51:06 +01:00
parent 667989e373
commit efbdfeed2e
19 changed files with 3698 additions and 3680 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
(define a 10)
(define a 1111)
(define (get-a-1) a)
+8 -15
View File
@@ -1,27 +1,20 @@
(import "tests/import1.slime")
(print)
(print ">" a)
(assert (= a 10))
(print ">" (get-a-1))
(assert (= (get-a-1) 10))
(assert (= a 1111))
(assert (= (get-a-1) 1111))
(import "tests/import2.slime")
(print ">" a)
(assert (= a 10))
(print ">" (get-a-1))
(assert (= (get-a-1) 10))
(print ">" (get-a-2))
(assert (= (get-a-2) 10))
(assert (= a 1111))
(assert (= (get-a-1) 1111))
(assert (= (get-a-2) 1111))
(set-a-2 11)
(print "> should be 11 from now on")
(print ">" a)
(assert (= a 11))
(print ">" (get-a-1))
(assert (= (get-a-1) 11))
(print ">" (get-a-2))
(assert (= (get-a-2) 11))
+2
View File
@@ -1,3 +1,4 @@
namespace Slime {
proc generate_docs(String* path) -> void {
FILE *f = fopen(Memory::get_c_str(path), "w");
if (!f) {
@@ -142,3 +143,4 @@ proc generate_docs(String* path) -> void {
print_this_env(print_this_env, get_current_environment(), (char*)"");
}
}
+5 -5
View File
@@ -97,11 +97,11 @@ namespace Slime {
}
};
// 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);
+3
View File
@@ -1,3 +1,5 @@
namespace Slime {
proc delete_error() -> void {
using Globals::error;
@@ -52,3 +54,4 @@ proc create_error(const char* c_func_name, const char* c_file_name, int c_file_l
free(out_msg);
create_error(c_func_name, c_file_name, c_file_line, type, formatted_string);
}
}
+2
View File
@@ -1,3 +1,4 @@
namespace Slime {
proc create_extended_environment_for_function_application(
Lisp_Object* unevaluated_arguments,
Lisp_Object* function,
@@ -520,3 +521,4 @@ proc interprete_stdin() -> void {
}();
}
}
}
+2
View File
@@ -1,3 +1,4 @@
namespace Slime {
void add_to_load_path(const char*);
bool lisp_object_equal(Lisp_Object*,Lisp_Object*);
Lisp_Object* built_in_load(String*);
@@ -81,3 +82,4 @@ namespace Globals {
extern Error* error;
extern bool breaking_on_errors;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
namespace GC {
namespace Slime::GC {
proc maybe_mark(Environment* env) -> void;
int current_mark;
+1 -1
View File
@@ -1,4 +1,4 @@
namespace Globals {
namespace Slime::Globals {
char* bin_path = nullptr;
Log_Level log_level = Log_Level::Debug;
+2
View File
@@ -1,3 +1,4 @@
namespace Slime {
proc string_equal(const char input[], const char check[]) -> bool {
if (input == check) return true;
@@ -458,3 +459,4 @@ proc log_error() -> void {
print_call_stack();
puts(console_normal);
}
}
+3 -4
View File
@@ -39,14 +39,14 @@ unsigned int hm_hash(void* ptr);
unsigned int hm_hash(Slime::Lisp_Object* obj);
#include "ftb/hashmap.hpp"
namespace Slime {
# include "defines.cpp"
# include "assert.hpp"
# include "define_macros.hpp"
# include "platform.cpp"
# include "structs.cpp"
# include "forward_decls.cpp"
}
bool hm_objects_match(char* a, char* b) {
return strcmp(a, b) == 0;
@@ -107,7 +107,6 @@ unsigned int hm_hash(Slime::Lisp_Object* obj) {
}
}
namespace Slime {
# include "globals.cpp"
# include "memory.cpp"
# include "gc.cpp"
@@ -122,4 +121,4 @@ namespace Slime {
# include "built_ins.cpp"
# include "testing.cpp"
// # include "undefines.cpp"
}
+2
View File
@@ -1,3 +1,4 @@
namespace Slime {
proc create_source_code_location(String* file, int line, int col) -> Source_Code_Location* {
if (!file)
return nullptr;
@@ -51,3 +52,4 @@ Lisp_Object::~Lisp_Object() {
default: break;
}
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
namespace Memory {
namespace Slime::Memory {
// ------------------
// global symbol / keyword table
+1 -1
View File
@@ -1,4 +1,4 @@
namespace Parser {
namespace Slime::Parser {
String* standard_in;
String* parser_file;
int parser_line;
+3
View File
@@ -1,3 +1,5 @@
namespace Slime {
inline proc get_cwd() -> char* {
const int buf_size = 2048;
char* res = (char*)malloc(buf_size * sizeof(char));
@@ -165,3 +167,4 @@ proc get_exe_dir() -> char* {
return path;
#endif
}
}
+2
View File
@@ -1,3 +1,4 @@
namespace Slime {
struct Lisp_Object;
struct String;
struct Environment;
@@ -140,3 +141,4 @@ struct Error {
Lisp_Object* type;
String* message;
};
}
+6
View File
@@ -1,3 +1,5 @@
namespace Slime {
#define epsilon 2.2204460492503131E-16
#define testresult int
@@ -602,6 +604,8 @@ proc run_all_tests() -> bool {
try Memory::init(409600);
push_environment(Memory::create_child_environment(
get_current_environment()));
printf("-- Util --\n");
invoke_test(test_array_lists_adding_and_removing);
invoke_test(test_array_lists_sorting);
@@ -629,6 +633,7 @@ proc run_all_tests() -> bool {
invoke_test(test_singular_t_and_nil);
invoke_test(test_singular_symbols);
pop_environment();
printf("\n-- Test Files --\n");
invoke_test_script("evaluation_of_default_args");
@@ -664,3 +669,4 @@ proc run_all_tests() -> bool {
#undef assert_not_null
#undef invoke_test
#undef invoke_test_script
}
+2
View File
@@ -1,3 +1,4 @@
namespace Slime {
proc visualize_lisp_machine() -> void {
// // save the current working directory
@@ -552,3 +553,4 @@ proc visualize_lisp_machine() -> void {
// ">", -padding, -padding, max_x + 2*padding, max_y + 2*padding);
}
}