mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 09:21:04 +01:00
Executable Semantics: 1st-class stacks (#296)
Replaces low-level uses of `Cons` with a first-class `Stack` data structure. Also removes an unused algorithm. Co-authored-by: Jeremy Siek <jsiek@indiana.edu> Possible next step: use `std::stack` instead.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include "executable_semantics/ast/expression.h"
|
||||
#include "executable_semantics/ast/function_definition.h"
|
||||
#include "executable_semantics/interpreter/interpreter.h"
|
||||
#include "executable_semantics/interpreter/stack.h"
|
||||
#include "executable_semantics/interpreter/typecheck.h"
|
||||
|
||||
namespace Carbon {
|
||||
@@ -48,12 +49,12 @@ void PrintAct(Action* act, std::ostream& out) {
|
||||
}
|
||||
}
|
||||
|
||||
void PrintActList(Cons<Action*>* ls, std::ostream& out) {
|
||||
if (ls) {
|
||||
PrintAct(ls->curr, out);
|
||||
if (ls->next) {
|
||||
void PrintActList(Stack<Action*> ls, std::ostream& out) {
|
||||
if (!ls.IsEmpty()) {
|
||||
PrintAct(ls.Pop(), out);
|
||||
if (!ls.IsEmpty()) {
|
||||
out << " :: ";
|
||||
PrintActList(ls->next, out);
|
||||
PrintActList(ls, out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user