Browse Source

some more wrk towards nrc eval

master
Felix Brendel 6 years ago
parent
commit
dfde24e1b2
2 changed files with 42 additions and 41 deletions
  1. +25
    -25
      build.sh
  2. +17
    -16
      src/eval.cpp

+ 25
- 25
build.sh View File

@@ -2,13 +2,13 @@ TIMEFORMAT=%3lU
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
pushd $SCRIPTPATH > /dev/null

# echo ""
# echo "----------------------"
# echo " compiling libslime "
# echo "----------------------"
# time clang++ --std=c++17 \
# src/libslime.cpp -c -o libslime.o \
# -I3rd/ || exit 1
echo ""
echo "----------------------"
echo " compiling libslime "
echo "----------------------"
time clang++ --std=c++17 \
src/libslime.cpp -c -o libslime.o \
-I3rd/ || exit 1

echo ""
echo "------------------------------"
@@ -18,15 +18,15 @@ time clang++ -D_DEBUG -D_DONT_BREAK_ON_ERRORS \
src/main.cpp -gfull -gdwarf -o ./bin/slime_d --std=c++17 \
-I3rd/ || exit 1

# echo ""
# echo "--------------------------------"
# echo " compiling fullslime (release) "
# echo "--------------------------------"
# time clang++ -D_DONT_BREAK_ON_ERRORS -O3 \
# src/main.cpp -g -o ./bin/slime --std=c++17 \
# -I3rd/ || exit 1
echo ""
echo "--------------------------------"
echo " compiling fullslime (release) "
echo "--------------------------------"
time clang++ -D_DONT_BREAK_ON_ERRORS -O3 \
src/main.cpp -g -o ./bin/slime --std=c++17 \
-I3rd/ || exit 1

# pushd ./bin > /dev/null
pushd ./bin > /dev/null

# echo ""
# echo "----------------------"
@@ -34,17 +34,17 @@ time clang++ -D_DEBUG -D_DONT_BREAK_ON_ERRORS \
# echo "----------------------"
# time valgrind -q ./slime_d --generate-docs || exit 1

# echo ""
# echo "----------------------"
# echo " running tests "
# echo "----------------------"
# time valgrind -q --track-origins=yes --leak-check=full --show-leak-kinds=all ./slime_d --run-tests || exit 1
echo ""
echo "----------------------"
echo " running tests "
echo "----------------------"
time valgrind -q --track-origins=yes --leak-check=full --show-leak-kinds=all ./slime_d --run-tests || exit 1

# echo ""
# echo "------------------------"
# echo " running benches "
# echo "------------------------"
# hyperfine -s color --warmup 5 "./slime --run-tests > /dev/null"
echo ""
echo "------------------------"
echo " running benches "
echo "------------------------"
hyperfine -s color --warmup 5 "./slime --run-tests > /dev/null"

popd > /dev/null
# popd > /dev/null


+ 17
- 16
src/eval.cpp View File

@@ -1,7 +1,9 @@
namespace Slime {

proc create_extended_environment_for_function_application_nrc(
Array_List<Lisp_Object*> cs,
// TODO(Felix): pass cs as value as soon as we got rid of
// destructors, to prevent destroying it on scope exit
Array_List<Lisp_Object*>* cs,
Lisp_Object* function,
int arg_start,
int arg_count) -> Environment*
@@ -45,7 +47,7 @@ namespace Slime {
int obligatory_keywords_count = 0;
int read_obligatory_keywords_count = 0;

Lisp_Object* next_arg = cs.data[arg_start];
Lisp_Object* next_arg = cs->data[arg_start];

proc read_positional_args = [&] {
for (int i = 0; i < arg_spec->positional.symbols.next_index; ++i) {
@@ -65,7 +67,7 @@ namespace Slime {
sym,
Memory::copy_lisp_object_except_pairs(next_arg));
}
next_arg = cs[++arg_start];
next_arg = cs->data[++arg_start];
--arg_count;
}
};
@@ -142,7 +144,7 @@ namespace Slime {

// if not set it and then add it to the array list
try_void sym = Memory::get_symbol(next_arg->value.symbol);
next_arg = cs[++arg_start];
next_arg = cs->data[++arg_start];
--arg_count;
// NOTE(Felix): It seems we do not need to evaluate the argument here...
if (is_c_function) {
@@ -157,7 +159,7 @@ namespace Slime {
++read_obligatory_keywords_count;

// overstep both for next one
next_arg = cs[++arg_start];
next_arg = cs->data[++arg_start];
--arg_count;

if (arg_count == 0) {
@@ -213,12 +215,12 @@ namespace Slime {
Lisp_Object* list;
try_void list = Memory::create_list(next_arg);
Lisp_Object* head = list;
next_arg = cs[++arg_start];
next_arg = cs->data[++arg_start];
--arg_count;
while (arg_count > 0) {
try_void head->value.pair.rest = Memory::create_list(next_arg);
head = head->value.pair.rest;
next_arg = cs[++arg_start];
next_arg = cs->data[++arg_start];
--arg_count;
}
define_symbol(arg_spec->rest, list);
@@ -238,7 +240,6 @@ namespace Slime {
try read_rest_arg();

// TODO(Felix): fucking destructors
cs.data = nullptr;
return new_env;
}
proc create_extended_environment_for_function_application(
@@ -781,7 +782,6 @@ namespace Slime {
Lisp_Object* args = pcs[--pcs.next_index];
int length = list_length(args);
cs.reserve(length);
printf("aaaaaa\n\n");
for_lisp_list(args) {
cs.data[cs.next_index - 1 + (length - it_index)] = it;
nas.append(Action::Eval);
@@ -798,7 +798,7 @@ namespace Slime {
Action current_action;
Lisp_Object* pc;
while (nas.next_index > 0) {
debug_step();
// debug_step();

current_action = nas.data[--nas.next_index];
switch (current_action) {
@@ -871,7 +871,7 @@ namespace Slime {
Lisp_Object_Type type = Memory::get_type(function);
Environment* extended_env =
create_extended_environment_for_function_application_nrc(
cs, function, am+1, cs.next_index-am-1);
&cs, function, am+1, cs.next_index-am-1);
cs.next_index = am;
push_environment(extended_env);
if (type == Lisp_Object_Type::CFunction) {
@@ -914,12 +914,13 @@ namespace Slime {
}

}
debug_step();
// debug_step();

return cs.data[--cs.next_index];
}

proc eval_expr(Lisp_Object* node) -> Lisp_Object* {
return nrc_eval(node);
profile_this();

using namespace Globals::Current_Execution;
@@ -1020,12 +1021,12 @@ namespace Slime {
Lisp_Object* parsed, * evaluated;
while (true) {
[&] {
// delete_error();
delete_error();
fputs("> ", stdout);
line = read_expression();
// defer {
// free(line);
// };
defer {
free(line);
};
try_void parsed = Parser::parse_single_expression(line);
try_void evaluated = nrc_eval(parsed);
if (evaluated != Memory::nil) {


Loading…
Cancel
Save