| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include <gyoji-mir/operations.hpp> | ||
| 2 | #include <gyoji-misc/jstring.hpp> | ||
| 3 | |||
| 4 | using namespace Gyoji::mir; | ||
| 5 | |||
| 6 | namespace Gyoji::mir { | ||
| 7 | static std::map<Operation::OperationType, std::string> op_type_names; | ||
| 8 | } | ||
| 9 | |||
| 10 | 32 | void Gyoji::mir::operation_static_init() | |
| 11 | { | ||
| 12 | // This doesn't really belong here, but I don't have a | ||
| 13 | // better place to globally initialize static data. | ||
| 14 | |||
| 15 | |||
| 16 | // Functions and global symbols | ||
| 17 | 32 | op_type_names.insert(std::pair(Operation::OP_FUNCTION_CALL, "function-call")); | |
| 18 | 32 | op_type_names.insert(std::pair(Operation::OP_SYMBOL, "symbol")); | |
| 19 | |||
| 20 | // Cast operations. | ||
| 21 | 32 | op_type_names.insert(std::pair(Operation::OP_WIDEN_SIGNED, "widen-signed")); | |
| 22 | 32 | op_type_names.insert(std::pair(Operation::OP_WIDEN_UNSIGNED, "widen-unsigned")); | |
| 23 | 32 | op_type_names.insert(std::pair(Operation::OP_WIDEN_FLOAT, "widen-float")); | |
| 24 | |||
| 25 | // Indirect access | ||
| 26 | 32 | op_type_names.insert(std::pair(Operation::OP_ARRAY_INDEX, "array-index")); | |
| 27 | 32 | op_type_names.insert(std::pair(Operation::OP_DOT, "dot")); | |
| 28 | |||
| 29 | // Variable access | ||
| 30 | |||
| 31 | 32 | op_type_names.insert(std::pair(Operation::OP_LOCAL_DECLARE, "declare")); | |
| 32 | 32 | op_type_names.insert(std::pair(Operation::OP_LOCAL_UNDECLARE, "undeclare")); | |
| 33 | 32 | op_type_names.insert(std::pair(Operation::OP_LOCAL_VARIABLE, "load")); | |
| 34 | |||
| 35 | // Literals | ||
| 36 | 32 | op_type_names.insert(std::pair(Operation::OP_LITERAL_CHAR, "literal-char")); | |
| 37 | 32 | op_type_names.insert(std::pair(Operation::OP_LITERAL_STRING, "literal-string")); | |
| 38 | 32 | op_type_names.insert(std::pair(Operation::OP_LITERAL_INT, "literal-int")); | |
| 39 | 32 | op_type_names.insert(std::pair(Operation::OP_LITERAL_FLOAT, "literal-float")); | |
| 40 | 32 | op_type_names.insert(std::pair(Operation::OP_LITERAL_BOOL, "literal-bool")); | |
| 41 | 32 | op_type_names.insert(std::pair(Operation::OP_LITERAL_NULL, "literal-null")); | |
| 42 | |||
| 43 | // Unary operations | ||
| 44 | 32 | op_type_names.insert(std::pair(Operation::OP_ADDRESSOF, "addressof")); | |
| 45 | 32 | op_type_names.insert(std::pair(Operation::OP_DEREFERENCE, "dereference")); | |
| 46 | 32 | op_type_names.insert(std::pair(Operation::OP_NEGATE, "negate")); | |
| 47 | 32 | op_type_names.insert(std::pair(Operation::OP_BITWISE_NOT, "bitwise-not")); | |
| 48 | 32 | op_type_names.insert(std::pair(Operation::OP_LOGICAL_NOT, "logical-not")); | |
| 49 | 32 | op_type_names.insert(std::pair(Operation::OP_SIZEOF_TYPE, "sizeof")); | |
| 50 | |||
| 51 | // Binary operations: arithmetic | ||
| 52 | 32 | op_type_names.insert(std::pair(Operation::OP_ADD, "add")); | |
| 53 | 32 | op_type_names.insert(std::pair(Operation::OP_SUBTRACT, "subtract")); | |
| 54 | 32 | op_type_names.insert(std::pair(Operation::OP_MULTIPLY, "multiply")); | |
| 55 | 32 | op_type_names.insert(std::pair(Operation::OP_DIVIDE, "divide")); | |
| 56 | 32 | op_type_names.insert(std::pair(Operation::OP_MODULO, "modulo")); | |
| 57 | |||
| 58 | // Binary operations: logical | ||
| 59 | 32 | op_type_names.insert(std::pair(Operation::OP_LOGICAL_AND, "logical-and")); | |
| 60 | 32 | op_type_names.insert(std::pair(Operation::OP_LOGICAL_OR, "logical-or")); | |
| 61 | |||
| 62 | // Binary operations: bitwise | ||
| 63 | 32 | op_type_names.insert(std::pair(Operation::OP_BITWISE_AND, "bitwise-and")); | |
| 64 | 32 | op_type_names.insert(std::pair(Operation::OP_BITWISE_OR, "bitwise-or")); | |
| 65 | 32 | op_type_names.insert(std::pair(Operation::OP_BITWISE_XOR, "bitwise-xor")); | |
| 66 | 32 | op_type_names.insert(std::pair(Operation::OP_SHIFT_LEFT, "bitwise-shift-left")); | |
| 67 | 32 | op_type_names.insert(std::pair(Operation::OP_SHIFT_RIGHT, "bitwise-shift-right")); | |
| 68 | |||
| 69 | // Binary operations: comparisons | ||
| 70 | 32 | op_type_names.insert(std::pair(Operation::OP_COMPARE_LESS, "compare-less")); | |
| 71 | 32 | op_type_names.insert(std::pair(Operation::OP_COMPARE_GREATER, "compare-greater")); | |
| 72 | 32 | op_type_names.insert(std::pair(Operation::OP_COMPARE_LESS_EQUAL, "compare-less-equal")); | |
| 73 | 32 | op_type_names.insert(std::pair(Operation::OP_COMPARE_GREATER_EQUAL, "compare-greater-equal")); | |
| 74 | 32 | op_type_names.insert(std::pair(Operation::OP_COMPARE_NOT_EQUAL, "compare-not-equal")); | |
| 75 | 32 | op_type_names.insert(std::pair(Operation::OP_COMPARE_EQUAL, "compare-equal")); | |
| 76 | |||
| 77 | // Binary operations: assignment | ||
| 78 | 32 | op_type_names.insert(std::pair(Operation::OP_ASSIGN, "store")); | |
| 79 | |||
| 80 | // Branch and flow control | ||
| 81 | 32 | op_type_names.insert(std::pair(Operation::OP_JUMP_CONDITIONAL, "jump-conditional")); | |
| 82 | 32 | op_type_names.insert(std::pair(Operation::OP_JUMP, "jump")); | |
| 83 | 32 | op_type_names.insert(std::pair(Operation::OP_RETURN, "return")); | |
| 84 | 32 | op_type_names.insert(std::pair(Operation::OP_RETURN_VOID, "return-void")); | |
| 85 | 32 | } | |
| 86 | |||
| 87 | 2736 | Operation::Operation( | |
| 88 | OperationType _type, | ||
| 89 | const Gyoji::context::SourceReference & _src_ref, | ||
| 90 | size_t _result | ||
| 91 | 2736 | ) | |
| 92 | 2736 | : type(_type) | |
| 93 | 2736 | , src_ref(_src_ref) | |
| 94 | 2736 | , result(_result) | |
| 95 | 2736 | {} | |
| 96 | 560 | Operation::Operation( | |
| 97 | OperationType _type, | ||
| 98 | const Gyoji::context::SourceReference & _src_ref, | ||
| 99 | size_t _result, | ||
| 100 | size_t _operand | ||
| 101 | 560 | ) | |
| 102 | 560 | : type(_type) | |
| 103 | 560 | , src_ref(_src_ref) | |
| 104 | 560 | , result(_result) | |
| 105 | { | ||
| 106 | 560 | add_operand(_operand); | |
| 107 | 560 | } | |
| 108 | 680 | Operation::Operation( | |
| 109 | OperationType _type, | ||
| 110 | const Gyoji::context::SourceReference & _src_ref, | ||
| 111 | size_t _result, | ||
| 112 | size_t _operand_a, | ||
| 113 | size_t _operand_b | ||
| 114 | 680 | ) | |
| 115 | 680 | : type(_type) | |
| 116 | 680 | , src_ref(_src_ref) | |
| 117 | 680 | , result(_result) | |
| 118 | { | ||
| 119 | 680 | add_operand(_operand_a); | |
| 120 | 680 | add_operand(_operand_b); | |
| 121 | 680 | } | |
| 122 | 38 | Operation::Operation( | |
| 123 | OperationType _type, | ||
| 124 | const Gyoji::context::SourceReference & _src_ref, | ||
| 125 | size_t _result, | ||
| 126 | size_t _operand_a, | ||
| 127 | size_t _operand_b, | ||
| 128 | size_t _operand_c | ||
| 129 | 38 | ) | |
| 130 | 38 | : type(_type) | |
| 131 | 38 | , src_ref(_src_ref) | |
| 132 | 38 | , result(_result) | |
| 133 | { | ||
| 134 | 38 | add_operand(_operand_a); | |
| 135 | 38 | add_operand(_operand_b); | |
| 136 | 38 | add_operand(_operand_c); | |
| 137 | 38 | } | |
| 138 | 8028 | Operation::~Operation() | |
| 139 | 8028 | {} | |
| 140 | |||
| 141 | void | ||
| 142 | 2086 | Operation::add_operand(size_t operand) | |
| 143 | { | ||
| 144 | 2086 | operands.push_back(operand); | |
| 145 | 2086 | } | |
| 146 | |||
| 147 | std::string | ||
| 148 | 776 | Operation::get_description() const | |
| 149 | { | ||
| 150 | 776 | const auto & it = op_type_names.find(type); | |
| 151 | 776 | const std::string & op_name = it->second; | |
| 152 | |||
| 153 | 3880 | std::string desc = std::string("_") + std::to_string(result) + std::string(" = ") + op_name + std::string(" ("); | |
| 154 |
2/2✓ Branch 4 taken 1500 times.
✓ Branch 5 taken 776 times.
|
2276 | for (const auto & operand : operands) { |
| 155 | 4500 | desc = desc + std::string(" _") + std::to_string(operand); | |
| 156 | } | ||
| 157 | 776 | desc = desc + std::string(" )"); | |
| 158 | |||
| 159 | 776 | return desc; | |
| 160 | } | ||
| 161 | bool | ||
| 162 | 4154 | Operation::is_terminating() const | |
| 163 | { | ||
| 164 | // Identify any instructions that | ||
| 165 | // would terminate a basic block. | ||
| 166 | 8268 | return (type == OP_JUMP) || | |
| 167 |
2/2✓ Branch 0 taken 4076 times.
✓ Branch 1 taken 38 times.
|
4114 | (type == OP_JUMP_CONDITIONAL) || |
| 168 |
4/4✓ Branch 0 taken 4114 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 3776 times.
✓ Branch 3 taken 300 times.
|
12044 | (type == OP_RETURN) || |
| 169 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3774 times.
|
7930 | (type == OP_RETURN_VOID); |
| 170 | } | ||
| 171 | |||
| 172 | Operation::OperationType | ||
| 173 | 4032 | Operation::get_type() const | |
| 174 | 4032 | { return type; } | |
| 175 | |||
| 176 | const std::vector<size_t> & | ||
| 177 | 570 | Operation::get_operands() const | |
| 178 | 570 | { return operands; } | |
| 179 | |||
| 180 | size_t | ||
| 181 | 3570 | Operation::get_result() const | |
| 182 | 3570 | { return result; } | |
| 183 | |||
| 184 | const Gyoji::context::SourceReference & | ||
| 185 | ✗ | Operation::get_source_ref() const | |
| 186 | ✗ | { return src_ref; } | |
| 187 | |||
| 188 | void | ||
| 189 | 3994 | Operation::dump(FILE *out) const | |
| 190 | { | ||
| 191 | 3994 | fprintf(out, " %s\n", get_description().c_str()); | |
| 192 | 3994 | } | |
| 193 | |||
| 194 | |||
| 195 | ////////////////////////////////////////////// | ||
| 196 | // OperationUnary | ||
| 197 | ////////////////////////////////////////////// | ||
| 198 | 170 | OperationUnary::OperationUnary( | |
| 199 | OperationType _type, | ||
| 200 | const Gyoji::context::SourceReference & _src_ref, | ||
| 201 | size_t _result, | ||
| 202 | size_t _operand | ||
| 203 | 170 | ) | |
| 204 | 170 | : Operation(_type, _src_ref, _result, _operand) | |
| 205 | 170 | {} | |
| 206 | 384 | OperationUnary::~OperationUnary() | |
| 207 | 384 | {} | |
| 208 | size_t | ||
| 209 | 170 | OperationUnary::get_a() const | |
| 210 | 170 | { return operands.at(0); } | |
| 211 | ////////////////////////////////////////////// | ||
| 212 | // OperationCast | ||
| 213 | ////////////////////////////////////////////// | ||
| 214 | 136 | OperationCast::OperationCast( | |
| 215 | OperationType _type, | ||
| 216 | const Gyoji::context::SourceReference & _src_ref, | ||
| 217 | size_t _result, | ||
| 218 | size_t _operand, | ||
| 219 | const Type *_cast_type | ||
| 220 | 136 | ) | |
| 221 | : OperationUnary(_type, _src_ref, _result, _operand) | ||
| 222 | 136 | , cast_type(_cast_type) | |
| 223 | 136 | {} | |
| 224 | 544 | OperationCast::~OperationCast() | |
| 225 | 544 | {} | |
| 226 | |||
| 227 | const Type* | ||
| 228 | 136 | OperationCast::get_cast_type() const | |
| 229 | 136 | { return cast_type; } | |
| 230 | |||
| 231 | std::string | ||
| 232 | 136 | OperationCast::get_description() const | |
| 233 | { | ||
| 234 | 136 | const auto & it = op_type_names.find(type); | |
| 235 | 136 | const std::string & op_name = it->second; | |
| 236 | |||
| 237 | 680 | std::string desc = std::string("_") + std::to_string(result) + std::string(" = ") + op_name + std::string(" ("); | |
| 238 | 408 | desc = desc + std::string(" _") + std::to_string(operands.at(0)); | |
| 239 | 408 | desc = desc + std::string(" ") + cast_type->get_name(); | |
| 240 | 136 | desc = desc + std::string(" )"); | |
| 241 | 136 | return desc; | |
| 242 | } | ||
| 243 | |||
| 244 | ////////////////////////////////////////////// | ||
| 245 | // OperationBinary | ||
| 246 | ////////////////////////////////////////////// | ||
| 247 | |||
| 248 | 680 | OperationBinary::OperationBinary( | |
| 249 | OperationType _type, | ||
| 250 | const Gyoji::context::SourceReference & _src_ref, | ||
| 251 | size_t _result, | ||
| 252 | size_t _operand_a, | ||
| 253 | size_t _operand_b | ||
| 254 | 680 | ) | |
| 255 | 680 | : Operation(_type, _src_ref, _result, _operand_a, _operand_b) | |
| 256 | 680 | {} | |
| 257 | 2700 | OperationBinary::~OperationBinary() | |
| 258 | 2700 | {} | |
| 259 | size_t | ||
| 260 | 680 | OperationBinary::get_a() const | |
| 261 | 680 | { return operands.at(0); } | |
| 262 | |||
| 263 | size_t | ||
| 264 | 1066 | OperationBinary::get_b() const | |
| 265 | 1066 | { return operands.at(1); } | |
| 266 | |||
| 267 | |||
| 268 | ////////////////////////////////////////////// | ||
| 269 | // OperationFunctionCall | ||
| 270 | ////////////////////////////////////////////// | ||
| 271 | 66 | OperationFunctionCall::OperationFunctionCall( | |
| 272 | const Gyoji::context::SourceReference & _src_ref, | ||
| 273 | size_t _result, | ||
| 274 | size_t _callee_tmpvar, | ||
| 275 | std::vector<size_t> _arg_args | ||
| 276 | 66 | ) | |
| 277 | 66 | : Operation(OP_FUNCTION_CALL, _src_ref, _result, _callee_tmpvar) | |
| 278 | { | ||
| 279 |
2/2✓ Branch 5 taken 52 times.
✓ Branch 6 taken 66 times.
|
118 | for (const auto & av : _arg_args) { |
| 280 | 52 | add_operand(av); | |
| 281 | } | ||
| 282 | 66 | } | |
| 283 | |||
| 284 | 264 | OperationFunctionCall::~OperationFunctionCall() | |
| 285 | 264 | {} | |
| 286 | |||
| 287 | ////////////////////////////////////////////// | ||
| 288 | // OperationSymbol | ||
| 289 | ////////////////////////////////////////////// | ||
| 290 | 66 | OperationSymbol::OperationSymbol( | |
| 291 | const Gyoji::context::SourceReference & _src_ref, | ||
| 292 | size_t _result, | ||
| 293 | std::string _symbol_name | ||
| 294 | 66 | ) | |
| 295 | : Operation(OP_SYMBOL, _src_ref, _result) | ||
| 296 | 66 | , symbol_name(_symbol_name) | |
| 297 | 66 | {} | |
| 298 | |||
| 299 | 264 | OperationSymbol::~OperationSymbol() | |
| 300 | 264 | {} | |
| 301 | |||
| 302 | const std::string & | ||
| 303 | 66 | OperationSymbol::get_symbol_name() const | |
| 304 | 66 | { return symbol_name; } | |
| 305 | |||
| 306 | std::string | ||
| 307 | 66 | OperationSymbol::get_description() const | |
| 308 | { | ||
| 309 | 66 | const auto & it = op_type_names.find(type); | |
| 310 | 66 | const std::string & op_name = it->second; | |
| 311 | |||
| 312 | 330 | std::string desc = std::string("_") + std::to_string(result) + std::string(" = ") + op_name + std::string(" ("); | |
| 313 | 198 | desc = desc + std::string(" ") + symbol_name; | |
| 314 | 66 | desc = desc + std::string(" )"); | |
| 315 | 66 | return desc; | |
| 316 | } | ||
| 317 | |||
| 318 | ////////////////////////////////////////////// | ||
| 319 | // OperationArrayIndex | ||
| 320 | ////////////////////////////////////////////// | ||
| 321 | 10 | OperationArrayIndex::OperationArrayIndex( | |
| 322 | const Gyoji::context::SourceReference & _src_ref, | ||
| 323 | size_t _result, | ||
| 324 | size_t _array_tmpvar, | ||
| 325 | size_t _index_tmpvar | ||
| 326 | 10 | ) | |
| 327 | 10 | : OperationBinary(OP_ARRAY_INDEX, _src_ref, _result, _array_tmpvar, _index_tmpvar) | |
| 328 | 10 | {} | |
| 329 | 40 | OperationArrayIndex::~OperationArrayIndex() | |
| 330 | 40 | {} | |
| 331 | |||
| 332 | ////////////////////////////////////////////// | ||
| 333 | // OperationDot | ||
| 334 | ////////////////////////////////////////////// | ||
| 335 | 12 | OperationDot::OperationDot( | |
| 336 | const Gyoji::context::SourceReference & _src_ref, | ||
| 337 | size_t _result, | ||
| 338 | size_t _operand, | ||
| 339 | std::string _member_name | ||
| 340 | 12 | ) | |
| 341 | : OperationUnary(OP_DOT, _src_ref, _result, _operand) | ||
| 342 | 12 | , member_name(_member_name) | |
| 343 | 12 | {} | |
| 344 | |||
| 345 | 48 | OperationDot::~OperationDot() | |
| 346 | 48 | {} | |
| 347 | |||
| 348 | const std::string & | ||
| 349 | 12 | OperationDot::get_member_name() const | |
| 350 | 12 | { return member_name; } | |
| 351 | |||
| 352 | std::string | ||
| 353 | 12 | OperationDot::get_description() const | |
| 354 | { | ||
| 355 | 12 | const auto & it = op_type_names.find(type); | |
| 356 | 12 | const std::string & op_name = it->second; | |
| 357 | |||
| 358 | 60 | std::string desc = std::string("_") + std::to_string(result) + std::string(" = ") + op_name + std::string(" ("); | |
| 359 | 36 | desc = desc + std::string(" _") + std::to_string(operands.at(0)); | |
| 360 | 36 | desc = desc + std::string(" ") + member_name; | |
| 361 | 12 | desc = desc + std::string(" )"); | |
| 362 | 12 | return desc; | |
| 363 | } | ||
| 364 | |||
| 365 | ////////////////////////////////////////////// | ||
| 366 | // OperationLocalVariable | ||
| 367 | ////////////////////////////////////////////// | ||
| 368 | 1180 | OperationLocalVariable::OperationLocalVariable( | |
| 369 | const Gyoji::context::SourceReference & _src_ref, | ||
| 370 | size_t _result, | ||
| 371 | std::string _symbol_name, | ||
| 372 | const Type * _var_type | ||
| 373 | 1180 | ) | |
| 374 | : Operation(OP_LOCAL_VARIABLE, _src_ref, _result) | ||
| 375 | 1180 | , symbol_name(_symbol_name) | |
| 376 | 1180 | , var_type(_var_type) | |
| 377 | 1180 | {} | |
| 378 | 4720 | OperationLocalVariable::~OperationLocalVariable() | |
| 379 | 4720 | {} | |
| 380 | |||
| 381 | const std::string & | ||
| 382 | 1180 | OperationLocalVariable::get_symbol_name() const | |
| 383 | 1180 | { return symbol_name; } | |
| 384 | |||
| 385 | const Type * | ||
| 386 | 1180 | OperationLocalVariable::get_var_type() const | |
| 387 | 1180 | { return var_type; } | |
| 388 | |||
| 389 | std::string | ||
| 390 | 1180 | OperationLocalVariable::get_description() const | |
| 391 | { | ||
| 392 | 1180 | const auto & it = op_type_names.find(type); | |
| 393 | 1180 | const std::string & op_name = it->second; | |
| 394 | |||
| 395 | 5900 | std::string desc = std::string("_") + std::to_string(result) + std::string(" = ") + op_name + std::string(" ("); | |
| 396 | 2360 | desc = desc + std::string(" ") + symbol_name; | |
| 397 | 3540 | desc = desc + std::string(" ") + var_type->get_name(); | |
| 398 | 1180 | desc = desc + std::string(" )"); | |
| 399 | 1180 | return desc; | |
| 400 | } | ||
| 401 | |||
| 402 | ////////////////////////////////////////////// | ||
| 403 | // OperationLiteralChar | ||
| 404 | ////////////////////////////////////////////// | ||
| 405 | 8 | OperationLiteralChar::OperationLiteralChar( | |
| 406 | const Gyoji::context::SourceReference & _src_ref, | ||
| 407 | size_t _result, | ||
| 408 | char _literal_char | ||
| 409 | 8 | ) | |
| 410 | : Operation(OP_LITERAL_CHAR, _src_ref, _result) | ||
| 411 | 8 | , literal_char(_literal_char) | |
| 412 | 8 | {} | |
| 413 | 32 | OperationLiteralChar::~OperationLiteralChar() | |
| 414 | 32 | {} | |
| 415 | |||
| 416 | char | ||
| 417 | 8 | OperationLiteralChar::get_literal_char() const | |
| 418 | 8 | { return literal_char; } | |
| 419 | |||
| 420 | std::string | ||
| 421 | 8 | OperationLiteralChar::get_description() const | |
| 422 | { | ||
| 423 | 8 | const auto & it = op_type_names.find(type); | |
| 424 | 8 | const std::string & op_name = it->second; | |
| 425 | 8 | std::string char_unescaped; | |
| 426 | 8 | char_unescaped.push_back(literal_char); | |
| 427 | 8 | std::string char_escaped; | |
| 428 | 8 | Gyoji::misc::string_c_escape(char_escaped, char_unescaped, true); | |
| 429 | |||
| 430 | 40 | std::string desc = std::string("_") + std::to_string(result) + std::string(" = ") + op_name + std::string(" ("); | |
| 431 | 24 | desc = desc + std::string(" ") + literal_char; | |
| 432 | 8 | desc = desc + std::string(" )"); | |
| 433 | 8 | return desc; | |
| 434 | 8 | } | |
| 435 | |||
| 436 | ////////////////////////////////////////////// | ||
| 437 | // OperationLiteralString | ||
| 438 | ////////////////////////////////////////////// | ||
| 439 | 10 | OperationLiteralString::OperationLiteralString( | |
| 440 | const Gyoji::context::SourceReference & _src_ref, | ||
| 441 | size_t _result, | ||
| 442 | std::string _literal_string | ||
| 443 | 10 | ) | |
| 444 | : Operation(OP_LITERAL_STRING, _src_ref, _result) | ||
| 445 | 10 | , literal_string(_literal_string) | |
| 446 | 10 | {} | |
| 447 | 40 | OperationLiteralString::~OperationLiteralString() | |
| 448 | 40 | {} | |
| 449 | |||
| 450 | const std::string & | ||
| 451 | 10 | OperationLiteralString::get_literal_string() const | |
| 452 | 10 | { return literal_string; } | |
| 453 | |||
| 454 | std::string | ||
| 455 | 10 | OperationLiteralString::get_description() const | |
| 456 | { | ||
| 457 | 10 | const auto & it = op_type_names.find(type); | |
| 458 | 10 | const std::string & op_name = it->second; | |
| 459 | |||
| 460 | 10 | std::string literal_escaped; | |
| 461 | 10 | Gyoji::misc::string_c_escape(literal_escaped, literal_string, false); | |
| 462 | |||
| 463 | 60 | std::string desc = std::string("_") + std::to_string(result) + std::string(" = ") + op_name + std::string(" ("); | |
| 464 | 20 | desc = desc + std::string(" \"") + literal_escaped; | |
| 465 | 10 | desc = desc + std::string(" \")"); | |
| 466 | 10 | return desc; | |
| 467 | 10 | } | |
| 468 | |||
| 469 | ////////////////////////////////////////////// | ||
| 470 | // OperationLiteralInt | ||
| 471 | ////////////////////////////////////////////// | ||
| 472 | 10 | OperationLiteralInt::OperationLiteralInt( | |
| 473 | const Gyoji::context::SourceReference & _src_ref, | ||
| 474 | size_t _result, | ||
| 475 | Type::TypeType _literal_type, | ||
| 476 | unsigned char _literal_u8 | ||
| 477 | 10 | ) | |
| 478 | : Operation(OP_LITERAL_INT, _src_ref, _result) | ||
| 479 | 10 | , literal_type(_literal_type) | |
| 480 | 10 | , literal_u8(_literal_u8) | |
| 481 | 10 | , literal_u16(0) | |
| 482 | 10 | , literal_u32(0) | |
| 483 | 10 | , literal_u64(0L) | |
| 484 | 10 | , literal_i8(0) | |
| 485 | 10 | , literal_i16(0) | |
| 486 | 10 | , literal_i32(0) | |
| 487 | 10 | , literal_i64(0) | |
| 488 | 10 | {} | |
| 489 | 24 | OperationLiteralInt::OperationLiteralInt( | |
| 490 | const Gyoji::context::SourceReference & _src_ref, | ||
| 491 | size_t _result, | ||
| 492 | Type::TypeType _literal_type, | ||
| 493 | unsigned short _literal_u16 | ||
| 494 | 24 | ) | |
| 495 | : Operation(OP_LITERAL_INT, _src_ref, _result) | ||
| 496 | 24 | , literal_type(_literal_type) | |
| 497 | 24 | , literal_u8(0) | |
| 498 | 24 | , literal_u16(_literal_u16) | |
| 499 | 24 | , literal_u32(0) | |
| 500 | 24 | , literal_u64(0L) | |
| 501 | 24 | , literal_i8(0) | |
| 502 | 24 | , literal_i16(0) | |
| 503 | 24 | , literal_i32(0) | |
| 504 | 24 | , literal_i64(0) | |
| 505 | 24 | {} | |
| 506 | 146 | OperationLiteralInt::OperationLiteralInt( | |
| 507 | const Gyoji::context::SourceReference & _src_ref, | ||
| 508 | size_t _result, | ||
| 509 | Type::TypeType _literal_type, | ||
| 510 | unsigned int _literal_u32 | ||
| 511 | 146 | ) | |
| 512 | : Operation(OP_LITERAL_INT, _src_ref, _result) | ||
| 513 | 146 | , literal_type(_literal_type) | |
| 514 | 146 | , literal_u8(0) | |
| 515 | 146 | , literal_u16(0) | |
| 516 | 146 | , literal_u32(_literal_u32) | |
| 517 | 146 | , literal_u64(0L) | |
| 518 | 146 | , literal_i8(0) | |
| 519 | 146 | , literal_i16(0) | |
| 520 | 146 | , literal_i32(0) | |
| 521 | 146 | , literal_i64(0) | |
| 522 | 146 | {} | |
| 523 | 18 | OperationLiteralInt::OperationLiteralInt( | |
| 524 | const Gyoji::context::SourceReference & _src_ref, | ||
| 525 | size_t _result, | ||
| 526 | Type::TypeType _literal_type, | ||
| 527 | unsigned long _literal_u64 | ||
| 528 | 18 | ) | |
| 529 | : Operation(OP_LITERAL_INT, _src_ref, _result) | ||
| 530 | 18 | , literal_type(_literal_type) | |
| 531 | 18 | , literal_u8(0) | |
| 532 | 18 | , literal_u16(0) | |
| 533 | 18 | , literal_u32(0) | |
| 534 | 18 | , literal_u64(_literal_u64) | |
| 535 | 18 | , literal_i8(0) | |
| 536 | 18 | , literal_i16(0) | |
| 537 | 18 | , literal_i32(0) | |
| 538 | 18 | , literal_i64(0) | |
| 539 | 18 | {} | |
| 540 | ///// | ||
| 541 | 10 | OperationLiteralInt::OperationLiteralInt( | |
| 542 | const Gyoji::context::SourceReference & _src_ref, | ||
| 543 | size_t _result, | ||
| 544 | Type::TypeType _literal_type, | ||
| 545 | char _literal_i8 | ||
| 546 | 10 | ) | |
| 547 | : Operation(OP_LITERAL_INT, _src_ref, _result) | ||
| 548 | 10 | , literal_type(_literal_type) | |
| 549 | 10 | , literal_u8(0) | |
| 550 | 10 | , literal_u16(0) | |
| 551 | 10 | , literal_u32(0) | |
| 552 | 10 | , literal_u64(0L) | |
| 553 | 10 | , literal_i8(_literal_i8) | |
| 554 | 10 | , literal_i16(0) | |
| 555 | 10 | , literal_i32(0) | |
| 556 | 10 | , literal_i64(0) | |
| 557 | 10 | {} | |
| 558 | 16 | OperationLiteralInt::OperationLiteralInt( | |
| 559 | const Gyoji::context::SourceReference & _src_ref, | ||
| 560 | size_t _result, | ||
| 561 | Type::TypeType _literal_type, | ||
| 562 | short _literal_i16 | ||
| 563 | 16 | ) | |
| 564 | : Operation(OP_LITERAL_INT, _src_ref, _result) | ||
| 565 | 16 | , literal_type(_literal_type) | |
| 566 | 16 | , literal_u8(0) | |
| 567 | 16 | , literal_u16(0) | |
| 568 | 16 | , literal_u32(0) | |
| 569 | 16 | , literal_u64(0L) | |
| 570 | 16 | , literal_i8(0) | |
| 571 | 16 | , literal_i16(_literal_i16) | |
| 572 | 16 | , literal_i32(0) | |
| 573 | 16 | , literal_i64(0) | |
| 574 | 16 | {} | |
| 575 | 8 | OperationLiteralInt::OperationLiteralInt( | |
| 576 | const Gyoji::context::SourceReference & _src_ref, | ||
| 577 | size_t _result, | ||
| 578 | Type::TypeType _literal_type, | ||
| 579 | int _literal_i32 | ||
| 580 | 8 | ) | |
| 581 | : Operation(OP_LITERAL_INT, _src_ref, _result) | ||
| 582 | 8 | , literal_type(_literal_type) | |
| 583 | 8 | , literal_u8(0) | |
| 584 | 8 | , literal_u16(0) | |
| 585 | 8 | , literal_u32(0) | |
| 586 | 8 | , literal_u64(0L) | |
| 587 | 8 | , literal_i8(0) | |
| 588 | 8 | , literal_i16(0) | |
| 589 | 8 | , literal_i32(_literal_i32) | |
| 590 | 8 | , literal_i64(0) | |
| 591 | 8 | {} | |
| 592 | 10 | OperationLiteralInt::OperationLiteralInt( | |
| 593 | const Gyoji::context::SourceReference & _src_ref, | ||
| 594 | size_t _result, | ||
| 595 | Type::TypeType _literal_type, | ||
| 596 | long _literal_i64 | ||
| 597 | 10 | ) | |
| 598 | : Operation(OP_LITERAL_INT, _src_ref, _result) | ||
| 599 | 10 | , literal_type(_literal_type) | |
| 600 | 10 | , literal_u8(0) | |
| 601 | 10 | , literal_u16(0) | |
| 602 | 10 | , literal_u32(0) | |
| 603 | 10 | , literal_u64(0) | |
| 604 | 10 | , literal_i8(0) | |
| 605 | 10 | , literal_i16(0) | |
| 606 | 10 | , literal_i32(0) | |
| 607 | 10 | , literal_i64(_literal_i64) | |
| 608 | 10 | {} | |
| 609 | |||
| 610 | 968 | OperationLiteralInt::~OperationLiteralInt() | |
| 611 | 968 | {} | |
| 612 | |||
| 613 | Type::TypeType | ||
| 614 | 222 | OperationLiteralInt::get_literal_type() const | |
| 615 | 222 | { return literal_type; } | |
| 616 | unsigned char | ||
| 617 | 10 | OperationLiteralInt::get_literal_u8() const | |
| 618 | 10 | { return literal_u8; } | |
| 619 | unsigned short | ||
| 620 | 14 | OperationLiteralInt::get_literal_u16() const | |
| 621 | 14 | { return literal_u16; } | |
| 622 | unsigned int | ||
| 623 | 146 | OperationLiteralInt::get_literal_u32() const | |
| 624 | 146 | { return literal_u32; } | |
| 625 | unsigned long | ||
| 626 | 18 | OperationLiteralInt::get_literal_u64() const | |
| 627 | 18 | { return literal_u64; } | |
| 628 | char | ||
| 629 | 10 | OperationLiteralInt::get_literal_i8() const | |
| 630 | 10 | { return literal_i8; } | |
| 631 | short | ||
| 632 | 6 | OperationLiteralInt::get_literal_i16() const | |
| 633 | 6 | { return literal_i16; } | |
| 634 | int | ||
| 635 | 8 | OperationLiteralInt::get_literal_i32() const | |
| 636 | 8 | { return literal_i32; } | |
| 637 | long | ||
| 638 | 10 | OperationLiteralInt::get_literal_i64() const | |
| 639 | 10 | { return literal_i64; } | |
| 640 | |||
| 641 | std::string | ||
| 642 | 222 | OperationLiteralInt::get_description() const | |
| 643 | { | ||
| 644 | 222 | const auto & it = op_type_names.find(type); | |
| 645 | 222 | const std::string & op_name = it->second; | |
| 646 | |||
| 647 | 222 | std::string literalstr; | |
| 648 | 222 | std::string literaltype; | |
| 649 | |||
| 650 |
8/9✓ Branch 0 taken 10 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 146 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 10 times.
✗ Branch 8 not taken.
|
222 | switch (literal_type) { |
| 651 | 10 | case Type::TYPE_PRIMITIVE_u8: | |
| 652 | 10 | literalstr = std::to_string(literal_u8); | |
| 653 | 10 | literaltype = "u8"; | |
| 654 | 10 | break; | |
| 655 | 14 | case Type::TYPE_PRIMITIVE_u16: | |
| 656 | 14 | literalstr = std::to_string(literal_u16); | |
| 657 | 14 | literaltype = "u16"; | |
| 658 | 14 | break; | |
| 659 | 146 | case Type::TYPE_PRIMITIVE_u32: | |
| 660 | 146 | literalstr = std::to_string(literal_u32); | |
| 661 | 146 | literaltype = "u32"; | |
| 662 | 146 | break; | |
| 663 | 18 | case Type::TYPE_PRIMITIVE_u64: | |
| 664 | 18 | literalstr = std::to_string(literal_u64); | |
| 665 | 18 | literaltype = "u64"; | |
| 666 | 18 | break; | |
| 667 | 10 | case Type::TYPE_PRIMITIVE_i8: | |
| 668 | 10 | literalstr = std::to_string(literal_i8); | |
| 669 | 10 | literaltype = "i8"; | |
| 670 | 10 | break; | |
| 671 | 6 | case Type::TYPE_PRIMITIVE_i16: | |
| 672 | 6 | literalstr = std::to_string(literal_i16); | |
| 673 | 6 | literaltype = "i16"; | |
| 674 | 6 | break; | |
| 675 | 8 | case Type::TYPE_PRIMITIVE_i32: | |
| 676 | 8 | literalstr = std::to_string(literal_i32); | |
| 677 | 8 | literaltype = "i32"; | |
| 678 | 8 | break; | |
| 679 | 10 | case Type::TYPE_PRIMITIVE_i64: | |
| 680 | 10 | literalstr = std::to_string(literal_i64); | |
| 681 | 10 | literaltype = "i64"; | |
| 682 | 10 | break; | |
| 683 | ✗ | default: | |
| 684 | ✗ | literalstr = "Error: Unsupported literal int type"; | |
| 685 | ✗ | break; | |
| 686 | } | ||
| 687 | 1332 | std::string desc = std::string("_") + std::to_string(result) + std::string(" = ") + op_name + std::string(" ("); | |
| 688 | 444 | desc = desc + std::string(" ") + literalstr + literaltype; | |
| 689 | 222 | desc = desc + std::string(" )"); | |
| 690 | 222 | return desc; | |
| 691 | 222 | } | |
| 692 | |||
| 693 | ////////////////////////////////////////////// | ||
| 694 | // OperationLiteralFloat | ||
| 695 | ////////////////////////////////////////////// | ||
| 696 | |||
| 697 | 2 | OperationLiteralFloat::OperationLiteralFloat( | |
| 698 | const Gyoji::context::SourceReference & _src_ref, | ||
| 699 | size_t _result, | ||
| 700 | float _literal_float | ||
| 701 | 2 | ) | |
| 702 | : Operation(OP_LITERAL_FLOAT, _src_ref, _result) | ||
| 703 | 2 | , literal_type(Type::TYPE_PRIMITIVE_f32) | |
| 704 | 2 | , literal_float_f32(_literal_float) | |
| 705 | 2 | , literal_float_f64(0.0) | |
| 706 | 2 | {} | |
| 707 | 4 | OperationLiteralFloat::OperationLiteralFloat( | |
| 708 | const Gyoji::context::SourceReference & _src_ref, | ||
| 709 | size_t _result, | ||
| 710 | double _literal_float | ||
| 711 | 4 | ) | |
| 712 | : Operation(OP_LITERAL_FLOAT, _src_ref, _result) | ||
| 713 | 4 | , literal_type(Type::TYPE_PRIMITIVE_f64) | |
| 714 | 4 | , literal_float_f32(0.0) | |
| 715 | 4 | , literal_float_f64(_literal_float) | |
| 716 | 4 | {} | |
| 717 | 24 | OperationLiteralFloat::~OperationLiteralFloat() | |
| 718 | 24 | {} | |
| 719 | |||
| 720 | float | ||
| 721 | 2 | OperationLiteralFloat::get_literal_float() const | |
| 722 | 2 | { return literal_float_f32; } | |
| 723 | |||
| 724 | double | ||
| 725 | 4 | OperationLiteralFloat::get_literal_double() const | |
| 726 | 4 | { return literal_float_f64; } | |
| 727 | |||
| 728 | Type::TypeType | ||
| 729 | 6 | OperationLiteralFloat::get_literal_type() const | |
| 730 | 6 | { return literal_type; } | |
| 731 | std::string | ||
| 732 | 6 | OperationLiteralFloat::get_description() const | |
| 733 | { | ||
| 734 | 6 | const auto & it = op_type_names.find(type); | |
| 735 | 6 | const std::string & op_name = it->second; | |
| 736 | |||
| 737 | 6 | std::string literal_float; | |
| 738 |
2/3✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
|
6 | switch (literal_type) { |
| 739 | 2 | case Type::TYPE_PRIMITIVE_f32: | |
| 740 | 2 | literal_float = std::to_string(literal_float_f32) + std::string(" f32"); | |
| 741 | 2 | break; | |
| 742 | 4 | case Type::TYPE_PRIMITIVE_f64: | |
| 743 | 4 | literal_float = std::to_string(literal_float_f64) + std::string(" f64"); | |
| 744 | 4 | break; | |
| 745 | ✗ | default: | |
| 746 | ✗ | fprintf(stderr, "Compiler Bug! Unknown literal float type\n"); | |
| 747 | ✗ | exit(1); | |
| 748 | } | ||
| 749 | |||
| 750 | 36 | std::string desc = std::string("_") + std::to_string(result) + std::string(" = ") + op_name + std::string(" ("); | |
| 751 | 12 | desc = desc + std::string(" ") + literal_float; | |
| 752 | 6 | desc = desc + std::string(" )"); | |
| 753 | 6 | return desc; | |
| 754 | 6 | } | |
| 755 | |||
| 756 | ////////////////////////////////////////////// | ||
| 757 | // OperationLiteralBool | ||
| 758 | ////////////////////////////////////////////// | ||
| 759 | ✗ | OperationLiteralBool::OperationLiteralBool( | |
| 760 | const Gyoji::context::SourceReference & _src_ref, | ||
| 761 | size_t _result, | ||
| 762 | bool _literal_bool | ||
| 763 | ✗ | ) | |
| 764 | : Operation(OP_LITERAL_BOOL, _src_ref, _result) | ||
| 765 | ✗ | , literal_bool(_literal_bool) | |
| 766 | ✗ | {} | |
| 767 | ✗ | OperationLiteralBool::~OperationLiteralBool() | |
| 768 | ✗ | {} | |
| 769 | bool | ||
| 770 | ✗ | OperationLiteralBool::get_literal_bool() const | |
| 771 | ✗ | { return literal_bool; } | |
| 772 | std::string | ||
| 773 | ✗ | OperationLiteralBool::get_description() const | |
| 774 | { | ||
| 775 | ✗ | const auto & it = op_type_names.find(type); | |
| 776 | ✗ | const std::string & op_name = it->second; | |
| 777 | ✗ | std::string desc = std::string("_") + std::to_string(result) + std::string(" = ") + op_name + std::string(" ("); | |
| 778 | ✗ | desc = desc + std::string(" ") + (literal_bool ? std::string("true") : std::string("false")); | |
| 779 | ✗ | desc = desc + std::string(" )"); | |
| 780 | ✗ | return desc; | |
| 781 | } | ||
| 782 | ////////////////////////////////////////////// | ||
| 783 | // OperationLiteralNull | ||
| 784 | ////////////////////////////////////////////// | ||
| 785 | ✗ | OperationLiteralNull::OperationLiteralNull( | |
| 786 | const Gyoji::context::SourceReference & _src_ref, | ||
| 787 | size_t _result | ||
| 788 | ✗ | ) | |
| 789 | ✗ | : Operation(OP_LITERAL_NULL, _src_ref, _result) | |
| 790 | ✗ | {} | |
| 791 | ✗ | OperationLiteralNull::~OperationLiteralNull() | |
| 792 | ✗ | {} | |
| 793 | std::string | ||
| 794 | ✗ | OperationLiteralNull::get_description() const | |
| 795 | { | ||
| 796 | ✗ | const auto & it = op_type_names.find(type); | |
| 797 | ✗ | const std::string & op_name = it->second; | |
| 798 | ✗ | std::string desc = std::string("_") + std::to_string(result) + std::string(" = ") + op_name + std::string(" ( )"); | |
| 799 | ✗ | return desc; | |
| 800 | } | ||
| 801 | |||
| 802 | |||
| 803 | ////////////////////////////////////////////// | ||
| 804 | // OperationJumpConditional | ||
| 805 | ////////////////////////////////////////////// | ||
| 806 | 38 | OperationJumpConditional::OperationJumpConditional( | |
| 807 | const Gyoji::context::SourceReference & _src_ref, | ||
| 808 | size_t _operand, | ||
| 809 | size_t _if_block, | ||
| 810 | size_t _else_block | ||
| 811 | 38 | ) | |
| 812 | 38 | : Operation(OP_JUMP_CONDITIONAL, _src_ref, 0, _operand, _if_block, _else_block) | |
| 813 | 38 | {} | |
| 814 | |||
| 815 | 152 | OperationJumpConditional::~OperationJumpConditional() | |
| 816 | 152 | {} | |
| 817 | |||
| 818 | std::string | ||
| 819 | 38 | OperationJumpConditional::get_description() const | |
| 820 | { | ||
| 821 | 38 | const auto & it = op_type_names.find(type); | |
| 822 | 38 | const std::string & op_name = it->second; | |
| 823 | |||
| 824 | 38 | std::string desc = op_name + std::string(" ("); | |
| 825 | 114 | desc = desc + std::string(" _") + std::to_string(operands.at(0)); | |
| 826 | 114 | desc = desc + std::string(" BB") + std::to_string(operands.at(1)); | |
| 827 | 114 | desc = desc + std::string(" BB") + std::to_string(operands.at(2)); | |
| 828 | 38 | desc = desc + std::string(" )"); | |
| 829 | 38 | return desc; | |
| 830 | } | ||
| 831 | |||
| 832 | ////////////////////////////////////////////// | ||
| 833 | // OperationJump | ||
| 834 | ////////////////////////////////////////////// | ||
| 835 | 40 | OperationJump::OperationJump( | |
| 836 | const Gyoji::context::SourceReference & _src_ref, | ||
| 837 | size_t _block | ||
| 838 | 40 | ) | |
| 839 | 40 | : Operation(OP_JUMP, _src_ref, 0, _block) | |
| 840 | 40 | {} | |
| 841 | 160 | OperationJump::~OperationJump() | |
| 842 | 160 | {} | |
| 843 | |||
| 844 | std::string | ||
| 845 | 40 | OperationJump::get_description() const | |
| 846 | { | ||
| 847 | 40 | const auto & it = op_type_names.find(type); | |
| 848 | 40 | const std::string & op_name = it->second; | |
| 849 | |||
| 850 | 40 | std::string desc = op_name + std::string(" ("); | |
| 851 | 120 | desc = desc + std::string(" BB") + std::to_string(operands.at(0)); | |
| 852 | 40 | desc = desc + std::string(" )"); | |
| 853 | 40 | return desc; | |
| 854 | } | ||
| 855 | |||
| 856 | ////////////////////////////////////////////// | ||
| 857 | // OperationReturn | ||
| 858 | ////////////////////////////////////////////// | ||
| 859 | 282 | OperationReturn::OperationReturn( | |
| 860 | const Gyoji::context::SourceReference & _src_ref, | ||
| 861 | size_t _operand | ||
| 862 | 282 | ) | |
| 863 | 282 | : Operation(OP_RETURN, _src_ref, 0, _operand) | |
| 864 | 282 | {} | |
| 865 | 1128 | OperationReturn::~OperationReturn() | |
| 866 | 1128 | {} | |
| 867 | |||
| 868 | std::string | ||
| 869 | 282 | OperationReturn::get_description() const | |
| 870 | { | ||
| 871 | 282 | const auto & it = op_type_names.find(type); | |
| 872 | 282 | const std::string & op_name = it->second; | |
| 873 | |||
| 874 | 282 | std::string desc = op_name + std::string(" ("); | |
| 875 | 846 | desc = desc + std::string(" _") + std::to_string(operands.at(0)); | |
| 876 | 282 | desc = desc + std::string(" )"); | |
| 877 | 282 | return desc; | |
| 878 | } | ||
| 879 | |||
| 880 | ////////////////////////////////////////////// | ||
| 881 | // OperationReturnVoid | ||
| 882 | ////////////////////////////////////////////// | ||
| 883 | 2 | OperationReturnVoid::OperationReturnVoid( | |
| 884 | const Gyoji::context::SourceReference & _src_ref | ||
| 885 | 2 | ) | |
| 886 | 2 | : Operation(OP_RETURN_VOID, _src_ref, 0, 0) | |
| 887 | 2 | {} | |
| 888 | 8 | OperationReturnVoid::~OperationReturnVoid() | |
| 889 | 8 | {} | |
| 890 | |||
| 891 | std::string | ||
| 892 | 2 | OperationReturnVoid::get_description() const | |
| 893 | { | ||
| 894 | 2 | const auto & it = op_type_names.find(type); | |
| 895 | 2 | const std::string & op_name = it->second; | |
| 896 | 2 | return op_name; | |
| 897 | } | ||
| 898 | |||
| 899 | ////////////////////////////////////////////// | ||
| 900 | // OperationLocalDeclare | ||
| 901 | ////////////////////////////////////////////// | ||
| 902 | 310 | OperationLocalDeclare::OperationLocalDeclare( | |
| 903 | const Gyoji::context::SourceReference & _src_ref, | ||
| 904 | std::string _variable, | ||
| 905 | const Type *_variable_type | ||
| 906 | 310 | ) | |
| 907 | : Operation(OP_LOCAL_DECLARE, _src_ref, 0) | ||
| 908 | 310 | , variable(_variable) | |
| 909 | 310 | , variable_type(_variable_type) | |
| 910 | 310 | {} | |
| 911 | 1240 | OperationLocalDeclare::~OperationLocalDeclare() | |
| 912 | 1240 | {} | |
| 913 | const std::string & | ||
| 914 | 620 | OperationLocalDeclare::get_variable() const | |
| 915 | 620 | { return variable; } | |
| 916 | const Type* | ||
| 917 | 310 | OperationLocalDeclare::get_variable_type() const | |
| 918 | 310 | { return variable_type; } | |
| 919 | |||
| 920 | std::string | ||
| 921 | 310 | OperationLocalDeclare::get_description() const | |
| 922 | { | ||
| 923 | 310 | const auto & it = op_type_names.find(type); | |
| 924 | 310 | const std::string & op_name = it->second; | |
| 925 | |||
| 926 | 310 | std::string desc = op_name + std::string(" ("); | |
| 927 | 620 | desc = desc + std::string(" ") + variable; | |
| 928 | 930 | desc = desc + std::string(" ") + variable_type->get_name(); | |
| 929 | 310 | desc = desc + std::string(" )"); | |
| 930 | 310 | return desc; | |
| 931 | } | ||
| 932 | ////////////////////////////////////////////// | ||
| 933 | // OperationLocalUndeclare | ||
| 934 | ////////////////////////////////////////////// | ||
| 935 | 906 | OperationLocalUndeclare::OperationLocalUndeclare( | |
| 936 | const Gyoji::context::SourceReference & _src_ref, | ||
| 937 | std::string _variable | ||
| 938 | 906 | ) | |
| 939 | : Operation(OP_LOCAL_UNDECLARE, _src_ref, 0) | ||
| 940 | 906 | , variable(_variable) | |
| 941 | 906 | {} | |
| 942 | |||
| 943 | 3624 | OperationLocalUndeclare::~OperationLocalUndeclare() | |
| 944 | 3624 | {} | |
| 945 | |||
| 946 | std::string | ||
| 947 | 906 | OperationLocalUndeclare::get_description() const | |
| 948 | { | ||
| 949 | 906 | const auto & it = op_type_names.find(type); | |
| 950 | 906 | const std::string & op_name = it->second; | |
| 951 | |||
| 952 | 906 | std::string desc = op_name + std::string(" ("); | |
| 953 | 2718 | desc = desc + std::string(" ") + variable; | |
| 954 | 906 | desc = desc + std::string(" )"); | |
| 955 | 906 | return desc; | |
| 956 | } | ||
| 957 | ////////////////////////////////////////////// | ||
| 958 | // OperationSizeofType | ||
| 959 | ////////////////////////////////////////////// | ||
| 960 | 8 | OperationSizeofType::OperationSizeofType( | |
| 961 | const Gyoji::context::SourceReference & _src_ref, | ||
| 962 | size_t _result, | ||
| 963 | const Type *_type | ||
| 964 | 8 | ) | |
| 965 | : Operation(OP_SIZEOF_TYPE, _src_ref, _result) | ||
| 966 | 8 | , type(_type) | |
| 967 | 8 | {} | |
| 968 | 32 | OperationSizeofType::~OperationSizeofType() | |
| 969 | 32 | {} | |
| 970 | |||
| 971 | const Type * | ||
| 972 | 8 | OperationSizeofType::get_type() const | |
| 973 | 8 | { return type; } | |
| 974 | |||
| 975 |