Generate BLR for a constant.
| 7664 | |
| 7665 | // Generate BLR for a constant. |
| 7666 | void LiteralNode::genConstant(DsqlCompilerScratch* dsqlScratch, const dsc* desc, bool negateValue, USHORT numStringLength) |
| 7667 | { |
| 7668 | SLONG value; |
| 7669 | SINT64 i64value; |
| 7670 | |
| 7671 | dsqlScratch->appendUChar(blr_literal); |
| 7672 | |
| 7673 | const UCHAR* p = desc->dsc_address; |
| 7674 | |
| 7675 | switch (desc->dsc_dtype) |
| 7676 | { |
| 7677 | case dtype_short: |
| 7678 | value = *(SSHORT*) p; |
| 7679 | if (negateValue) |
| 7680 | { |
| 7681 | if (!value) |
| 7682 | { |
| 7683 | genNegZero(dsqlScratch, 0); |
| 7684 | return; |
| 7685 | } |
| 7686 | value = -value; |
| 7687 | } |
| 7688 | |
| 7689 | GEN_descriptor(dsqlScratch, desc, true); |
| 7690 | dsqlScratch->appendUShort(value); |
| 7691 | break; |
| 7692 | |
| 7693 | case dtype_long: |
| 7694 | value = *(SLONG*) p; |
| 7695 | if (negateValue) |
| 7696 | { |
| 7697 | if (!value) |
| 7698 | { |
| 7699 | genNegZero(dsqlScratch, 0); |
| 7700 | return; |
| 7701 | } |
| 7702 | value = -value; |
| 7703 | } |
| 7704 | |
| 7705 | GEN_descriptor(dsqlScratch, desc, true); |
| 7706 | dsqlScratch->appendUShort(value); |
| 7707 | dsqlScratch->appendUShort(value >> 16); |
| 7708 | break; |
| 7709 | |
| 7710 | case dtype_sql_time: |
| 7711 | case dtype_sql_date: |
| 7712 | GEN_descriptor(dsqlScratch, desc, true); |
| 7713 | value = *(SLONG*) p; |
| 7714 | dsqlScratch->appendUShort(value); |
| 7715 | dsqlScratch->appendUShort(value >> 16); |
| 7716 | break; |
| 7717 | |
| 7718 | case dtype_sql_time_tz: |
| 7719 | GEN_descriptor(dsqlScratch, desc, true); |
| 7720 | value = *(SLONG*) p; |
| 7721 | dsqlScratch->appendUShort(value); |
| 7722 | dsqlScratch->appendUShort(value >> 16); |
| 7723 | value = *(SSHORT*) (p + 4); |
nothing calls this directly
no test coverage detected