From b7ad95446fe2201c896e3ef54dc64cce4aeea737 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 16 Sep 2009 02:53:05 +0000 Subject: [PATCH] - Fixed VMParamFiller to use proper A register tags. - Changed RET so that it will still work if the caller expects fewer return values. SVN r1843 (scripting) --- zscript/vm.h | 7 ++++--- zscript/vmexec.h | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/zscript/vm.h b/zscript/vm.h index 8a8b9e9f8..ee20d3ceb 100644 --- a/zscript/vm.h +++ b/zscript/vm.h @@ -104,6 +104,7 @@ enum ATAG_SREGISTER, // pointer to a string register ATAG_AREGISTER, // pointer to an address register + ATAG_STATE, // pointer to FState }; class VMFunction : public DObject @@ -758,14 +759,14 @@ public: void ParamObject(DObject *obj) { Reg.a[RegA] = obj; - Reg.atag[RegA] = true; + Reg.atag[RegA] = ATAG_OBJECT; RegA++; } - void ParamPointer(void *ptr) + void ParamPointer(void *ptr, VM_UBTYE atag) { Reg.a[RegA] = ptr; - Reg.atag[RegA] = false; + Reg.atag[RegA] = atag; RegA++; } diff --git a/zscript/vmexec.h b/zscript/vmexec.h index c0b268589..6bb2ae3eb 100644 --- a/zscript/vmexec.h +++ b/zscript/vmexec.h @@ -533,11 +533,14 @@ begin: { // No return values return 0; } - assert(a < numret); - SetReturn(reg, f, &ret[a], B, C); + assert(ret != NULL || numret == 0); + if (a < numret) + { + SetReturn(reg, f, &ret[a], B, C); + } if (B & REGT_FINAL) { - return a + 1; + return MIN(numret, a + 1); } NEXTOP; OP(RESULT):