38 lines
861 B
C#
38 lines
861 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ShintenScript
|
|
{
|
|
public class ASTNodeNegative : IASTNode
|
|
{
|
|
public IASTNode node;
|
|
|
|
public ASTNodeNegative(IASTNode of)
|
|
{
|
|
node = of;
|
|
}
|
|
|
|
public bool Const()
|
|
{
|
|
return node.Const();
|
|
}
|
|
|
|
public object CreateFunction()
|
|
{
|
|
Func<ExecutionContext, float> func = (Func<ExecutionContext, float>)node.CreateFunction();
|
|
return (Func<ExecutionContext, float>)(ctx => -func(ctx));
|
|
}
|
|
|
|
public SSType Type()
|
|
{
|
|
if (node.Type() != SSType.real)
|
|
throw new TypeException($"Unary '-' operator not supported for {node.Type()}");
|
|
|
|
return SSType.real;
|
|
}
|
|
}
|
|
}
|