8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 18:43:02 +01:00

Output initially hex constants as hex, avoiding fr example use of -1 instead 0xFFFFFFFF

This commit is contained in:
AlexPeshkoff 2020-03-24 18:20:23 +03:00
parent fd2ab9d2cd
commit 9e7eb8c082
7 changed files with 26 additions and 22 deletions

View File

@ -29,15 +29,18 @@ using std::string;
//--------------------------------------
IntLiteralExpr::IntLiteralExpr(int value)
: value(value)
IntLiteralExpr::IntLiteralExpr(int value, bool hex)
: value(value), hex(hex)
{
}
string IntLiteralExpr::generate(Language language, const string& prefix)
{
char buffer[64];
sprintf(buffer, "%d", value);
if (hex)
sprintf(buffer, "%s%x", language == LANGUAGE_PASCAL ? "$" : "0x", value);
else
sprintf(buffer, "%d", value);
return buffer;
}

View File

@ -51,13 +51,14 @@ public:
class IntLiteralExpr : public Expr
{
public:
IntLiteralExpr(int value);
IntLiteralExpr(int value, bool hex);
public:
virtual std::string generate(Language language, const std::string& prefix);
private:
int value;
bool hex;
};

View File

@ -310,7 +310,7 @@ Expr* Parser::parsePrimaryExpr()
int base = len > 2 && tolower(p[1]) == 'x' ? 16 : 10;
long val = strtol(p, NULL, base);
return new IntLiteralExpr((int) val);
return new IntLiteralExpr((int) val, base == 16);
}
case Token::TYPE_IDENTIFIER:

View File

@ -43,7 +43,7 @@ CLOOP_EXTERN_C void CALC_IDisposable_dispose(struct CALC_IDisposable* self);
#define CALC_IStatus_VERSION 2
#define CALC_IStatus_ERROR_1 ((int) (1))
#define CALC_IStatus_ERROR_2 ((int) (2))
#define CALC_IStatus_ERROR_2 ((int) (0x2))
#define CALC_IStatus_ERROR_12 ((int) (CALC_IStatus_ERROR_1 | CALC_IStatus_ERROR_2))
struct CALC_IStatus;

View File

@ -88,7 +88,7 @@ namespace calc
static const unsigned VERSION = 2;
static const int ERROR_1 = 1;
static const int ERROR_2 = 2;
static const int ERROR_2 = 0x2;
static const int ERROR_12 = IStatus::ERROR_1 | IStatus::ERROR_2;
int getCode() const

View File

@ -79,7 +79,7 @@ end;
Status = class(Disposable)
const VERSION = 2;
const ERROR_1 = Integer(1);
const ERROR_2 = Integer(2);
const ERROR_2 = Integer($2);
const ERROR_12 = Integer(Status.ERROR_1 or Status.ERROR_2);
function getCode(): Integer;

View File

@ -239,8 +239,8 @@ namespace Firebird
public:
static const unsigned VERSION = 3;
static const unsigned STATE_WARNINGS = 1;
static const unsigned STATE_ERRORS = 2;
static const unsigned STATE_WARNINGS = 0x1;
static const unsigned STATE_ERRORS = 0x2;
static const int RESULT_ERROR = -1;
static const int RESULT_OK = 0;
static const int RESULT_NO_DATA = 1;
@ -1639,19 +1639,19 @@ namespace Firebird
public:
static const unsigned VERSION = 4;
static const unsigned PREPARE_PREFETCH_NONE = 0;
static const unsigned PREPARE_PREFETCH_TYPE = 1;
static const unsigned PREPARE_PREFETCH_INPUT_PARAMETERS = 2;
static const unsigned PREPARE_PREFETCH_OUTPUT_PARAMETERS = 4;
static const unsigned PREPARE_PREFETCH_LEGACY_PLAN = 8;
static const unsigned PREPARE_PREFETCH_DETAILED_PLAN = 16;
static const unsigned PREPARE_PREFETCH_AFFECTED_RECORDS = 32;
static const unsigned PREPARE_PREFETCH_FLAGS = 64;
static const unsigned PREPARE_PREFETCH_NONE = 0x0;
static const unsigned PREPARE_PREFETCH_TYPE = 0x1;
static const unsigned PREPARE_PREFETCH_INPUT_PARAMETERS = 0x2;
static const unsigned PREPARE_PREFETCH_OUTPUT_PARAMETERS = 0x4;
static const unsigned PREPARE_PREFETCH_LEGACY_PLAN = 0x8;
static const unsigned PREPARE_PREFETCH_DETAILED_PLAN = 0x10;
static const unsigned PREPARE_PREFETCH_AFFECTED_RECORDS = 0x20;
static const unsigned PREPARE_PREFETCH_FLAGS = 0x40;
static const unsigned PREPARE_PREFETCH_METADATA = IStatement::PREPARE_PREFETCH_TYPE | IStatement::PREPARE_PREFETCH_FLAGS | IStatement::PREPARE_PREFETCH_INPUT_PARAMETERS | IStatement::PREPARE_PREFETCH_OUTPUT_PARAMETERS;
static const unsigned PREPARE_PREFETCH_ALL = IStatement::PREPARE_PREFETCH_METADATA | IStatement::PREPARE_PREFETCH_LEGACY_PLAN | IStatement::PREPARE_PREFETCH_DETAILED_PLAN | IStatement::PREPARE_PREFETCH_AFFECTED_RECORDS;
static const unsigned FLAG_HAS_CURSOR = 1;
static const unsigned FLAG_REPEAT_EXECUTE = 2;
static const unsigned CURSOR_TYPE_SCROLLABLE = 1;
static const unsigned FLAG_HAS_CURSOR = 0x1;
static const unsigned FLAG_REPEAT_EXECUTE = 0x2;
static const unsigned CURSOR_TYPE_SCROLLABLE = 0x1;
template <typename StatusType> void getInfo(StatusType* status, unsigned itemsLength, const unsigned char* items, unsigned bufferLength, unsigned char* buffer)
{
@ -1922,7 +1922,7 @@ namespace Firebird
static const int EXECUTE_FAILED = -1;
static const int SUCCESS_NO_INFO = -2;
static const unsigned NO_MORE_ERRORS = -1;
static const unsigned NO_MORE_ERRORS = 0xffffffff;
template <typename StatusType> unsigned getSize(StatusType* status)
{