small optimizaitons
This commit is contained in:
@@ -52,3 +52,5 @@
|
||||
# define assert_type(_node, _type) do {} while (0)
|
||||
# define assert(condition) do {} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define if_error_log_location_and_return() \
|
||||
#define if_error_log_location_and_return(val) \
|
||||
do { \
|
||||
if (Globals::error) { \
|
||||
log_location(); \
|
||||
return; \
|
||||
return val; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
@@ -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*
|
||||
@@ -132,6 +132,7 @@
|
||||
Globals::Current_Execution::envi_stack.next_index-1)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* iterate over lisp vectors
|
||||
*/
|
||||
@@ -151,3 +152,9 @@
|
||||
for (Lisp_Object* head = l, *it; \
|
||||
Memory::get_type(head) == Lisp_Object_Type::Pair && (it = head->value.pair.first); \
|
||||
head = head->value.pair.rest, ++it_index)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+15
-17
@@ -67,16 +67,6 @@ namespace Slime {
|
||||
int column;
|
||||
};
|
||||
|
||||
struct Symbol {
|
||||
String* identifier;
|
||||
u64 hash;
|
||||
};
|
||||
|
||||
struct Keyword {
|
||||
String* identifier;
|
||||
u64 hash;
|
||||
};
|
||||
|
||||
struct Pair {
|
||||
Lisp_Object* first;
|
||||
Lisp_Object* rest;
|
||||
@@ -110,6 +100,11 @@ namespace Slime {
|
||||
struct Environment {
|
||||
Array_List<Environment*> parents;
|
||||
Hash_Map<void*, Lisp_Object*> hm;
|
||||
|
||||
~Environment() {
|
||||
parents.~Array_List();
|
||||
hm.~Hash_Map();
|
||||
}
|
||||
};
|
||||
|
||||
struct Function {
|
||||
@@ -120,7 +115,7 @@ namespace Slime {
|
||||
};
|
||||
|
||||
struct cFunction {
|
||||
std::function<Lisp_Object* ()> body;
|
||||
Lisp_Object* (*body)();
|
||||
Arguments args;
|
||||
bool is_special_form;
|
||||
};
|
||||
@@ -130,18 +125,20 @@ namespace Slime {
|
||||
u64 flags;
|
||||
Lisp_Object* userType; // keyword
|
||||
String* docstring;
|
||||
union {
|
||||
Symbol symbol; // used for symbols and keywords
|
||||
union value {
|
||||
String* symbol; // used for symbols and keywords
|
||||
double number;
|
||||
String* string;
|
||||
Pair pair;
|
||||
Vector vector;
|
||||
Function function;
|
||||
Function* function;
|
||||
cFunction* cFunction;
|
||||
void* pointer;
|
||||
Continuation continuation;
|
||||
Hash_Map<Lisp_Object*, Lisp_Object*> hashMap;
|
||||
Continuation* continuation;
|
||||
Hash_Map<Lisp_Object*, Lisp_Object*>* hashMap;
|
||||
~value() {}
|
||||
} value;
|
||||
~Lisp_Object();
|
||||
};
|
||||
|
||||
struct Error {
|
||||
@@ -151,6 +148,7 @@ namespace Slime {
|
||||
String* message;
|
||||
};
|
||||
|
||||
|
||||
const wchar_t* char_to_wchar(const char* c);
|
||||
char* read_entire_file(char* filename);
|
||||
void add_to_load_path(const char*);
|
||||
@@ -165,7 +163,7 @@ namespace Slime {
|
||||
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*);
|
||||
|
||||
Reference in New Issue
Block a user