@@ -8375,6 +8375,8 @@ void BytecodeGenerator::HandleFuncDecl(FuncDeclNode* func_decl) {
8375
8375
nullptr , return_value_reference_index));
8376
8376
args_index.push_back (return_value_reference_index);
8377
8377
8378
+ std::size_t va_array_index = 0 ;
8379
+
8378
8380
for (std::size_t i = 0 ; i < args.size (); i++) {
8379
8381
if (args[i]->GetType () == StmtNode::StmtType::kVarDecl ) {
8380
8382
args_index.push_back (
@@ -8387,7 +8389,8 @@ void BytecodeGenerator::HandleFuncDecl(FuncDeclNode* func_decl) {
8387
8389
" args is not VarDeclNode or ArrayDeclNode." );
8388
8390
}
8389
8391
if (i==args.size ()-1 && func_decl->GetStat ()->GetVaFlag ()){
8390
- args_index.push_back (global_memory_.Add (1 ));
8392
+ va_array_index = global_memory_.Add (1 );
8393
+ args_index.push_back (va_array_index);
8391
8394
}
8392
8395
}
8393
8396
@@ -8416,7 +8419,7 @@ void BytecodeGenerator::HandleFuncDecl(FuncDeclNode* func_decl) {
8416
8419
if (i == func_decl->GetStat ()->GetArgs ().size ()-1 && func_decl->GetStat ()->GetVaFlag ()){
8417
8420
var_decl_map_.emplace (current_scope_.back () + " #args" ,
8418
8421
std::pair<VarDeclNode*, std::size_t >(
8419
- NULL , global_memory_. Add ( 1 ) ));
8422
+ NULL , va_array_index ));
8420
8423
}
8421
8424
}
8422
8425
@@ -8542,6 +8545,8 @@ void BytecodeGenerator::HandleClassFuncDecl(FuncDeclNode* func_decl) {
8542
8545
nullptr , return_value_reference_index));
8543
8546
args_index.push_back (return_value_reference_index);
8544
8547
8548
+ std::size_t va_array_index = 0 ;
8549
+
8545
8550
for (std::size_t i = 0 ; i < args.size (); i++) {
8546
8551
if (args[i]->GetType () == StmtNode::StmtType::kVarDecl ) {
8547
8552
args_index.push_back (
@@ -8554,7 +8559,8 @@ void BytecodeGenerator::HandleClassFuncDecl(FuncDeclNode* func_decl) {
8554
8559
" args is not VarDeclNode or ArrayDeclNode." );
8555
8560
}
8556
8561
if (i == args.size ()-1 && func_decl->GetStat ()->GetVaFlag ()){
8557
- args_index.push_back (global_memory_.Add (1 ));
8562
+ va_array_index = global_memory_.Add (1 );
8563
+ args_index.push_back (va_array_index);
8558
8564
}
8559
8565
}
8560
8566
@@ -8584,7 +8590,7 @@ void BytecodeGenerator::HandleClassFuncDecl(FuncDeclNode* func_decl) {
8584
8590
var_decl_map_.emplace (
8585
8591
current_scope_.back () + " #args" ,
8586
8592
std::pair<VarDeclNode*, std::size_t >(
8587
- NULL , global_memory_. Add ( 1 ) ));
8593
+ NULL , va_array_index ));
8588
8594
}
8589
8595
}
8590
8596
@@ -8703,6 +8709,8 @@ void BytecodeGenerator::HandleClassConstructor(FuncDeclNode* func_decl) {
8703
8709
nullptr, return_value_reference_index));*/
8704
8710
args_index.push_back (return_value_index);
8705
8711
8712
+ std::size_t va_array_index = 0 ;
8713
+
8706
8714
for (std::size_t i = 0 ; i < args.size (); i++) {
8707
8715
if (args[i]->GetType () == StmtNode::StmtType::kVarDecl ) {
8708
8716
args_index.push_back (
@@ -8715,7 +8723,8 @@ void BytecodeGenerator::HandleClassConstructor(FuncDeclNode* func_decl) {
8715
8723
" args is not VarDeclNode or ArrayDeclNode." );
8716
8724
}
8717
8725
if (i==args.size ()-1 && func_decl->GetStat ()->GetVaFlag ()){
8718
- args_index.push_back (global_memory_.Add (1 ));
8726
+ va_array_index = global_memory_.Add (1 );
8727
+ args_index.push_back (va_array_index);
8719
8728
}
8720
8729
}
8721
8730
@@ -8745,7 +8754,7 @@ void BytecodeGenerator::HandleClassConstructor(FuncDeclNode* func_decl) {
8745
8754
var_decl_map_.emplace (
8746
8755
current_scope_.back () + " #args" ,
8747
8756
std::pair<VarDeclNode*, std::size_t >(
8748
- NULL , global_memory_. Add ( 1 ) ));
8757
+ NULL , va_array_index ));
8749
8758
}
8750
8759
}
8751
8760
0 commit comments