From 380d445e57597e6c5d10e001d47fc22c00414850 Mon Sep 17 00:00:00 2001 From: Kemal Ardian Date: Sun, 22 Sep 2024 01:20:13 +0700 Subject: [PATCH 1/3] Add virtual to ValFunction.BindAndCopy --- MiniScript-cs/MiniscriptTypes.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/MiniScript-cs/MiniscriptTypes.cs b/MiniScript-cs/MiniscriptTypes.cs index 4de18cf..d77c824 100644 --- a/MiniScript-cs/MiniscriptTypes.cs +++ b/MiniScript-cs/MiniscriptTypes.cs @@ -1037,7 +1037,7 @@ public ValFunction(Function function) { } public ValFunction(Function function, ValMap outerVars) { this.function = function; - this.outerVars = outerVars; + this.outerVars = outerVars; } public override string ToString(TAC.Machine vm) { @@ -1065,9 +1065,9 @@ public override double Equality(Value rhs) { return function == other.function ? 1 : 0; } - public ValFunction BindAndCopy(ValMap contextVariables) { - return new ValFunction(function, contextVariables); - } + public virtual ValFunction BindAndCopy(ValMap contextVariables) { + return new ValFunction(function, contextVariables); + } } From e7132a3fae044a51784e7a648885200b7eec06de Mon Sep 17 00:00:00 2001 From: Kemal Ardian Date: Sun, 22 Sep 2024 01:58:43 +0700 Subject: [PATCH 2/3] set nextContext.outerVars to func.outerVars in ManuallyPushCall --- MiniScript-cs/MiniscriptTAC.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/MiniScript-cs/MiniscriptTAC.cs b/MiniScript-cs/MiniscriptTAC.cs index 300c1b2..267dff3 100644 --- a/MiniScript-cs/MiniscriptTAC.cs +++ b/MiniScript-cs/MiniscriptTAC.cs @@ -992,6 +992,7 @@ public void ManuallyPushCall(ValFunction func, Value resultStorage=null, List Date: Wed, 25 Sep 2024 21:56:40 +0700 Subject: [PATCH 3/3] check temps size before get the index --- MiniScript-cs/MiniscriptTAC.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MiniScript-cs/MiniscriptTAC.cs b/MiniScript-cs/MiniscriptTAC.cs index 267dff3..cc4c274 100644 --- a/MiniScript-cs/MiniscriptTAC.cs +++ b/MiniScript-cs/MiniscriptTAC.cs @@ -623,7 +623,7 @@ public void SetTemp(int tempNum, Value value) { } public Value GetTemp(int tempNum) { - return temps == null ? null : temps[tempNum]; + return temps == null || temps.Count <= tempNum ? null : temps[tempNum]; } public Value GetTemp(int tempNum, Value defaultValue) {