interpreter.h 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_EXPLORER_INTERPRETER_INTERPRETER_H_
  5. #define CARBON_EXPLORER_INTERPRETER_INTERPRETER_H_
  6. #include "common/ostream.h"
  7. #include "explorer/ast/ast.h"
  8. #include "explorer/ast/expression.h"
  9. #include "explorer/ast/value.h"
  10. #include "explorer/base/trace_stream.h"
  11. namespace Carbon {
  12. // Interprets the program defined by `ast`, allocating values on `arena` and
  13. // printing traces if `trace` is true.
  14. auto InterpProgram(const AST& ast, Nonnull<Arena*> arena,
  15. Nonnull<TraceStream*> trace_stream,
  16. Nonnull<llvm::raw_ostream*> print_stream) -> ErrorOr<int>;
  17. // Interprets `e` at compile-time, allocating values on `arena` and
  18. // printing traces if `trace` is true. The caller must ensure that all the
  19. // code this evaluates has been typechecked.
  20. auto InterpExp(Nonnull<const Expression*> e, Nonnull<Arena*> arena,
  21. Nonnull<TraceStream*> trace_stream,
  22. Nonnull<llvm::raw_ostream*> print_stream)
  23. -> ErrorOr<Nonnull<const Value*>>;
  24. } // namespace Carbon
  25. #endif // CARBON_EXPLORER_INTERPRETER_INTERPRETER_H_