Skip to content

Commit 9eb560e

Browse files
committed
Merge branch 'main' into dev
2 parents 6f5a202 + 2f73546 commit 9eb560e

File tree

199 files changed

+674
-254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+674
-254
lines changed

Code/ArgumentSystem/Arguments/ValueArgument.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ public DynamicTryGet<T> GetConvertSolution(BaseToken token)
1919
return $"Value '{token.RawRep}' cannot represent {InputDescription}";
2020
}
2121

22-
return new(() => get());
22+
return new(get);
2323
}
2424
}

Code/ArgumentSystem/ProvidedArguments.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using LabApi.Features.Wrappers;
22
using SER.Code.ArgumentSystem.Arguments;
3+
using SER.Code.ArgumentSystem.BaseArguments;
34
using SER.Code.ArgumentSystem.Structures;
45
using SER.Code.FileSystem.Structures;
56
using SER.Code.Helpers;
@@ -194,12 +195,12 @@ public CollectionVariable GetCollectionVariable(string argName)
194195
/// Retrieves a list of remaining arguments based on the specified argument name.
195196
/// The method resolves provided arguments into a typed list of values.
196197
/// </summary>
197-
public TValue[] GetRemainingArguments<TValue, TArg>(string argName)
198+
public TValue[] GetRemainingArguments<TValue, TArg>(string argName) where TArg : Argument
198199
{
199200
return GetEvaluators<TValue, TArg>(argName).Select(dtg => dtg.Invoke().Value!).ToArray();
200201
}
201202

202-
public TValue GetValue<TValue, TArg>(string argName)
203+
public TValue GetValue<TValue, TArg>(string argName) where TArg : Argument
203204
{
204205
return GetEvaluators<TValue, TArg>(argName).First().Invoke().Value!;
205206
}
@@ -244,7 +245,7 @@ private List<DynamicTryGet> GetValueInternal<TValue, TArg>(string argName)
244245

245246
if (foundArg.DefaultValue is null)
246247
{
247-
throw new CustomScriptRuntimeError($"{method} is missing a required argument '{argName}'.");
248+
throw new ScriptRuntimeError(method, $"Method is missing a required argument '{argName}'.");
248249
}
249250

250251
return foundArg.DefaultValue.Value switch

Code/ContextSystem/Contexts/Control/ElifStatementContext.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using SER.Code.Helpers.Extensions;
88
using SER.Code.Helpers.ResultSystem;
99
using SER.Code.TokenSystem.Tokens;
10-
using UnityEngine;
1110

1211
namespace SER.Code.ContextSystem.Contexts.Control;
1312

Code/ContextSystem/Contexts/MethodContext.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77
using SER.Code.Helpers.Extensions;
88
using SER.Code.Helpers.ResultSystem;
99
using SER.Code.MethodSystem.BaseMethods;
10+
using SER.Code.MethodSystem.BaseMethods.Interfaces;
11+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
12+
using SER.Code.MethodSystem.BaseMethods.Yielding;
1013
using SER.Code.Plugin;
1114
using SER.Code.TokenSystem.Tokens;
1215
using SER.Code.ValueSystem;
1316
using MethodToken = SER.Code.TokenSystem.Tokens.MethodToken;
17+
using ReturningMethod = SER.Code.MethodSystem.BaseMethods.Synchronous.ReturningMethod;
1418

1519
namespace SER.Code.ContextSystem.Contexts;
1620

@@ -20,7 +24,7 @@ public class MethodContext(MethodToken methodToken) : YieldingContext, IMayRetur
2024
public readonly MethodArgumentDispatcher Dispatcher = new(methodToken.Method);
2125
private int _providedArguments = 0;
2226

23-
public TypeOfValue? Returns => Method is ReturningMethod returningMethod
27+
public TypeOfValue? Returns => Method is IReturningMethod returningMethod
2428
? returningMethod.Returns
2529
: null;
2630

@@ -78,7 +82,7 @@ protected override IEnumerator<float> Execute()
7882
break;
7983
}
8084

81-
ReturnedValue = Method is ReturningMethod returningMethod
85+
ReturnedValue = Method is IReturningMethod returningMethod
8286
? returningMethod.ReturnValue
8387
: null;
8488
}

Code/ContextSystem/Contexts/VariableDefinition/LiteralVariableDefinitionContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public LiteralVariableDefinitionContext(VariableToken<LiteralVariable, LiteralVa
1414
{
1515
if (token is TextToken textToken)
1616
{
17-
return () => new TextValue(textToken.ParsedValue());
17+
return () => textToken.Value;
1818
}
1919

2020
return null;

Code/Examples/Example.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using Cassie.Interpreters;
32
using JetBrains.Annotations;
43
using SER.Code.Helpers.ResultSystem;
54
using SER.Code.ScriptSystem;

Code/Helpers/Extensions/SerExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ public static bool CanReturn<T>(this IValueToken valToken, out Func<TryGet<T>> g
4848
{
4949
get = valToken.TryGet<T>;
5050

51+
// if unknown, its always assumed that it may return T
5152
if (!valToken.PossibleValues.AreKnown(out var knownReturnTypes)) return true;
53+
54+
// if any of known types is assignable to T, or T to type, then it may return T
5255
return knownReturnTypes.Any(type => typeof(T).IsAssignableFrom(type) || type.IsAssignableFrom(typeof(T)));
5356
}
5457

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
namespace SER.Code.MethodSystem.BaseMethods.Interfaces;
2+
3+
public interface IReferenceReturningMethod
4+
{
5+
public Type ReturnType { get; }
6+
}
7+
8+
public interface IReferenceReturningMethod<out T> : IReferenceReturningMethod
9+
{
10+
public new T ReturnType { get; }
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using SER.Code.ValueSystem;
2+
3+
namespace SER.Code.MethodSystem.BaseMethods.Interfaces;
4+
5+
public interface IReturningMethod
6+
{
7+
public Value? ReturnValue { get; }
8+
public abstract TypeOfValue Returns { get; }
9+
}
10+
11+
public interface IReturningMethod<out T> : IReturningMethod where T : Value
12+
{
13+
public new T ReturnValue { get; }
14+
}

Code/MethodSystem/BaseMethods/Method.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using SER.Code.Helpers;
55
using SER.Code.Helpers.Exceptions;
66
using SER.Code.Helpers.Extensions;
7+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
8+
using SER.Code.MethodSystem.BaseMethods.Yielding;
79
using SER.Code.ScriptSystem;
810

911
namespace SER.Code.MethodSystem.BaseMethods;

0 commit comments

Comments
 (0)