changed function_ingredients struct to FunctionIngredients class with accessors

This commit is contained in:
Vern Paxson 2023-04-02 11:34:16 -07:00
parent 5718046b96
commit 0c434ca4f8
11 changed files with 63 additions and 53 deletions

View file

@ -842,24 +842,25 @@ void end_func(StmtPtr body, const char* module_name, bool free_of_conditionals)
oi->num_stmts = Stmt::GetNumStmts();
oi->num_exprs = Expr::GetNumExprs();
auto ingredients = std::make_unique<function_ingredients>(pop_scope(), std::move(body),
module_name);
if ( ! ingredients->id->HasVal() )
auto ingredients = std::make_unique<FunctionIngredients>(pop_scope(), std::move(body),
module_name);
auto id = ingredients->GetID();
if ( ! id->HasVal() )
{
auto f = make_intrusive<ScriptFunc>(ingredients->id);
ingredients->id->SetVal(make_intrusive<FuncVal>(std::move(f)));
ingredients->id->SetConst();
auto f = make_intrusive<ScriptFunc>(id);
id->SetVal(make_intrusive<FuncVal>(std::move(f)));
id->SetConst();
}
ingredients->id->GetVal()->AsFunc()->AddBody(ingredients->body, ingredients->inits,
ingredients->frame_size, ingredients->priority,
ingredients->groups);
id->GetVal()->AsFunc()->AddBody(ingredients->Body(), ingredients->Inits(),
ingredients->FrameSize(), ingredients->Priority(),
ingredients->Groups());
auto func_ptr = cast_intrusive<FuncVal>(ingredients->id->GetVal())->AsFuncPtr();
auto func_ptr = cast_intrusive<FuncVal>(id->GetVal())->AsFuncPtr();
auto func = cast_intrusive<ScriptFunc>(func_ptr);
func->SetScope(ingredients->scope);
func->SetScope(ingredients->Scope());
for ( const auto& group : ingredients->groups )
for ( const auto& group : ingredients->Groups() )
group->AddFunc(func);
analyze_func(std::move(func));