Remove global_arena (#814)

With this, only main.cpp instantiates an arena. Maybe we'll want to split that up more later (e.g., so that the runtime interpreter uses its own arena), but given the intent to have type-checking update the AST, I thought this was a reasonable approach for now in order to avoid ownership complexities.

Fixes #769
This commit is contained in:
Jon Meow
2021-09-09 11:00:57 -07:00
committed by GitHub
parent 3610325c38
commit 90f04700e2
27 changed files with 568 additions and 581 deletions
@@ -17,8 +17,8 @@ namespace Carbon {
class ParseAndLexContext {
public:
// Creates an instance analyzing the given input file.
ParseAndLexContext(const std::string& input_file)
: input_file_name(global_arena->New<std::string>(input_file)) {}
ParseAndLexContext(Ptr<const std::string> input_file_name)
: input_file_name(input_file_name) {}
// Writes a syntax error diagnostic containing message to standard error.
auto PrintDiagnostic(const std::string& message) -> void;
@@ -40,8 +40,9 @@ class ParseAndLexContext {
} // namespace Carbon
// Gives flex the yylex prototype we want.
#define YY_DECL \
Carbon::Parser::symbol_type yylex(yyscan_t yyscanner, \
#define YY_DECL \
Carbon::Parser::symbol_type yylex(Carbon::Ptr<Carbon::Arena> arena, \
yyscan_t yyscanner, \
Carbon::ParseAndLexContext& context)
// Declares yylex for the parser's sake.