diff --git a/3rd/ftb b/3rd/ftb index 3959dd2..d213320 160000 --- a/3rd/ftb +++ b/3rd/ftb @@ -1 +1 @@ -Subproject commit 3959dd2fc12eefbd4955fd20a1e4220562730508 +Subproject commit d2133205a73c3ae3455e8cc3e0a910ce0aaae518 diff --git a/bin/slime.rdbg b/bin/slime.rdbg index 0193073..84ccd66 100644 Binary files a/bin/slime.rdbg and b/bin/slime.rdbg differ diff --git a/build.bat b/build.bat index bdaace0..9ce9d43 100644 --- a/build.bat +++ b/build.bat @@ -8,11 +8,10 @@ taskkill /F /IM %exeName% > NUL 2> NUL echo ---------- Compiling ---------- call ..\timecmd cl ^ - ../src/main.cpp ^ + ../src/main.cpp^ /I../3rd/ ^ /D_PROFILING /D_DEBUG /D_DONT_BREAK_ON_ERRORS ^ - /Zi /std:c++latest /Fe%exeName% /W3 /wd4003 /nologo /EHsc ^ - /link /NODEFAULTLIB:libucrt libucrtd.lib + /Zi /std:c++latest /Fe%exeName% /W3 /wd4003 /nologo /EHsc rem call ..\timecmd clang-cl ../src/main.cpp -o %exeName% /O2 /std:c++latest /W3 /Zi /EHsc diff --git a/include/assert.hpp b/include/assert.hpp index 754d421..3ff6de5 100644 --- a/include/assert.hpp +++ b/include/assert.hpp @@ -52,3 +52,5 @@ # define assert_type(_node, _type) do {} while (0) # define assert(condition) do {} while (0) #endif + + diff --git a/include/define_macros.hpp b/include/define_macros.hpp index 33f1767..055e0f0 100644 --- a/include/define_macros.hpp +++ b/include/define_macros.hpp @@ -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) + + + + + + diff --git a/include/libslime.h b/include/libslime.h index d95a1e2..37bcf2d 100644 --- a/include/libslime.h +++ b/include/libslime.h @@ -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 parents; Hash_Map hm; + + ~Environment() { + parents.~Array_List(); + hm.~Hash_Map(); + } }; struct Function { @@ -120,7 +115,7 @@ namespace Slime { }; struct cFunction { - std::function 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 hashMap; + Continuation* continuation; + Hash_Map* 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*); diff --git a/manual/built-in-docs.org b/manual/built-in-docs.org index 131e18e..f7e22e3 100644 --- a/manual/built-in-docs.org +++ b/manual/built-in-docs.org @@ -1,195 +1,153 @@ #+latex: \hrule #+html:
-* =begin= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:cfunction= - - arguments :: - - rest :: =args= - - docu :: - #+BEGIN: -TODO - #+END: -#+latex: \hrule -#+html:
-* =concat-strings= +* =**= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - rest :: =strings= + - postitional :: =a=, =b= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =/= +* =quote= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - rest :: =args= + - postitional :: =datum= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =type= +* =load= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =n= + - postitional :: =file= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =pe= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:macro= - - arguments :: - - postitional :: =expr= - - docu :: none -#+latex: \hrule -#+html:
-* =zip= +* =type=?= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =l1=, =l2= - - docu :: none -#+latex: \hrule -#+html:
-* =helper= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:cfunction= - - arguments :: none. + - postitional :: =obj=, =typ= - docu :: #+BEGIN: - +Checks if the argument =obj= is of type =typ= #+END: #+latex: \hrule #+html:
-* =if= +* =symbol?= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:cfunction= + - type :: =:lambda= - arguments :: - - postitional :: =test=, =then_part=, =else_part= + - postitional :: =x= - docu :: #+BEGIN: -TODO +Checks if the argument is a symbol. #+END: #+latex: \hrule #+html:
-* =apply= +* =reduce-binary= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:cfunction= + - type :: =:lambda= - arguments :: - - postitional :: =fun=, =args= + - postitional :: =fun=, =seq= - docu :: #+BEGIN: -TODO +Takes a function and a sequence as arguments and applies the +function to the argument sequence. reduce-binary applies the arguments +*pair-wise* which means it works with binary functions as compared to +[[=reduce=]]. #+END: #+latex: \hrule #+html:
-* =delete-type!= +* =test= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =n= + - keyword :: =k= =(101)= - docu :: #+BEGIN: -TODO + #+END: #+latex: \hrule #+html:
-* =when= +* =lambda?= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:macro= + - type :: =:lambda= - arguments :: - - postitional :: =condition= - - rest :: =body= + - postitional :: =x= - docu :: #+BEGIN: -Special form for when multiple actions should be done if a -condition is true. - -{{{example_start}}} -(when (not ()) - (print "Hello ") - (print "from ") - (print "when!")) - -(when () - (print "Goodbye ") - (print "World!")) -{{{example_end}}} - +Checks if the argument is a function. #+END: #+latex: \hrule #+html:
-* =type=?= +* =extend2= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =obj=, =typ= + - postitional :: =seq=, =elem= - docu :: #+BEGIN: -Checks if the argument =obj= is of type =typ= +Extends a list with the given element, by putting it in +the (rest) of the last element of the sequence. #+END: #+latex: \hrule #+html:
-* =symbol?= +* =length= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =x= + - postitional :: =seq= - docu :: #+BEGIN: -Checks if the argument is a symbol. +Returns the length of the given sequence. #+END: #+latex: \hrule #+html:
-* =set-cdr!= +* =assert= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =target=, =source= + - postitional :: =test= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =break= +* =memstat= :PROPERTIES: :UNNUMBERED: t :END: @@ -201,47 +159,27 @@ TODO #+END: #+latex: \hrule #+html:
-* =lambda?= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:lambda= - - arguments :: - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is a function. - #+END: -#+latex: \hrule -#+html:
-* =extend2= +* =cond= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:lambda= + - type :: =:macro= - arguments :: - - postitional :: =seq=, =elem= - - docu :: - #+BEGIN: -Extends a list with the given element, by putting it in -the (rest) of the last element of the sequence. - #+END: + - rest :: =clauses= + - docu :: none #+latex: \hrule #+html:
-* =length= +* =assert-types== :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =seq= - - docu :: - #+BEGIN: -Returns the length of the given sequence. - #+END: + - rest :: =objs= + - docu :: none #+latex: \hrule #+html:
-* =<= +* =<== :PROPERTIES: :UNNUMBERED: t :END: @@ -254,59 +192,32 @@ TODO #+END: #+latex: \hrule #+html:
-* =mutate= +* =bound?= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =target=, =source= + - postitional :: =var= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =set-car!= +* =set-type!= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =target=, =source= + - postitional :: =node=, =new_type= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =assert-types== - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:lambda= - - arguments :: - - rest :: =objs= - - docu :: none -#+latex: \hrule -#+html:
-* =reduce= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:lambda= - - arguments :: - - postitional :: =fun=, =seq= - - docu :: - #+BEGIN: -Takes a function and a sequence as arguments and applies the -function to the argument sequence. This only works correctly if the -given function accepts a variable amount of parameters. If your -funciton is limited to two arguments, use [[=reduce-binary=]] -instead. - #+END: -#+latex: \hrule -#+html:
* =end= :PROPERTIES: :UNNUMBERED: t @@ -326,26 +237,26 @@ Returns the last pair in the sqeuence. #+END: #+latex: \hrule #+html:
-* === +* =get-random-between= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - rest :: =args= + - postitional :: =a=, =b= - docu :: #+BEGIN: -Takes 0 or more arguments and returns =t= if all arguments are equal and =()= otherwise. +TODO #+END: #+latex: \hrule #+html:
-* =info= +* =addr-of= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =n= + - postitional :: =var= - docu :: #+BEGIN: TODO @@ -375,56 +286,56 @@ Adds one to the argument. #+END: #+latex: \hrule #+html:
-* =*= +* =%= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - rest :: =args= + - postitional :: =a=, =b= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =define-syntax= +* =hm/set!= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =form= - - keyword :: =doc= =("")= - - rest :: =body= + - postitional :: =hm=, =key=, =value= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =vector-ref= +* =begin= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =vec=, =idx= + - rest :: =args= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =let= +* =concat-strings= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:macro= + - type :: =:cfunction= - arguments :: - - postitional :: =bindings= - - rest :: =body= - - docu :: none + - rest :: =strings= + - docu :: + #+BEGIN: +TODO + #+END: #+latex: \hrule #+html:
* =define-module= @@ -452,246 +363,222 @@ Checks if the argument is a built-in function. #+END: #+latex: \hrule #+html:
-* =vector-length= +* =zip= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:cfunction= + - type :: =:lambda= - arguments :: - - postitional :: =v= - - docu :: - #+BEGIN: -TODO - #+END: + - postitional :: =l1=, =l2= + - docu :: none #+latex: \hrule #+html:
-* =print= +* =/= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - keyword :: =sep= =(" ")=, =end= =("\n")= - - rest :: =things= + - rest :: =args= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =symbol->keyword= +* =type= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =sym= + - postitional :: =n= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =stream-null?= +* =pe= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:lambda= + - type :: =:macro= - arguments :: - - postitional :: =s= + - postitional :: =expr= - docu :: none #+latex: \hrule #+html:
-* =not= +* =helper= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - - arguments :: - - postitional :: =test= + - arguments :: none. - docu :: #+BEGIN: -TODO + #+END: #+latex: \hrule #+html:
-* =generate-docs= +* =if= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =file_name= + - postitional :: =test=, =then_part=, =else_part= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =hm/get-or-nil= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:lambda= - - arguments :: - - postitional :: =hm=, =key= - - docu :: none -#+latex: \hrule -#+html:
-* =the-empty-stream= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:constructor= - - value :: =()= - - docu :: none -#+latex: \hrule -#+html:
-* =force= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:lambda= - - arguments :: - - postitional :: =promise= - - docu :: none -#+latex: \hrule -#+html:
-* =>== +* =apply= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - rest :: =args= + - postitional :: =fun=, =args= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =hash-map-get= +* =delete-type!= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =hm=, =key= + - postitional :: =n= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =exit= +* =when= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:cfunction= + - type :: =:macro= - arguments :: - - keyword :: =code= =(0)= + - postitional :: =condition= + - rest :: =body= - docu :: #+BEGIN: -TODO +Special form for when multiple actions should be done if a +condition is true. + +{{{example_start}}} +(when (not ()) + (print "Hello ") + (print "from ") + (print "when!")) + +(when () + (print "Goodbye ") + (print "World!")) +{{{example_end}}} + #+END: #+latex: \hrule #+html:
-* =hm/get= +* =set-cdr!= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =hm=, =key= + - postitional :: =target=, =source= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =n-times= +* =break= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:macro= - - arguments :: - - postitional :: =times=, =action= + - type :: =:cfunction= + - arguments :: none. - docu :: #+BEGIN: -Executes action times times. +TODO #+END: #+latex: \hrule #+html:
-* =string?= +* =reduce= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =x= + - postitional :: =fun=, =seq= - docu :: #+BEGIN: -Checks if the argument is a string. +Takes a function and a sequence as arguments and applies the +function to the argument sequence. This only works correctly if the +given function accepts a variable amount of parameters. If your +funciton is limited to two arguments, use [[=reduce-binary=]] +instead. #+END: #+latex: \hrule #+html:
-* =vector-set!= +* =<= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =vec=, =idx=, =val= + - rest :: =args= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =pair= +* =mutate= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =car=, =cdr= + - postitional :: =target=, =source= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =mem-reset= +* =set-car!= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - - arguments :: none. + - arguments :: + - postitional :: =target=, =source= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =delay= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:macro= - - arguments :: - - postitional :: =expr= - - docu :: none -#+latex: \hrule -#+html:
-* =define-typed= +* =string?= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:macro= + - type :: =:lambda= - arguments :: - - postitional :: =args= - - rest :: =body= - - docu :: none + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is a string. + #+END: #+latex: \hrule #+html:
* =generic-extend= @@ -719,17 +606,33 @@ by the key 'from' and ends with the number defined in 'to'. #+END: #+latex: \hrule #+html:
-* =unzip= +* === :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:lambda= + - type :: =:cfunction= - arguments :: - - postitional :: =lists= - - docu :: none + - rest :: =args= + - docu :: + #+BEGIN: +Takes 0 or more arguments and returns =t= if all arguments are equal and =()= otherwise. + #+END: #+latex: \hrule #+html:
-* =-= +* =info= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:cfunction= + - arguments :: + - postitional :: =n= + - docu :: + #+BEGIN: +TODO + #+END: +#+latex: \hrule +#+html:
+* =*= :PROPERTIES: :UNNUMBERED: t :END: @@ -742,33 +645,45 @@ TODO #+END: #+latex: \hrule #+html:
-* =extend= +* =define-syntax= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:lambda= + - type :: =:cfunction= - arguments :: - - postitional :: =seq=, =elem= + - postitional :: =form= + - keyword :: =doc= =("")= + - rest :: =body= - docu :: #+BEGIN: -Extends a list with the given element, by putting it in -the (rest) of the last element of the sequence. +TODO #+END: #+latex: \hrule #+html:
-* =hash-map-set!= +* =vector-ref= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =hm=, =key=, =value= + - postitional :: =vec=, =idx= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
+* =let= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:macro= + - arguments :: + - postitional :: =bindings= + - rest :: =body= + - docu :: none +#+latex: \hrule +#+html:
* =null?= :PROPERTIES: :UNNUMBERED: t @@ -792,69 +707,54 @@ Checks if the argument is =nil=. - docu :: none #+latex: \hrule #+html:
-* =enumerate= +* =vector-length= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:lambda= + - type :: =:cfunction= - arguments :: - - postitional :: =seq= - - docu :: none + - postitional :: =v= + - docu :: + #+BEGIN: +TODO + #+END: #+latex: \hrule #+html:
-* =or= +* =print= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - rest :: =args= + - keyword :: =sep= =(" ")=, =end= =("\n")= + - rest :: =things= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =rest= +* =symbol->keyword= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =seq= + - postitional :: =sym= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =construct-list= +* =stream-null?= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:macro= + - type :: =:lambda= - arguments :: - - rest :: =body= - - docu :: - #+BEGIN: - -{{{example_start}}} -(construct-list - i <- '(1 2 3 4 5) - yield (* i i)) -{{{example_end}}} - -(construct-list - i <- '(1 2 3 4) - j <- '(A B) - yield (pair i j)) - -(construct-list - i <- '(1 2 3 4 5 6 7 8) - if (= 0 (% i 2)) - yield i) - - #+END: + - postitional :: =s= + - docu :: none #+latex: \hrule #+html:
* =types=?= @@ -880,144 +780,123 @@ Checks if the argument is a special-lambda. #+END: #+latex: \hrule #+html:
-* =>= +* =not= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - rest :: =args= + - postitional :: =test= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =set!= +* =generate-docs= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =sym=, =val= + - postitional :: =file_name= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =create-hash-map= +* =hm/get-or-nil= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:cfunction= - - arguments :: none. - - docu :: - #+BEGIN: -TODO - #+END: + - type :: =:lambda= + - arguments :: + - postitional :: =hm=, =key= + - docu :: none #+latex: \hrule #+html:
-* =first= +* =the-empty-stream= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:cfunction= - - arguments :: - - postitional :: =seq= - - docu :: - #+BEGIN: -TODO - #+END: + - type :: =:constructor= + - value :: =()= + - docu :: none #+latex: \hrule #+html:
-* =show= +* =force= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:cfunction= + - type :: =:lambda= - arguments :: - - postitional :: =n= - - docu :: - #+BEGIN: -TODO - #+END: -#+latex: \hrule -#+html:
-* =member?= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:lambda= - - arguments :: - - postitional :: =elem=, =seq= + - postitional :: =promise= - docu :: none #+latex: \hrule #+html:
-* =read= +* =>== :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - keyword :: =prompt= =(">")= + - rest :: =args= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =unless= +* =hash-map-get= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:macro= + - type :: =:cfunction= - arguments :: - - postitional :: =condition= - - rest :: =body= + - postitional :: =hm=, =key= - docu :: #+BEGIN: -Special form for when multiple actions should be done if a -condition is false. +TODO #+END: #+latex: \hrule #+html:
-* =eval= +* =exit= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =expr= + - keyword :: =code= =(0)= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =vector= +* =hm/get= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - rest :: =args= + - postitional :: =hm=, =key= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =symbol->string= +* =n-times= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:cfunction= + - type :: =:macro= - arguments :: - - postitional :: =sym= + - postitional :: =times=, =action= - docu :: #+BEGIN: -TODO +Executes action times times. #+END: #+latex: \hrule #+html:
@@ -1048,45 +927,65 @@ by the key =from= and ends with the number defined in =to=. #+END: #+latex: \hrule #+html:
-* =hash-map-delete!= +* =vector-set!= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =hm=, =key= + - postitional :: =vec=, =idx=, =val= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =mytry= +* =pair= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =try_part=, =catch_part= + - postitional :: =car=, =cdr= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =string->symbol= +* =mem-reset= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - - arguments :: - - postitional :: =str= + - arguments :: none. - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
+* =delay= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:macro= + - arguments :: + - postitional :: =expr= + - docu :: none +#+latex: \hrule +#+html:
+* =define-typed= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:macro= + - arguments :: + - postitional :: =args= + - rest :: =body= + - docu :: none +#+latex: \hrule +#+html:
* =pair?= :PROPERTIES: :UNNUMBERED: t @@ -1100,23 +999,30 @@ Checks if the argument is a pair. #+END: #+latex: \hrule #+html:
-* =filter= +* =unzip= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =fun=, =seq= + - postitional :: =lists= + - docu :: none +#+latex: \hrule +#+html:
+* =number?= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:lambda= + - arguments :: + - postitional :: =x= - docu :: #+BEGIN: -Takes a function and a sequence as arguments and applies the -function to every value in the sequence. If the result of that -funciton application returns a truthy value, the original value is -added to a list, which in the end is returned. +Checks if the argument is a number. #+END: #+latex: \hrule #+html:
-* =+= +* =-= :PROPERTIES: :UNNUMBERED: t :END: @@ -1129,58 +1035,132 @@ TODO #+END: #+latex: \hrule #+html:
-* =lambda= +* =extend= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:lambda= + - arguments :: + - postitional :: =seq=, =elem= + - docu :: + #+BEGIN: +Extends a list with the given element, by putting it in +the (rest) of the last element of the sequence. + #+END: +#+latex: \hrule +#+html:
+* =enumerate= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:lambda= + - arguments :: + - postitional :: =seq= + - docu :: none +#+latex: \hrule +#+html:
+* =hash-map-set!= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =args= - - rest :: =body= + - postitional :: =hm=, =key=, =value= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =number?= +* =or= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:lambda= + - type :: =:cfunction= - arguments :: - - postitional :: =x= + - rest :: =args= - docu :: #+BEGIN: -Checks if the argument is a number. +TODO #+END: #+latex: \hrule #+html:
-* =error= +* =rest= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =type=, =message= + - postitional :: =seq= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =case= +* =construct-list= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:macro= - arguments :: - - postitional :: =var= - - rest :: =clauses= - - docu :: none + - rest :: =body= + - docu :: + #+BEGIN: + +{{{example_start}}} +(construct-list + i <- '(1 2 3 4 5) + yield (* i i)) +{{{example_end}}} + +(construct-list + i <- '(1 2 3 4) + j <- '(A B) + yield (pair i j)) + +(construct-list + i <- '(1 2 3 4 5 6 7 8) + if (= 0 (% i 2)) + yield i) + + #+END: #+latex: \hrule #+html:
-* =and= +* =last= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:lambda= + - arguments :: + - postitional :: =seq= + - docu :: + #+BEGIN: +Returns the (first) of the last (pair) of the given sequence. + +{{{example_start}}} +(define a (list 1 2 3 4)) +(print (last a)) +{{{example_end}}} + + #+END: +#+latex: \hrule +#+html:
+* =append= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:lambda= + - arguments :: + - postitional :: =seq=, =elem= + - docu :: + #+BEGIN: +Appends an element to a sequence, by extendeing the list +with (pair elem nil). + #+END: +#+latex: \hrule +#+html:
+* =>= :PROPERTIES: :UNNUMBERED: t :END: @@ -1193,35 +1173,119 @@ TODO #+END: #+latex: \hrule #+html:
-* =copy= +* =set!= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:cfunction= + - arguments :: + - postitional :: =sym=, =val= + - docu :: + #+BEGIN: +TODO + #+END: +#+latex: \hrule +#+html:
+* =create-hash-map= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:cfunction= + - arguments :: none. + - docu :: + #+BEGIN: +TODO + #+END: +#+latex: \hrule +#+html:
+* =first= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:cfunction= + - arguments :: + - postitional :: =seq= + - docu :: + #+BEGIN: +TODO + #+END: +#+latex: \hrule +#+html:
+* =show= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:cfunction= + - arguments :: + - postitional :: =n= + - docu :: + #+BEGIN: +TODO + #+END: +#+latex: \hrule +#+html:
+* =macro?= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:lambda= + - arguments :: + - postitional :: =x= + - docu :: + #+BEGIN: +Checks if the argument is a macro. + #+END: +#+latex: \hrule +#+html:
+* =procedure?= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:lambda= + - arguments :: + - postitional :: =x= + - docu :: none +#+latex: \hrule +#+html:
+* =member?= + :PROPERTIES: + :UNNUMBERED: t + :END: + - type :: =:lambda= + - arguments :: + - postitional :: =elem=, =seq= + - docu :: none +#+latex: \hrule +#+html:
+* =read= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =obj= + - keyword :: =prompt= =(">")= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =define= +* =unless= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:cfunction= + - type :: =:macro= - arguments :: - - postitional :: =definee= - - keyword :: =doc= =("")= + - postitional :: =condition= - rest :: =body= - docu :: #+BEGIN: -TODO +Special form for when multiple actions should be done if a +condition is false. #+END: #+latex: \hrule #+html:
-* =quasiquote= +* =eval= :PROPERTIES: :UNNUMBERED: t :END: @@ -1234,7 +1298,7 @@ TODO #+END: #+latex: \hrule #+html:
-* =list= +* =vector= :PROPERTIES: :UNNUMBERED: t :END: @@ -1247,194 +1311,167 @@ TODO #+END: #+latex: \hrule #+html:
-* =import= +* =symbol->string= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =f= + - postitional :: =sym= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =last= +* =map= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =seq= + - postitional :: =fun=, =seq= - docu :: #+BEGIN: -Returns the (first) of the last (pair) of the given sequence. - -{{{example_start}}} -(define a (list 1 2 3 4)) -(print (last a)) -{{{example_end}}} - +Takes a function and a sequence as arguments and returns a new +sequence which contains the results of using the first sequences +elemens as argument to that function. #+END: #+latex: \hrule #+html:
-* =append= +* =filter= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =seq=, =elem= + - postitional :: =fun=, =seq= - docu :: #+BEGIN: -Appends an element to a sequence, by extendeing the list -with (pair elem nil). +Takes a function and a sequence as arguments and applies the +function to every value in the sequence. If the result of that +funciton application returns a truthy value, the original value is +added to a list, which in the end is returned. #+END: #+latex: \hrule #+html:
-* =**= +* =hash-map-delete!= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =a=, =b= + - postitional :: =hm=, =key= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =quote= +* =mytry= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =datum= + - postitional :: =try_part=, =catch_part= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =load= +* =string->symbol= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =file= + - postitional :: =str= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =macro?= +* =decrement= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =x= + - postitional :: =val= - docu :: #+BEGIN: -Checks if the argument is a macro. +Subtracts one from the argument. #+END: #+latex: \hrule #+html:
-* =procedure?= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:lambda= - - arguments :: - - postitional :: =x= - - docu :: none -#+latex: \hrule -#+html:
-* =test= +* =+= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - keyword :: =k= =(101)= - - docu :: - #+BEGIN: - - #+END: -#+latex: \hrule -#+html:
-* =reduce-binary= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:lambda= - - arguments :: - - postitional :: =fun=, =seq= + - rest :: =args= - docu :: #+BEGIN: -Takes a function and a sequence as arguments and applies the -function to the argument sequence. reduce-binary applies the arguments -*pair-wise* which means it works with binary functions as compared to -[[=reduce=]]. +TODO #+END: #+latex: \hrule #+html:
-* =assert= +* =lambda= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =test= + - postitional :: =args= + - rest :: =body= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =memstat= +* =error= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - - arguments :: none. + - arguments :: + - postitional :: =type=, =message= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =cond= +* =case= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:macro= - arguments :: + - postitional :: =var= - rest :: =clauses= - docu :: none #+latex: \hrule #+html:
-* =map= +* =continuation?= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =fun=, =seq= + - postitional :: =x= - docu :: #+BEGIN: -Takes a function and a sequence as arguments and returns a new -sequence which contains the results of using the first sequences -elemens as argument to that function. +Checks if the argument is a continuation. #+END: #+latex: \hrule #+html:
-* =<== +* =and= :PROPERTIES: :UNNUMBERED: t :END: @@ -1447,111 +1484,93 @@ TODO #+END: #+latex: \hrule #+html:
-* =bound?= +* =copy= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =var= + - postitional :: =obj= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =set-type!= +* =define= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =node=, =new_type= + - postitional :: =definee= + - keyword :: =doc= =("")= + - rest :: =body= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =decrement= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:lambda= - - arguments :: - - postitional :: =val= - - docu :: - #+BEGIN: -Subtracts one from the argument. - #+END: -#+latex: \hrule -#+html:
-* =get-random-between= +* =quasiquote= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =a=, =b= + - postitional :: =expr= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =addr-of= +* =list= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =var= + - rest :: =args= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =%= +* =import= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:cfunction= - arguments :: - - postitional :: =a=, =b= + - postitional :: =f= - docu :: #+BEGIN: TODO #+END: #+latex: \hrule #+html:
-* =hm/set!= +* =ds::alist::make= :PROPERTIES: :UNNUMBERED: t :END: - - type :: =:cfunction= - - arguments :: - - postitional :: =hm=, =key=, =value= - - docu :: - #+BEGIN: -TODO - #+END: + - type :: =:lambda= + - arguments :: none. + - docu :: none #+latex: \hrule #+html:
-* =continuation?= +* =ds::alist::print= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =x= - - docu :: - #+BEGIN: -Checks if the argument is a continuation. - #+END: + - postitional :: =alist= + - docu :: none #+latex: \hrule #+html:
-* =ds::alist::get= +* =ds::alist::find= :PROPERTIES: :UNNUMBERED: t :END: @@ -1561,7 +1580,7 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =ds::alist::key-exists?= +* =ds::alist::remove!= :PROPERTIES: :UNNUMBERED: t :END: @@ -1571,7 +1590,7 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =ds::alist::set!= +* =ds::alist::set-overwrite!= :PROPERTIES: :UNNUMBERED: t :END: @@ -1581,16 +1600,17 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =ds::plist::make= +* =ds::plist::print= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - - arguments :: none. + - arguments :: + - postitional :: =plist= - docu :: none #+latex: \hrule #+html:
-* =ds::plist::get= +* =ds::plist::find= :PROPERTIES: :UNNUMBERED: t :END: @@ -1600,7 +1620,7 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =ds::plist::prop-exists?= +* =ds::plist::remove!= :PROPERTIES: :UNNUMBERED: t :END: @@ -1610,7 +1630,7 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =ds::plist::set!= +* =ds::plist::set-overwrite!= :PROPERTIES: :UNNUMBERED: t :END: @@ -1620,26 +1640,7 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =ds::alist::make= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:lambda= - - arguments :: none. - - docu :: none -#+latex: \hrule -#+html:
-* =ds::alist::print= - :PROPERTIES: - :UNNUMBERED: t - :END: - - type :: =:lambda= - - arguments :: - - postitional :: =alist= - - docu :: none -#+latex: \hrule -#+html:
-* =ds::alist::find= +* =ds::alist::get= :PROPERTIES: :UNNUMBERED: t :END: @@ -1649,7 +1650,7 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =ds::alist::remove!= +* =ds::alist::key-exists?= :PROPERTIES: :UNNUMBERED: t :END: @@ -1659,7 +1660,7 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =ds::alist::set-overwrite!= +* =ds::alist::set!= :PROPERTIES: :UNNUMBERED: t :END: @@ -1669,17 +1670,16 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =ds::plist::print= +* =ds::plist::make= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - - arguments :: - - postitional :: =plist= + - arguments :: none. - docu :: none #+latex: \hrule #+html:
-* =ds::plist::find= +* =ds::plist::get= :PROPERTIES: :UNNUMBERED: t :END: @@ -1689,7 +1689,7 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =ds::plist::remove!= +* =ds::plist::prop-exists?= :PROPERTIES: :UNNUMBERED: t :END: @@ -1699,7 +1699,7 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =ds::plist::set-overwrite!= +* =ds::plist::set!= :PROPERTIES: :UNNUMBERED: t :END: @@ -1719,73 +1719,73 @@ Checks if the argument is a continuation. - docu :: none #+latex: \hrule #+html:
-* =interpolation::lerp= +* =interpolation::lerper= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =a=, =b=, =t= + - postitional :: =a=, =b= - docu :: none #+latex: \hrule #+html:
-* =interpolation::stepped-lerper= +* =interpolation::point-lerp= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =a=, =b=, =#steps= + - postitional :: =p1=, =p2=, =t= - docu :: none #+latex: \hrule #+html:
-* =interpolation::point-lerper= +* =interpolation::bezier2= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =p1=, =p2= + - postitional :: =p1=, =p2=, =p3=, =t= - docu :: none #+latex: \hrule #+html:
-* =interpolation::bezierer2= +* =interpolation::lerp= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =p1=, =p2=, =p3= + - postitional :: =a=, =b=, =t= - docu :: none #+latex: \hrule #+html:
-* =interpolation::lerper= +* =interpolation::stepped-lerper= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =a=, =b= + - postitional :: =a=, =b=, =#steps= - docu :: none #+latex: \hrule #+html:
-* =interpolation::point-lerp= +* =interpolation::point-lerper= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =p1=, =p2=, =t= + - postitional :: =p1=, =p2= - docu :: none #+latex: \hrule #+html:
-* =interpolation::bezier2= +* =interpolation::bezierer2= :PROPERTIES: :UNNUMBERED: t :END: - type :: =:lambda= - arguments :: - - postitional :: =p1=, =p2=, =p3=, =t= + - postitional :: =p1=, =p2=, =p3= - docu :: none #+latex: \hrule #+html:
diff --git a/src/built_ins.cpp b/src/built_ins.cpp index 82dc59a..7a253b0 100644 --- a/src/built_ins.cpp +++ b/src/built_ins.cpp @@ -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; } diff --git a/src/define_macros.hpp b/src/define_macros.hpp index 7a23237..2587a54 100644 --- a/src/define_macros.hpp +++ b/src/define_macros.hpp @@ -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* diff --git a/src/env.cpp b/src/env.cpp index 6e1248d..4070c2c 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -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); diff --git a/src/forward_decls.cpp b/src/forward_decls.cpp index 1d0831e..f4173b7 100644 --- a/src/forward_decls.cpp +++ b/src/forward_decls.cpp @@ -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*); diff --git a/src/io.cpp b/src/io.cpp index c7dff1d..97054f7 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -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; } diff --git a/src/libslime.cpp b/src/libslime.cpp index 29e73eb..4e69e72 100644 --- a/src/libslime.cpp +++ b/src/libslime.cpp @@ -1,7 +1,6 @@ #define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_DEPRECATE -#define _CRTDBG_MAP_ALLOC #include #include @@ -12,10 +11,8 @@ #include #include #include -// #include #ifdef _MSC_VER -# include # include # include #else diff --git a/src/main.cpp b/src/main.cpp index fbb0be9..e65672d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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; } diff --git a/src/platform.cpp b/src/platform.cpp index 8cbd74c..c39b290 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -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; diff --git a/src/testing.cpp b/src/testing.cpp index 24b13de..2019597 100644 --- a/src/testing.cpp +++ b/src/testing.cpp @@ -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);