using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ShintenScript { public class ASTNodeLiteral : IASTNode { public readonly object value; public ASTNodeLiteral(object value) { this.value = value; } public bool Const() => true; public object CreateFunction() { SSType type = Type(); if (type == SSType.none) return (Action)(ctx => { }); if (type == SSType.boolean) return (bool)value ? (Func)(ctx => true) : ctx => false; if (type == SSType.real) { float real = (float)value; return (Func)(ctx => real); } throw new Exception("This should be unreachable"); } public SSType Type() { if (value == null) return SSType.none; if (value is bool) return SSType.boolean; if (value is float) return SSType.real; throw new Exception("This should be unreachable"); } } }