periodic checkpoint
This commit is contained in:
parent
b1e9e58783
commit
e458cdd910
2 changed files with 38 additions and 6 deletions
31
src/stdlib/functions/FunctionBase.cs
Normal file
31
src/stdlib/functions/FunctionBase.cs
Normal file
|
@ -0,0 +1,31 @@
|
|||
using csmic;
|
||||
using ValueType = csmic.ValueType;
|
||||
|
||||
namespace stdlib.functions
|
||||
{
|
||||
public abstract class FunctionBase
|
||||
{
|
||||
public virtual IEnumerable<FunctionArgument> ExpectedArguments { get; }
|
||||
|
||||
internal bool ArgumentCheck(params FunctionArgument[] args)
|
||||
{
|
||||
if (args == null || args.Length != this.ExpectedArguments.Count())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var expectedArgumentsArray = this.ExpectedArguments.ToArray();
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
{
|
||||
var expectedArgument = expectedArgumentsArray[i];
|
||||
var argument = args[i];
|
||||
if(argument.Value == null || argument.Value.Type != expectedArgument.Value.Type)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue