@@ -12301,22 +12301,43 @@ void Emit(ParseNode* pnode, ByteCodeGenerator* byteCodeGenerator, FuncInfo* func
12301
12301
byteCodeGenerator->StartStatement (pnode);
12302
12302
funcInfo->AcquireLoc (pnode);
12303
12303
ParseNodeInternalCommand* command = pnode->AsParseNodeInternalCommand ();
12304
- ParseNode* params = command->params ;
12305
- // ParseNode* param1 = params->AsParseNodeBin()->pnode1;
12306
- Emit (params, byteCodeGenerator, funcInfo, false );
12304
+
12305
+ Js::OpCode opcode = Js::OpCode::Nop;
12306
+ uint32 expectedParams = 0 ;
12307
+
12308
+ #define Command (name, params ) \
12309
+ case InternalCommandType::##name: \
12310
+ opcode = Js::OpCode::##name; \
12311
+ expectedParams = params; \
12312
+ break ;
12307
12313
12308
12314
switch (command->commandType )
12309
12315
{
12310
- case InternalCommandType::Conv_Num:
12311
- byteCodeGenerator->Writer ()->Reg2 (Js::OpCode::Conv_Num, pnode->location , params->location );
12316
+ #include " InternalCommands.h"
12317
+ default :
12318
+ AssertOrFailFast (0 );
12319
+ }
12320
+
12321
+ ParseNode* params = command->params ;
12322
+ switch (expectedParams)
12323
+ {
12324
+ case 1 :
12325
+ Emit (params, byteCodeGenerator, funcInfo, false );
12326
+ byteCodeGenerator->Writer ()->Reg2 (opcode, pnode->location , params->location );
12312
12327
break ;
12313
- case InternalCommandType::Conv_Obj:
12314
- byteCodeGenerator->Writer ()->Reg2 (Js::OpCode::Conv_Obj, pnode->location , params->location );
12328
+ case 2 :
12329
+ {
12330
+ ParseNode* param1 = params->AsParseNodeBin ()->pnode1 ;
12331
+ ParseNode* param2 = params->AsParseNodeBin ()->pnode2 ;
12332
+ Emit (param1, byteCodeGenerator, funcInfo, false );
12333
+ Emit (param2, byteCodeGenerator, funcInfo, false );
12334
+ byteCodeGenerator->Writer ()->Reg3 (opcode, pnode->location , param1->location , param2->location );
12315
12335
break ;
12316
-
12336
+ }
12317
12337
default :
12318
- AssertOrFailFast (0 );
12338
+ AssertOrFailFast (0 ); // currently only support Internal Commands with 1 or 2 parameters
12319
12339
}
12340
+
12320
12341
funcInfo->ReleaseLoc (params);
12321
12342
byteCodeGenerator->EndStatement (pnode);
12322
12343
break ;
0 commit comments