로딩중...
검색중...
일치하는것 없음
tscalar.hpp
이 파일의 문서화 페이지로 가기
1
2#pragma once
3
5#include "core/ast/func.hpp"
6#include "core/ast/scope.hpp"
10
11namespace by {
12
13 template <typename T> class tscalar: public scalar {
14 BY(ADT(tscalar, scalar))
15 typedef T trait;
16
17 protected:
18 template <typename E, typename RAW> class asPrimitive: public tas<E, T> {
19 typedef tas<E, T> __super18;
21
22 public:
23 str as(const node& me, const type& to) const override { return str(new E(*me.cast<RAW>())); }
24
25 protected:
26 str _onAs(const T& me, const type& to) const override { return str(); }
27 };
28
29 public:
30 tscalar(): _val() {}
31
32 tscalar(const T& val): _val(val) {}
33
34 public:
35 T& get() { return _val; }
36
37 const T& get() const { return _val; }
38
39 using super::cast;
40
41 void* cast(const type& to) override {
42 WHEN(to == ttype<T>::get()) .ret(&_val);
43
44 return super::cast(to);
45 }
46
47 protected:
48 nbool _onSame(const typeProvidable& rhs) const override {
49 const me& cast = (const me&) rhs;
50 return _val == cast._val;
51 }
52
53 private:
54 T _val;
55 };
56
57 template <> class tscalar<void>: public scalar {
58 BY(ADT(tscalar, scalar))
59
60 protected:
61 nbool _onSame(const typeProvidable& rhs) const override { return true; }
62 };
63} // namespace by
Base class for all AST nodes in the byeol language
Definition node.hpp:195
Base class for arithmetic operations on primitive types
Definition scalar.hpp:14
Definition tnarr.hpp:9
Definition tscalar.hpp:18
Definition tscalar.hpp:13
Definition tas.hpp:11
to Top