Switch InlineExpr from using IDPList* to vector<IDPtr>

This commit is contained in:
Jon Siwek 2020-12-13 15:04:53 -08:00
parent a0552f9771
commit c7bec09e14
3 changed files with 13 additions and 12 deletions

View file

@ -1135,7 +1135,7 @@ private:
class InlineExpr : public Expr { class InlineExpr : public Expr {
public: public:
InlineExpr(ListExprPtr arg_args, IDPList* params, StmtPtr body, InlineExpr(ListExprPtr arg_args, std::vector<IDPtr> params, StmtPtr body,
int frame_offset, TypePtr ret_type); int frame_offset, TypePtr ret_type);
bool IsPure() const override; bool IsPure() const override;
@ -1152,7 +1152,7 @@ public:
protected: protected:
void ExprDescribe(ODesc* d) const override; void ExprDescribe(ODesc* d) const override;
IDPList* params; std::vector<IDPtr> params;
int frame_offset; int frame_offset;
ListExprPtr args; ListExprPtr args;
StmtPtr body; StmtPtr body;

View file

@ -445,13 +445,13 @@ ExprPtr IsExpr::Duplicate()
} }
InlineExpr::InlineExpr(ListExprPtr arg_args, IDPList* arg_params, InlineExpr::InlineExpr(ListExprPtr arg_args, std::vector<IDPtr> arg_params,
StmtPtr arg_body, int _frame_offset, TypePtr ret_type) StmtPtr arg_body, int _frame_offset, TypePtr ret_type)
: Expr(EXPR_INLINE), args(std::move(arg_args)), body(std::move(arg_body)) : Expr(EXPR_INLINE), args(std::move(arg_args)), body(std::move(arg_body))
{ {
params = arg_params; params = std::move(arg_params);
frame_offset = _frame_offset; frame_offset = _frame_offset;
type = ret_type; type = std::move(ret_type);
} }
bool InlineExpr::IsPure() const bool InlineExpr::IsPure() const
@ -497,8 +497,7 @@ ExprPtr InlineExpr::Duplicate()
{ {
auto args_d = args->Duplicate()->AsListExprPtr(); auto args_d = args->Duplicate()->AsListExprPtr();
auto body_d = body->Duplicate(); auto body_d = body->Duplicate();
return SetSucc(new InlineExpr(args_d, params, body_d, frame_offset, return SetSucc(new InlineExpr(args_d, params, body_d, frame_offset, type));
type));
} }
TraversalCode InlineExpr::Traverse(TraversalCallback* cb) const TraversalCode InlineExpr::Traverse(TraversalCallback* cb) const

View file

@ -199,12 +199,14 @@ ExprPtr Inliner::CheckForInlining(IntrusivePtr<CallExpr> c)
// the function, *using the knowledge that the parameters are // the function, *using the knowledge that the parameters are
// declared first*. // declared first*.
auto scope = func_vf->GetScope(); auto scope = func_vf->GetScope();
auto vars = scope->OrderedVars(); auto& vars = scope->OrderedVars();
int nparam = func_vf->GetType()->Params()->NumFields(); int nparam = func_vf->GetType()->Params()->NumFields();
auto params = new IDPList; std::vector<IDPtr> params;
params.reserve(nparam);
for ( int i = 0; i < nparam; ++i ) for ( int i = 0; i < nparam; ++i )
params->append(vars[i].get()); params.emplace_back(vars[i]);
auto body_dup = body->Duplicate(); auto body_dup = body->Duplicate();
@ -229,8 +231,8 @@ ExprPtr Inliner::CheckForInlining(IntrusivePtr<CallExpr> c)
else else
max_inlined_frame_size = hold_max_inlined_frame_size; max_inlined_frame_size = hold_max_inlined_frame_size;
auto ie = make_intrusive<InlineExpr>(args, params, body_dup, auto ie = make_intrusive<InlineExpr>(args, std::move(params), body_dup,
curr_frame_size, t); curr_frame_size, t);
ie->SetOriginal(c); ie->SetOriginal(c);
return ie; return ie;