Switch allocation of FunctionDefinition to use Ptr (#785)

This commit is contained in:
Jon Meow
2021-08-26 09:33:29 -07:00
committed by GitHub
parent 8b8715e871
commit 5b18f24db0
4 changed files with 11 additions and 10 deletions
+5 -5
View File
@@ -95,8 +95,8 @@ void Carbon::Parser::error(const location_type&, const std::string& message) {
%token <std::string> string_literal
%type <std::string> designator
%type <BisonWrap<Ptr<const Declaration>>> declaration
%type <const FunctionDefinition*> function_declaration
%type <const FunctionDefinition*> function_definition
%type <BisonWrap<Ptr<const FunctionDefinition>>> function_declaration
%type <BisonWrap<Ptr<const FunctionDefinition>>> function_definition
%type <std::list<Ptr<const Declaration>>> declaration_list
%type <const Statement*> statement
%type <const Statement*> if_statement
@@ -511,7 +511,7 @@ deduced_params:
function_definition:
FN identifier deduced_params maybe_empty_tuple_pattern return_type block
{
$$ = global_arena->RawNew<FunctionDefinition>(
$$ = global_arena->New<FunctionDefinition>(
yylineno, $2, $3, $4,
global_arena->RawNew<ExpressionPattern>($5.first),
$5.second, $6);
@@ -520,7 +520,7 @@ function_definition:
{
// The return type is not considered "omitted" because it's automatic from
// the expression.
$$ = global_arena->RawNew<FunctionDefinition>(
$$ = global_arena->New<FunctionDefinition>(
yylineno, $2, $3, $4,
global_arena->RawNew<AutoPattern>(yylineno), true,
global_arena->RawNew<Return>(yylineno, $6, true));
@@ -529,7 +529,7 @@ function_definition:
function_declaration:
FN identifier deduced_params maybe_empty_tuple_pattern return_type ";"
{
$$ = global_arena->RawNew<FunctionDefinition>(
$$ = global_arena->New<FunctionDefinition>(
yylineno, $2, $3, $4,
global_arena->RawNew<ExpressionPattern>($5.first),
$5.second, nullptr); }
@@ -27,7 +27,7 @@ static void AddIntrinsics(std::list<Ptr<const Declaration>>* fs) {
IntrinsicExpression::IntrinsicKind::Print),
false);
auto print = global_arena->New<FunctionDeclaration>(
global_arena->RawNew<FunctionDefinition>(
global_arena->New<FunctionDefinition>(
-1, "Print", std::vector<GenericBinding>(),
global_arena->RawNew<TuplePattern>(-1, print_fields),
global_arena->RawNew<ExpressionPattern>(