Skip to content

Commit f0d0bf6

Browse files
author
drizzle9
committed
[feat] COPYRESTARG: Improve support
1 parent b937b35 commit f0d0bf6

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

astgen.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class AstGen : public compiler::Optimization, public compiler::GraphVisitor {
8181
panda::es2panda::ir::ScriptFunctionFlags flags_ {panda::es2panda::ir::ScriptFunctionFlags::NONE};
8282
auto funcNode = parser_program->Allocator()->New<panda::es2panda::ir::ScriptFunction>(nullptr, std::move(arguments), nullptr, body, nullptr, flags_, true, false);
8383

84+
this->scriptfunc = funcNode;
8485

8586
(*this->method2scriptfunast_)[methodoffset] = funcNode;
8687

@@ -925,6 +926,8 @@ class AstGen : public compiler::Optimization, public compiler::GraphVisitor {
925926

926927
panda::es2panda::ir::Expression* suspendobj = nullptr;
927928

929+
panda::es2panda::ir::ScriptFunction* scriptfunc = nullptr;
930+
928931

929932
panda::es2panda::ir::BooleanLiteral* constant_true = AllocNode<panda::es2panda::ir::BooleanLiteral>(this, true);
930933
panda::es2panda::ir::BooleanLiteral* constant_false = AllocNode<panda::es2panda::ir::BooleanLiteral>(this, false);

astgen_ecma.inl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,15 @@ void panda::bytecodeopt::AstGen::VisitEcma(panda::compiler::GraphVisitor *visito
118118
case compiler::RuntimeInterface::IntrinsicId::COPYRESTARGS_IMM8:
119119
case compiler::RuntimeInterface::IntrinsicId::WIDE_COPYRESTARGS_PREF_IMM16:
120120
{
121-
enc->HandleNewCreatedExpression(inst, enc->constant_restargs);
121+
auto argi = static_cast<uint32_t>(inst->GetImms()[0]);
122+
auto arg = enc->getParameterName(argi + 3);
123+
enc->HandleNewCreatedExpression(inst, arg);
124+
125+
auto& params = (*enc->method2scriptfunast_)[enc->methodoffset_]->Params();
126+
params.pop_back();
127+
128+
params.push_back( AllocNode<es2panda::ir::SpreadElement>(enc, es2panda::ir::AstNodeType::SPREAD_ELEMENT, arg) );
129+
122130
break;
123131
}
124132

0 commit comments

Comments
 (0)