Browse Source

little cleanup for c-macro calls

master
FelixBrendel 6 years ago
parent
commit
33145be4c6
2 changed files with 7 additions and 12 deletions
  1. +5
    -12
      src/built_ins.cpp
  2. +2
    -0
      src/eval.cpp

+ 5
- 12
src/built_ins.cpp View File

@@ -163,8 +163,6 @@ namespace Slime {
profile_with_name("(apply)"); profile_with_name("(apply)");
using namespace Globals::Current_Execution; using namespace Globals::Current_Execution;


--cs.next_index;
--ams.next_index;
Lisp_Object* args = pcs[--pcs.next_index]; Lisp_Object* args = pcs[--pcs.next_index];
try_void assert_list_length(args, 2); try_void assert_list_length(args, 2);


@@ -224,10 +222,9 @@ namespace Slime {
{ {
profile_with_name("(eval)"); profile_with_name("(eval)");
using namespace Globals::Current_Execution; 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);
(nass.end()-1)->append(NasAction::Eval); (nass.end()-1)->append(NasAction::Eval);


@@ -238,8 +235,6 @@ namespace Slime {
{ {
profile_with_name("(begin)"); profile_with_name("(begin)");
using namespace Globals::Current_Execution; using namespace Globals::Current_Execution;
--cs.next_index;
--ams.next_index;
Lisp_Object* args = pcs[--pcs.next_index]; Lisp_Object* args = pcs[--pcs.next_index];
int length = list_length(args); int length = list_length(args);
cs.reserve(length); cs.reserve(length);
@@ -263,7 +258,6 @@ namespace Slime {
| | -> | <then> | | | -> | <then> |
| <if> | | <else> | | <if> | | <else> |
| .... | | ...... | */ | .... | | ...... | */
--ams.next_index;
Lisp_Object* args = pcs.data[--pcs.next_index]; Lisp_Object* args = pcs.data[--pcs.next_index];
Lisp_Object* test = args->value.pair.first; Lisp_Object* test = args->value.pair.first;
args = args->value.pair.rest; args = args->value.pair.rest;
@@ -274,7 +268,7 @@ namespace Slime {
Lisp_Object* alternative = args->value.pair.first; Lisp_Object* alternative = args->value.pair.first;
args = args->value.pair.rest; args = args->value.pair.rest;
try_void assert_type(args, Lisp_Object_Type::Nil); try_void assert_type(args, Lisp_Object_Type::Nil);
--cs.next_index;
cs.append(alternative); cs.append(alternative);
cs.append(consequence); cs.append(consequence);
cs.append(test); cs.append(test);
@@ -292,8 +286,7 @@ namespace Slime {
// and a NasAction. // and a NasAction.
profile_with_name("(define)"); profile_with_name("(define)");
using namespace Globals::Current_Execution; using namespace Globals::Current_Execution;
--cs.next_index;
--ams.next_index;

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;


+ 2
- 0
src/eval.cpp View File

@@ -395,6 +395,8 @@ namespace Slime {
case Lisp_Object_Type::Function: { case Lisp_Object_Type::Function: {
if(pc->value.function->is_c) { if(pc->value.function->is_c) {
if (pc->value.function->type.c_function_type == C_Function_Type::cMacro) { 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(); try pc->value.function->body.c_macro_body();
} else if (pc->value.function->type.c_function_type == C_Function_Type::cSpecial) } else if (pc->value.function->type.c_function_type == C_Function_Type::cSpecial)
{ {


Loading…
Cancel
Save