summaryrefslogtreecommitdiffstats
path: root/yql/essentials/ast/yql_expr.cpp
diff options
context:
space:
mode:
authorvvvv <[email protected]>2025-09-18 12:35:25 +0300
committervvvv <[email protected]>2025-09-18 12:48:14 +0300
commitf5a6d6cdfb9d7c44659f134a53c2fa273ec85599 (patch)
tree5cc206b17db5fa8f976ea922c997095a1d133687 /yql/essentials/ast/yql_expr.cpp
parente2dc5e15bc02bff63e44ed9c74ff1093d87d845b (diff)
YQL-20339 expr types & reflection
init commit_hash:1c72053b3785a26cfde418f28a9d054b5a624627
Diffstat (limited to 'yql/essentials/ast/yql_expr.cpp')
-rw-r--r--yql/essentials/ast/yql_expr.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/yql/essentials/ast/yql_expr.cpp b/yql/essentials/ast/yql_expr.cpp
index 25a888be53f..1ecb5191e77 100644
--- a/yql/essentials/ast/yql_expr.cpp
+++ b/yql/essentials/ast/yql_expr.cpp
@@ -606,6 +606,28 @@ namespace {
return nullptr;
return Expr.MakeType<TScalarExprType>(r);
+ } else if (content == TStringBuf("Linear")) {
+ if (node.GetChildrenCount() != 2) {
+ AddError(node, "Bad linear type annotation");
+ return nullptr;
+ }
+
+ auto r = CompileTypeAnnotationNode(*node.GetChild(1));
+ if (!r)
+ return nullptr;
+
+ return Expr.MakeType<TLinearExprType>(r);
+ } else if (content == TStringBuf("DynamicLinear")) {
+ if (node.GetChildrenCount() != 2) {
+ AddError(node, "Bad dynamic linear type annotation");
+ return nullptr;
+ }
+
+ auto r = CompileTypeAnnotationNode(*node.GetChild(1));
+ if (!r)
+ return nullptr;
+
+ return Expr.MakeType<TDynamicLinearExprType>(r);
} else {
AddError(node, TStringBuilder() << "Unknown type annotation");
return nullptr;
@@ -870,6 +892,22 @@ namespace {
return TAstNode::NewList(TPosition(), pool, self, itemType);
}
+ case ETypeAnnotationKind::Linear:
+ {
+ auto type = annotation.Cast<TLinearExprType>();
+ auto self = TAstNode::NewLiteralAtom(TPosition(), TStringBuf("Linear"), pool);
+ auto itemType = ConvertTypeAnnotationToAst(*type->GetItemType(), pool, refAtoms);
+ return TAstNode::NewList(TPosition(), pool, self, itemType);
+ }
+
+ case ETypeAnnotationKind::DynamicLinear:
+ {
+ auto type = annotation.Cast<TDynamicLinearExprType>();
+ auto self = TAstNode::NewLiteralAtom(TPosition(), TStringBuf("DynamicLinear"), pool);
+ auto itemType = ConvertTypeAnnotationToAst(*type->GetItemType(), pool, refAtoms);
+ return TAstNode::NewList(TPosition(), pool, self, itemType);
+ }
+
case ETypeAnnotationKind::LastType:
YQL_ENSURE(false, "Unknown kind: " << annotation.GetKind());
@@ -3610,6 +3648,24 @@ const TScalarExprType* TMakeTypeImpl<TScalarExprType>::Make(TExprContext& ctx, c
return AddType<TScalarExprType>(ctx, hash, itemType);
}
+const TLinearExprType* TMakeTypeImpl<TLinearExprType>::Make(TExprContext& ctx, const TTypeAnnotationNode* itemType) {
+ const auto hash = TLinearExprType::MakeHash(itemType);
+ TLinearExprType sample(hash, itemType);
+ if (const auto found = FindType(sample, ctx))
+ return found;
+
+ return AddType<TLinearExprType>(ctx, hash, itemType);
+}
+
+const TDynamicLinearExprType* TMakeTypeImpl<TDynamicLinearExprType>::Make(TExprContext& ctx, const TTypeAnnotationNode* itemType) {
+ const auto hash = TDynamicLinearExprType::MakeHash(itemType);
+ TDynamicLinearExprType sample(hash, itemType);
+ if (const auto found = FindType(sample, ctx))
+ return found;
+
+ return AddType<TDynamicLinearExprType>(ctx, hash, itemType);
+}
+
bool CompareExprTrees(const TExprNode*& one, const TExprNode*& two) {
TArgumentsMap map;
ui32 level = 0;
@@ -3892,6 +3948,14 @@ void TDefaultTypeAnnotationVisitor::Visit(const TScalarExprType& type) {
type.GetItemType()->Accept(*this);
}
+void TDefaultTypeAnnotationVisitor::Visit(const TLinearExprType& type) {
+ type.GetItemType()->Accept(*this);
+}
+
+void TDefaultTypeAnnotationVisitor::Visit(const TDynamicLinearExprType& type) {
+ type.GetItemType()->Accept(*this);
+}
+
TErrorTypeVisitor::TErrorTypeVisitor(TExprContext& ctx)
: Ctx_(ctx)
{}