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
+5 -4
View File
@@ -111,7 +111,7 @@ class TuplePattern : public Pattern {
// ExpressionPattern.
//
// REQUIRES: tuple_literal->Tag() == Expression::Kind::TupleLiteral
explicit TuplePattern(Ptr<const Expression> tuple_literal);
TuplePattern(Ptr<Arena> arena, Ptr<const Expression> tuple_literal);
static auto classof(const Pattern* pattern) -> bool {
return pattern->Tag() == Kind::TuplePattern;
@@ -126,19 +126,20 @@ class TuplePattern : public Pattern {
// Converts paren_contents to a Pattern, interpreting the parentheses as
// grouping if their contents permit that interpretation, or as forming a
// tuple otherwise.
auto PatternFromParenContents(SourceLocation loc,
auto PatternFromParenContents(Ptr<Arena> arena, SourceLocation loc,
const ParenContents<Pattern>& paren_contents)
-> Ptr<const Pattern>;
// Converts paren_contents to a TuplePattern, interpreting the parentheses as
// forming a tuple.
auto TuplePatternFromParenContents(SourceLocation loc,
auto TuplePatternFromParenContents(Ptr<Arena> arena, SourceLocation loc,
const ParenContents<Pattern>& paren_contents)
-> Ptr<const TuplePattern>;
// Converts `contents` to ParenContents<Pattern> by replacing each Expression
// with an ExpressionPattern.
auto ParenExpressionToParenPattern(const ParenContents<Expression>& contents)
auto ParenExpressionToParenPattern(Ptr<Arena> arena,
const ParenContents<Expression>& contents)
-> ParenContents<Pattern>;
// A pattern that matches an alternative of a choice type.