Files
carbon-lang/executable_semantics/interpreter/action.h
T
Dave Abrahams dd4e37e761 const-ify Value*s in preparation for value semantic transformation (#409)
Making Values const allows us to separate the actual mutations (search for "*&" in this change) from places where the Value is effectively passed by-value.
2021-03-21 09:00:00 -07:00

51 lines
1.5 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_ACTION_H_
#define EXECUTABLE_SEMANTICS_INTERPRETER_ACTION_H_
#include <iostream>
#include <vector>
#include "executable_semantics/ast/expression.h"
#include "executable_semantics/ast/statement.h"
#include "executable_semantics/interpreter/stack.h"
#include "executable_semantics/interpreter/value.h"
namespace Carbon {
enum class ActionKind {
LValAction,
ExpressionAction,
StatementAction,
ValAction,
ExpToLValAction,
DeleteTmpAction
};
struct Action {
ActionKind tag;
union {
Expression* exp; // for LValAction and ExpressionAction
Statement* stmt;
const Value* val; // for finished actions with a value (ValAction)
Address delete_tmp;
} u;
int pos; // position or state of the action
std::vector<const Value*> results; // results from subexpression
};
void PrintAct(Action* act, std::ostream& out);
void PrintActList(Stack<Action*> ls, std::ostream& out);
auto MakeExpAct(Expression* e) -> Action*;
auto MakeLvalAct(Expression* e) -> Action*;
auto MakeStmtAct(Statement* s) -> Action*;
auto MakeValAct(const Value* v) -> Action*;
auto MakeExpToLvalAct() -> Action*;
auto MakeDeleteAct(Address a) -> Action*;
} // namespace Carbon
#endif // EXECUTABLE_SEMANTICS_INTERPRETER_ACTION_H_