aboutsummaryrefslogtreecommitdiffstats
path: root/yql/essentials/minikql/mkql_node_cast.h
blob: 9fd7dec896fcfeb365f5e306089da7ac2f295bd2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include "mkql_node.h"

#include <util/system/src_location.h>


#define AS_VALUE(type, node) ::NKikimr::NMiniKQL::AsValue<type>((node), __LOCATION__)
#define AS_TYPE(type, node) ::NKikimr::NMiniKQL::AsType<type>((node), __LOCATION__)
#define AS_CALLABLE(name, node) ::NKikimr::NMiniKQL::AsCallable(TStringBuf(name), node, __LOCATION__)


namespace NKikimr {
namespace NMiniKQL {

template <typename T>
T* AsValue(TRuntimeNode node, const TSourceLocation& location);

template <typename T>
T* AsType(TType* type, const TSourceLocation& location);

template <typename T>
const T* AsType(const TType* type, const TSourceLocation& location);


template <typename T>
T* AsType(TRuntimeNode node, const TSourceLocation& location) {
    return AsType<T>(node.GetStaticType(), location);
}

TCallable* AsCallable(
        const TStringBuf& name,
        TRuntimeNode node,
        const TSourceLocation& location);

} // namespace NMiniKQL
} // namespace NKikimr