mirror of
https://github.com/ValKmjolnir/Nasal-Interpreter.git
synced 2026-07-23 03:18:43 +08:00
fix dynamic para error
This commit is contained in:
+3
-3
@@ -106,13 +106,13 @@ struct nasal_hash// 56 bytes
|
||||
|
||||
struct nasal_func// 112 bytes
|
||||
{
|
||||
uint32_t dynpara; // dynamic parameter index in hash. index 0 is reserved for 'me'.
|
||||
int32_t dynpara; // dynamic parameter name index in hash.
|
||||
uint32_t entry; // pc will set to entry-1 to call this function
|
||||
std::vector<nasal_ref> local; // local scope with default value(nasal_ref)
|
||||
std::vector<nasal_ref> upvalue; // closure
|
||||
std::unordered_map<std::string,int> keys; // parameter name table
|
||||
|
||||
nasal_func():dynpara(0){}
|
||||
nasal_func():dynpara(-1){}
|
||||
void clear();
|
||||
};
|
||||
|
||||
@@ -265,7 +265,7 @@ void nasal_hash::print()
|
||||
/*functions of nasal_func*/
|
||||
void nasal_func::clear()
|
||||
{
|
||||
dynpara=0;
|
||||
dynpara=-1;
|
||||
local.clear();
|
||||
upvalue.clear();
|
||||
keys.clear();
|
||||
|
||||
+2
-2
@@ -665,7 +665,7 @@ inline void nasal_vm::opr_callfv()
|
||||
for(uint32_t i=0;i<min_size;++i)
|
||||
closure[i+1]=args[i];
|
||||
// load dynamic argument if args_size>=para_size
|
||||
if(func.dynpara)
|
||||
if(func.dynpara>=0)
|
||||
{
|
||||
nasal_ref vec=gc.alloc(vm_vec);
|
||||
for(uint32_t i=para_size;i<args_size;++i)
|
||||
@@ -690,7 +690,7 @@ inline void nasal_vm::opr_callfh()
|
||||
gc.local.back().vec()->elems=func.local;
|
||||
// load parameters
|
||||
auto& closure=gc.local.back().vec()->elems;
|
||||
if(func.dynpara)
|
||||
if(func.dynpara>=0)
|
||||
die("callfh: special call cannot use dynamic argument");
|
||||
|
||||
for(auto& i:func.keys)
|
||||
|
||||
Reference in New Issue
Block a user