| 373 | |
| 374 | |
| 375 | Symbol * |
| 376 | ASTNode::codegen_int (Symbol *, bool boolify, bool invert) |
| 377 | { |
| 378 | Symbol *dest = codegen (); |
| 379 | TypeSpec type = dest->typespec (); |
| 380 | if (! type.is_int() || boolify || invert) { |
| 381 | // If they're not using an int as the condition, then it's an |
| 382 | // implied comparison to zero. |
| 383 | Symbol *tempvar = m_compiler->make_temporary (TypeDesc::TypeInt); |
| 384 | Symbol *zerovar = NULL; |
| 385 | if (type.is_closure()) |
| 386 | zerovar = m_compiler->make_constant ((int)0); |
| 387 | else if (type.is_string()) |
| 388 | zerovar = m_compiler->make_constant (ustring("")); |
| 389 | else if (type.is_int()) |
| 390 | zerovar = m_compiler->make_constant ((int)0); |
| 391 | else |
| 392 | zerovar = m_compiler->make_constant (0.0f); |
| 393 | emitcode (invert ? "eq" : "neq", tempvar, dest, zerovar); |
| 394 | dest = tempvar; |
| 395 | } |
| 396 | return dest; |
| 397 | } |
| 398 | |
| 399 | |
| 400 |
no test coverage detected