/
krasninja
/
querycat
Обзор
Документация
Войти
/
krasninja
/
querycat
Код
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
src/QueryCat.Backend/Ast/Nodes/SpecialFunctions/CastFunctionNode.cs
46 строк
1 KB
Ivan Kozhin
Add more strings to resources
26 фев 2024, 08:26
26 фев 2024, 08:26
802806b
Код
Авторство
О чём код?
using QueryCat.Backend.Core; using QueryCat.Backend.Core.Types; namespace QueryCat.Backend.Ast.Nodes.SpecialFunctions; internal sealed class CastFunctionNode : ExpressionNode { public ExpressionNode ExpressionNode { get; } public TypeNode TargetTypeNode { get; } /// <inheritdoc /> public override string Code => "cast"; /// <inheritdoc /> public CastFunctionNode(ExpressionNode expressionNode, TypeNode targetTypeNode) { if (targetTypeNode.Type == DataType.Void) { throw new SemanticException(Resources.Errors.CannotCastToVoid); } ExpressionNode = expressionNode; TargetTypeNode = targetTypeNode; } public CastFunctionNode(CastFunctionNode node) : this( (ExpressionNode)node.ExpressionNode.Clone(), (TypeNode)node.TargetTypeNode.Clone()) { node.CopyTo(this); } /// <inheritdoc /> public override IEnumerable<IAstNode> GetChildren() { yield return ExpressionNode; } /// <inheritdoc /> public override object Clone() => new CastFunctionNode(this); /// <inheritdoc /> public override void Accept(AstVisitor visitor) => visitor.Visit(this); /// <inheritdoc /> public override string ToString() => $"Cast {ExpressionNode} As {TargetTypeNode}"; }