|
8 | 8 |
|
9 | 9 | /// defines operations allowed on strings. |
10 | 10 |
|
11 | | -namespace ink::runtime::internal { |
| 11 | +namespace ink::runtime::internal |
| 12 | +{ |
12 | 13 |
|
13 | | - namespace casting { |
14 | | - // define valid castings |
15 | | - // when operate on float and string, the result is a string |
16 | | - template<> |
17 | | - struct cast<value_type::float32, value_type::string> |
18 | | - { static constexpr value_type value = value_type::string; }; |
19 | | - template<> |
20 | | - struct cast<value_type::int32, value_type::string> |
21 | | - { static constexpr value_type value = value_type::string; }; |
22 | | - template<> |
23 | | - struct cast<value_type::uint32, value_type::string> |
24 | | - { static constexpr value_type value = value_type::string; }; |
25 | | - template<> |
26 | | - struct cast<value_type::string, value_type::newline> |
27 | | - { static constexpr value_type value = value_type::string; }; |
28 | | - } |
29 | | - |
30 | | - // operation declaration add |
| 14 | +namespace casting |
| 15 | +{ |
| 16 | + // define valid castings |
| 17 | + // when operate on float and string, the result is a string |
31 | 18 | template<> |
32 | | - class operation<Command::ADD, value_type::string, void> : public operation_base<string_table> { |
33 | | - public: |
34 | | - using operation_base::operation_base; |
35 | | - void operator()(basic_eval_stack& stack, value* vals); |
| 19 | + struct cast<value_type::float32, value_type::string> { |
| 20 | + static constexpr value_type value = value_type::string; |
36 | 21 | }; |
37 | 22 |
|
38 | | - // operation declaration equality |
39 | 23 | template<> |
40 | | - class operation<Command::IS_EQUAL, value_type::string, void> : public operation_base<void> { |
41 | | - public: |
42 | | - using operation_base::operation_base; |
43 | | - void operator()(basic_eval_stack& stack, value* vals); |
| 24 | + struct cast<value_type::int32, value_type::string> { |
| 25 | + static constexpr value_type value = value_type::string; |
44 | 26 | }; |
45 | 27 |
|
46 | 28 | template<> |
47 | | - class operation<Command::NOT_EQUAL, value_type::string, void> : public operation_base<void> { |
48 | | - public: |
49 | | - using operation_base::operation_base; |
50 | | - void operator()(basic_eval_stack& stack, value* vals); |
| 29 | + struct cast<value_type::uint32, value_type::string> { |
| 30 | + static constexpr value_type value = value_type::string; |
51 | 31 | }; |
52 | 32 |
|
53 | 33 | template<> |
54 | | - class operation<Command::HAS, value_type::string, void> : public operation_base<void> { |
55 | | - public: |
56 | | - using operation_base::operation_base; |
57 | | - void operator()(basic_eval_stack& stack, value* vals); |
| 34 | + struct cast<value_type::boolean, value_type::string> { |
| 35 | + static constexpr value_type value = value_type::string; |
58 | 36 | }; |
59 | 37 |
|
60 | 38 | template<> |
61 | | - class operation<Command::HASNT, value_type::string, void> : public operation_base<void> { |
62 | | - public: |
63 | | - using operation_base::operation_base; |
64 | | - void operator()(basic_eval_stack& stack, value* vals); |
| 39 | + struct cast<value_type::string, value_type::newline> { |
| 40 | + static constexpr value_type value = value_type::string; |
65 | 41 | }; |
| 42 | +} // namespace casting |
| 43 | + |
| 44 | +// operation declaration add |
| 45 | +template<> |
| 46 | +class operation<Command::ADD, value_type::string, void> : public operation_base<string_table> |
| 47 | +{ |
| 48 | +public: |
| 49 | + using operation_base::operation_base; |
| 50 | + void operator()(basic_eval_stack& stack, value* vals); |
| 51 | +}; |
| 52 | + |
| 53 | +// operation declaration equality |
| 54 | +template<> |
| 55 | +class operation<Command::IS_EQUAL, value_type::string, void> : public operation_base<void> |
| 56 | +{ |
| 57 | +public: |
| 58 | + using operation_base::operation_base; |
| 59 | + void operator()(basic_eval_stack& stack, value* vals); |
| 60 | +}; |
| 61 | + |
| 62 | +template<> |
| 63 | +class operation<Command::NOT_EQUAL, value_type::string, void> : public operation_base<void> |
| 64 | +{ |
| 65 | +public: |
| 66 | + using operation_base::operation_base; |
| 67 | + void operator()(basic_eval_stack& stack, value* vals); |
| 68 | +}; |
| 69 | + |
| 70 | +template<> |
| 71 | +class operation<Command::HAS, value_type::string, void> : public operation_base<void> |
| 72 | +{ |
| 73 | +public: |
| 74 | + using operation_base::operation_base; |
| 75 | + void operator()(basic_eval_stack& stack, value* vals); |
| 76 | +}; |
| 77 | + |
| 78 | +template<> |
| 79 | +class operation<Command::HASNT, value_type::string, void> : public operation_base<void> |
| 80 | +{ |
| 81 | +public: |
| 82 | + using operation_base::operation_base; |
| 83 | + void operator()(basic_eval_stack& stack, value* vals); |
| 84 | +}; |
66 | 85 |
|
67 | | -} |
| 86 | +} // namespace ink::runtime::internal |
0 commit comments