From 33145be4c63f1385d3eda1e6c33bde87058a123b Mon Sep 17 00:00:00 2001 From: FelixBrendel Date: Sun, 29 Mar 2020 19:39:23 +0200 Subject: [PATCH] little cleanup for c-macro calls --- src/built_ins.cpp | 17 +++++------------ src/eval.cpp | 2 ++ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/built_ins.cpp b/src/built_ins.cpp index a0c689e..05e085f 100644 --- a/src/built_ins.cpp +++ b/src/built_ins.cpp @@ -163,8 +163,6 @@ namespace Slime { profile_with_name("(apply)"); using namespace Globals::Current_Execution; - --cs.next_index; - --ams.next_index; Lisp_Object* args = pcs[--pcs.next_index]; try_void assert_list_length(args, 2); @@ -224,10 +222,9 @@ namespace Slime { { profile_with_name("(eval)"); using namespace Globals::Current_Execution; - // TODO(Felix): ams index should be decremented in - // eval_expr when calling the macro - --ams.next_index; - cs.data[cs.next_index-1] = pcs[--pcs.next_index]->value.pair.first; + // we know cs.data[cs.next_index] is allocated because the + // macro cal lwas there just before + cs.data[cs.next_index++] = pcs[--pcs.next_index]->value.pair.first; (nass.end()-1)->append(NasAction::Eval); (nass.end()-1)->append(NasAction::Eval); @@ -238,8 +235,6 @@ namespace Slime { { profile_with_name("(begin)"); using namespace Globals::Current_Execution; - --cs.next_index; - --ams.next_index; Lisp_Object* args = pcs[--pcs.next_index]; int length = list_length(args); cs.reserve(length); @@ -263,7 +258,6 @@ namespace Slime { | | -> | | | | | | | .... | | ...... | */ - --ams.next_index; Lisp_Object* args = pcs.data[--pcs.next_index]; Lisp_Object* test = args->value.pair.first; args = args->value.pair.rest; @@ -274,7 +268,7 @@ namespace Slime { Lisp_Object* alternative = args->value.pair.first; args = args->value.pair.rest; try_void assert_type(args, Lisp_Object_Type::Nil); - --cs.next_index; + cs.append(alternative); cs.append(consequence); cs.append(test); @@ -292,8 +286,7 @@ namespace Slime { // and a NasAction. profile_with_name("(define)"); using namespace Globals::Current_Execution; - --cs.next_index; - --ams.next_index; + Lisp_Object* form = pcs.data[--pcs.next_index]; Lisp_Object* definee = form->value.pair.first; form = form->value.pair.rest; diff --git a/src/eval.cpp b/src/eval.cpp index 8aa472d..4a1753a 100644 --- a/src/eval.cpp +++ b/src/eval.cpp @@ -395,6 +395,8 @@ namespace Slime { case Lisp_Object_Type::Function: { if(pc->value.function->is_c) { if (pc->value.function->type.c_function_type == C_Function_Type::cMacro) { + --cs.next_index; // remove the macro call from cs + --ams.next_index; // remove the apply marker for the macro try pc->value.function->body.c_macro_body(); } else if (pc->value.function->type.c_function_type == C_Function_Type::cSpecial) {