|
7 | 7 | #include "../vm.hpp"
|
8 | 8 |
|
9 | 9 | static void add_act(Frame& f) {
|
10 |
| - |
11 |
| - Value rhs = f.eval_stack.back(); |
12 |
| - f.eval_stack.pop_back(); |
13 |
| - Value& lhs = f.eval_stack.back(); |
14 |
| - |
15 |
| - |
16 |
| - // defer references |
17 |
| - if (rhs.type() == Value::VType::REF) { |
18 |
| - Value* p = std::get<Handle<Value>>(rhs.v).ptr; |
19 |
| - if (p == nullptr) |
20 |
| - return; // TODO: type-error |
21 |
| - rhs = *p; |
22 |
| - } |
23 |
| - |
24 |
| - if (lhs.type() == Value::VType::REF) { |
25 |
| - Value* p = std::get<Handle<Value>>(lhs.v).ptr; |
26 |
| - if (p == nullptr) |
27 |
| - return; // TODO: type-error |
28 |
| - lhs = *p; |
29 |
| - } |
30 |
| - |
31 |
| - auto rhs_type = rhs.type(); |
32 |
| - auto lhs_type = lhs.type(); |
33 |
| - // perform relevant operation |
34 |
| - if (rhs_type == Value::VType::INT) { |
35 |
| - Value::int_t& i = std::get<Value::int_t>(rhs.v); |
36 |
| - if (lhs_type == Value::VType::INT) { |
37 |
| - std::get<Value::int_t>(lhs.v) += i; |
38 |
| - } else if (lhs_type == Value::VType::FLOAT) { |
39 |
| - lhs = Value(std::get<Value::float_t>(lhs.v) + (Value::float_t) i); |
40 |
| - } else if (lhs_type == Value::VType::STR) { |
41 |
| - Value(std::get<std::string>(lhs.v) += std::to_string(i); |
42 |
| - } else { |
43 |
| - // TODO: type-error |
44 |
| - } |
45 |
| - |
46 |
| - } else if (rhs_type == Value::VType::STR) { |
47 |
| - std::string& s = std::get<std::string>(rhs.v); |
48 |
| - if (lhs_type == Value::VType::INT) { |
49 |
| - lhs = Value(std::to_string(std::get<Value::int_t>(lhs.v)) + s); |
50 |
| - } else if (lhs_type == Value::VType::FLOAT) { |
51 |
| - lhs = Value(std::to_string(std::get<Value::float_t>(lhs.v)) + s); |
52 |
| - } else if (lhs_type == Value::VType::STR) { |
53 |
| - std::get<std::string>(lhs.v) += s; |
54 |
| - } else { |
55 |
| - // TODO: type-error |
56 |
| - } |
57 |
| - } else if (rhs_type == Value::VType::FLOAT) { |
58 |
| - Value::float_t &fp = std::get<Value::float_t>(rhs.v); |
59 |
| - if (lhs_type == Value::VType::INT) { |
60 |
| - lhs = Value(std::get<Value::int_t>(lhs.v) + fp); |
61 |
| - } else if (lhs_type == Value::VType::FLOAT) { |
62 |
| - std::get<Value::float_t>(lhs.v) += fp; |
63 |
| - } else if (lhs_type == Value::VType::STR) { |
64 |
| - std::get<std::string>(lhs.v) += std::to_string(fp); |
65 |
| - } else { |
66 |
| - // TODO: type-error |
67 |
| - } |
68 |
| - } else { |
69 |
| - // TODO: type-error |
70 |
| - } |
71 |
| - |
72 |
| - return; |
| 10 | +// |
| 11 | +// Value rhs = f.eval_stack.back(); |
| 12 | +// f.eval_stack.pop_back(); |
| 13 | +// Value& lhs = f.eval_stack.back(); |
| 14 | +// |
| 15 | +// |
| 16 | +// // defer references |
| 17 | +// if (rhs.type() == Value::VType::REF) { |
| 18 | +// Value* p = std::get<Handle<Value>>(rhs.v).ptr; |
| 19 | +// if (p == nullptr) |
| 20 | +// return; // TODO: type-error |
| 21 | +// rhs = *p; |
| 22 | +// } |
| 23 | +// |
| 24 | +// if (lhs.type() == Value::VType::REF) { |
| 25 | +// Value* p = std::get<Handle<Value>>(lhs.v).ptr; |
| 26 | +// if (p == nullptr) |
| 27 | +// return; // TODO: type-error |
| 28 | +// lhs = *p; |
| 29 | +// } |
| 30 | +// |
| 31 | +// auto rhs_type = rhs.type(); |
| 32 | +// auto lhs_type = lhs.type(); |
| 33 | +// // perform relevant operation |
| 34 | +// if (rhs_type == Value::VType::INT) { |
| 35 | +// Value::int_t& i = std::get<Value::int_t>(rhs.v); |
| 36 | +// if (lhs_type == Value::VType::INT) { |
| 37 | +// std::get<Value::int_t>(lhs.v) += i; |
| 38 | +// } else if (lhs_type == Value::VType::FLOAT) { |
| 39 | +// lhs = Value(std::get<Value::float_t>(lhs.v) + (Value::float_t) i); |
| 40 | +// } else if (lhs_type == Value::VType::STR) { |
| 41 | +// std::get<std::string>(lhs.v) += std::to_string(i); |
| 42 | +// } else { |
| 43 | +// // TODO: type-error |
| 44 | +// } |
| 45 | +// |
| 46 | +// } else if (rhs_type == Value::VType::STR) { |
| 47 | +// std::string& s = std::get<std::string>(rhs.v); |
| 48 | +// if (lhs_type == Value::VType::INT) { |
| 49 | +// lhs = Value(std::to_string(std::get<Value::int_t>(lhs.v)) + s); |
| 50 | +// } else if (lhs_type == Value::VType::FLOAT) { |
| 51 | +// lhs = Value(std::to_string(std::get<Value::float_t>(lhs.v)) + s); |
| 52 | +// } else if (lhs_type == Value::VType::STR) { |
| 53 | +// std::get<std::string>(lhs.v) += s; |
| 54 | +// } else { |
| 55 | +// // TODO: type-error |
| 56 | +// } |
| 57 | +// } else if (rhs_type == Value::VType::FLOAT) { |
| 58 | +// Value::float_t &fp = std::get<Value::float_t>(rhs.v); |
| 59 | +// if (lhs_type == Value::VType::INT) { |
| 60 | +// lhs = Value(std::get<Value::int_t>(lhs.v) + fp); |
| 61 | +// } else if (lhs_type == Value::VType::FLOAT) { |
| 62 | +// std::get<Value::float_t>(lhs.v) += fp; |
| 63 | +// } else if (lhs_type == Value::VType::STR) { |
| 64 | +// std::get<std::string>(lhs.v) += std::to_string(fp); |
| 65 | +// } else { |
| 66 | +// // TODO: type-error |
| 67 | +// } |
| 68 | +// } else { |
| 69 | +// // TODO: type-error |
| 70 | +// } |
| 71 | +// |
| 72 | +// return; |
73 | 73 |
|
74 | 74 | }
|
75 | 75 |
|
|
0 commit comments