Browse Source

Eval: Only need to cast AST once

master
Riyyi 2 years ago
parent
commit
c279f9111e
  1. 13
      src/eval.cpp

13
src/eval.cpp

@ -62,20 +62,17 @@ ValuePtr Eval::evalImpl()
return evalAst(ast, env); return evalAst(ast, env);
} }
auto list = std::static_pointer_cast<List>(ast);
if (list->empty()) {
return ast;
}
ast = macroExpand(ast, env); ast = macroExpand(ast, env);
if (!is<List>(ast.get())) { if (!is<List>(ast.get())) {
return evalAst(ast, env); return evalAst(ast, env);
} }
// Macro-expand modifies `ast', so get the new list auto list = std::static_pointer_cast<List>(ast);
list = std::static_pointer_cast<List>(ast);
if (list->empty()) {
return ast;
}
// Special forms // Special forms
auto nodes = list->nodes(); auto nodes = list->nodes();

Loading…
Cancel
Save