Files
carbon-lang/executable_semantics/interpreter/interpreter.h
T
Geoff RomerandJon Meow d5124256a2 Split interpreter into smaller modules (#662)
- Move Heap and Frame/Scope to their own headers.
- Move some functions to more appropriate headers (e.g. CopyValue -> value.h).
- Define a separate Bazel rule for each header/cpp pair.
- Modify PrintValue to not print the frames of a ContinuationValue. This was necessary to break a dependency cycle between PrintValue, PrintFrame, and Action::Print.

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
2021-07-19 13:51:35 -07:00

41 lines
1.1 KiB
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef EXECUTABLE_SEMANTICS_INTERPRETER_INTERPRETER_H_
#define EXECUTABLE_SEMANTICS_INTERPRETER_INTERPRETER_H_
#include <list>
#include <utility>
#include <vector>
#include "executable_semantics/ast/declaration.h"
#include "executable_semantics/interpreter/frame.h"
#include "executable_semantics/interpreter/heap.h"
#include "executable_semantics/interpreter/stack.h"
#include "executable_semantics/interpreter/value.h"
namespace Carbon {
using Env = Dictionary<std::string, Address>;
struct State {
Stack<Frame*> stack;
Heap heap;
};
extern State* state;
void InitEnv(const Declaration& d, Env* env);
void PrintStack(Stack<Frame*> ls, std::ostream& out);
void PrintEnv(Env values);
/***** Interpreters *****/
auto InterpProgram(std::list<Declaration>* fs) -> int;
auto InterpExp(Env values, const Expression* e) -> const Value*;
} // namespace Carbon
#endif // EXECUTABLE_SEMANTICS_INTERPRETER_INTERPRETER_H_