Browse Source

function bodys can now be empty.. sigh

master
FelixBrendel 6 years ago
parent
commit
4a0e6eb17a
6 changed files with 30 additions and 19 deletions
  1. +1
    -0
      bin/tests/regression.slime
  2. +10
    -10
      build.bat
  3. +14
    -6
      src/built_ins.cpp
  4. +3
    -1
      src/eval.cpp
  5. +0
    -1
      src/structs.cpp
  6. +2
    -1
      src/testing.cpp

+ 1
- 0
bin/tests/regression.slime View File

@@ -0,0 +1 @@
;; (define (empty-function-body-test))

+ 10
- 10
build.bat View File

@@ -11,7 +11,7 @@ call cl ^
../src/main.cpp^ ../src/main.cpp^
/I../3rd/ ^ /I../3rd/ ^
/D_PROFILING /D_DEBUG ^ /D_PROFILING /D_DEBUG ^
/Zi /std:c++latest /Fe%exeName% /W3 /wd4003 /nologo /EHsc
/Zi /std:c++latest /Fe%exeName% /W3 /wd4003 /wd4996 /nologo /EHsc
rem call ..\timecmd cl ^ rem call ..\timecmd cl ^
rem ../src/main.cpp^ rem ../src/main.cpp^
@@ -21,14 +21,14 @@ rem call ..\timecmd cl ^
rem call ..\timecmd clang-cl ../src/main.cpp -o %exeName% /O2 /std:c++latest /W3 /Zi /EHsc rem call ..\timecmd clang-cl ../src/main.cpp -o %exeName% /O2 /std:c++latest /W3 /Zi /EHsc
rem if %errorlevel% == 0 (
rem echo.
rem echo ---- Running Tests ----
rem echo.
rem call slime.exe --run-tests
rem ) else (
rem echo.
rem echo Fuckin' ell
rem )
if %errorlevel% == 0 (
echo.
echo ---- Running Tests ----
echo.
call slime.exe --run-tests
) else (
echo.
echo Fuckin' ell
)
popd popd

+ 14
- 6
src/built_ins.cpp View File

@@ -295,7 +295,9 @@ namespace Slime {
Lisp_Object* form = pcs.data[--pcs.next_index]; Lisp_Object* form = pcs.data[--pcs.next_index];
Lisp_Object* definee = form->value.pair.first; Lisp_Object* definee = form->value.pair.first;
form = form->value.pair.rest; form = form->value.pair.rest;
try_void assert_type(form, Lisp_Object_Type::Pair);
if (definee->type == Lisp_Object_Type::Symbol) {
try_void assert_type(form, Lisp_Object_Type::Pair);
}
Lisp_Object* thing = form->value.pair.first; Lisp_Object* thing = form->value.pair.first;
Lisp_Object* thing_cons = form; Lisp_Object* thing_cons = form;
form = form->value.pair.rest; form = form->value.pair.rest;
@@ -322,10 +324,15 @@ namespace Slime {
try_void func = Memory::create_lisp_object_function(Lisp_Function_Type::Lambda); try_void func = Memory::create_lisp_object_function(Lisp_Function_Type::Lambda);
func->value.function->parent_environment = get_current_environment(); func->value.function->parent_environment = get_current_environment();
create_arguments_from_lambda_list_and_inject(definee->value.pair.rest, func); create_arguments_from_lambda_list_and_inject(definee->value.pair.rest, func);
if (thing_cons->value.pair.first->type == Lisp_Object_Type::String &&
thing_cons->value.pair.rest != Memory::nil)
{
// extract docs

if (thing_cons->type == Lisp_Object_Type::Pair &&
// if there is stuff in the function body
thing_cons->value.pair.first->type == Lisp_Object_Type::String &&
// if the first is a string
thing_cons->value.pair.rest != Memory::nil
// if it is not the last
) {
// we found docs
Globals::docs.set_object( Globals::docs.set_object(
func, func,
Memory::duplicate_string( Memory::duplicate_string(
@@ -333,8 +340,9 @@ namespace Slime {
thing_cons = thing_cons->value.pair.rest; thing_cons = thing_cons->value.pair.rest;
} }
func->value.function->body.lisp_body = maybe_wrap_body_in_begin(thing_cons); func->value.function->body.lisp_body = maybe_wrap_body_in_begin(thing_cons);

define_symbol(definee->value.pair.first, func); define_symbol(definee->value.pair.first, func);
cs.append(Memory::t);
cs.append(definee->value.pair.first);
} break; } break;
default: { default: {
create_generic_error("you can only define symbols"); create_generic_error("you can only define symbols");


+ 3
- 1
src/eval.cpp View File

@@ -303,6 +303,8 @@ namespace Slime {


inline proc maybe_wrap_body_in_begin(Lisp_Object* body) -> Lisp_Object* { inline proc maybe_wrap_body_in_begin(Lisp_Object* body) -> Lisp_Object* {
Lisp_Object* begin_symbol = Memory::get_symbol("begin"); Lisp_Object* begin_symbol = Memory::get_symbol("begin");
if (body->type != Lisp_Object_Type::Pair)
return body;
if (body->value.pair.rest == Memory::nil) if (body->value.pair.rest == Memory::nil)
return body->value.pair.first; return body->value.pair.first;
else else
@@ -504,7 +506,7 @@ namespace Slime {
proc interprete_stdin() -> void { proc interprete_stdin() -> void {
try_void Memory::init(); try_void Memory::init();
try_void Memory::load_pre(); try_void Memory::load_pre();
printf("Welcome to the lispy interpreter.\n%s\n", version_string); printf("Welcome to the lispy interpreter.\n%s\n", version_string);


char* line; char* line;


+ 0
- 1
src/structs.cpp View File

@@ -142,7 +142,6 @@ namespace Slime {
} value; } value;
}; };
#pragma options align=reset #pragma options align=reset

struct Error { struct Error {
Lisp_Object* position; Lisp_Object* position;
// type has to be a keyword // type has to be a keyword


+ 2
- 1
src/testing.cpp View File

@@ -592,7 +592,7 @@ namespace Slime {


bool result = true; bool result = true;
try Memory::init(); try Memory::init();
try Memory::load_pre();
push_environment(Memory::create_child_environment( push_environment(Memory::create_child_environment(
get_current_environment())); get_current_environment()));
printf("-- Util --\n"); printf("-- Util --\n");
@@ -622,6 +622,7 @@ namespace Slime {
pop_environment(); pop_environment();
printf("\n-- Test Files --\n"); printf("\n-- Test Files --\n");


invoke_test_script("regression");
invoke_test_script("evaluation_of_default_args"); invoke_test_script("evaluation_of_default_args");
invoke_test_script("case_and_cond"); invoke_test_script("case_and_cond");
invoke_test_script("lexical_scope"); invoke_test_script("lexical_scope");


Loading…
Cancel
Save