Normalize logic operation keywords and add use msvc fix
Logical or should be only 'or','and','not', and not error prone '||','&&','!'
This commit is contained in:
@@ -5,11 +5,15 @@
|
||||
* (C) Cristina Cifuentes
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "Enums.h"
|
||||
#include "msvc_fixes.h"
|
||||
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include <stdint.h>
|
||||
#include <cstring>
|
||||
#include <list>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include "Enums.h"
|
||||
|
||||
static const int operandSize=20;
|
||||
/* The following definitions and types define the Conditional Expression
|
||||
* attributed syntax tree, as defined by the following EBNF:
|
||||
@@ -120,7 +124,7 @@ struct BinaryOperator : public Expr
|
||||
}
|
||||
~BinaryOperator()
|
||||
{
|
||||
assert(m_lhs!=m_rhs || m_lhs==nullptr);
|
||||
assert(m_lhs!=m_rhs or m_lhs==nullptr);
|
||||
delete m_lhs;
|
||||
delete m_rhs;
|
||||
m_lhs=m_rhs=nullptr;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <vector>
|
||||
#include "bundle.h"
|
||||
struct LLInst;
|
||||
struct Function;
|
||||
struct Disassembler
|
||||
{
|
||||
protected:
|
||||
|
||||
@@ -3,6 +3,19 @@
|
||||
* (C) Cristina Cifuentes
|
||||
****************************************************************************/
|
||||
#pragma once
|
||||
#include "msvc_fixes.h"
|
||||
#include "BinaryImage.h"
|
||||
#include "libdis.h"
|
||||
#include "Enums.h"
|
||||
#include "state.h" // State depends on INDEXBASE, but later need STATE
|
||||
#include "CallConvention.h"
|
||||
|
||||
#include <llvm/ADT/ilist.h>
|
||||
#include <llvm/ADT/ilist_node.h>
|
||||
#include <llvm/MC/MCInst.h>
|
||||
#include <llvm/IR/Instruction.h>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
@@ -10,15 +23,6 @@
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <initializer_list>
|
||||
#include <llvm/ADT/ilist.h>
|
||||
#include <llvm/ADT/ilist_node.h>
|
||||
#include <llvm/MC/MCInst.h>
|
||||
#include <llvm/IR/Instruction.h>
|
||||
#include <boost/range/iterator_range.hpp>
|
||||
#include "libdis.h"
|
||||
#include "Enums.h"
|
||||
#include "state.h" // State depends on INDEXBASE, but later need STATE
|
||||
#include "CallConvention.h"
|
||||
|
||||
//enum condId;
|
||||
|
||||
@@ -275,12 +279,12 @@ struct LLOperand
|
||||
}
|
||||
bool operator==(const LLOperand &with) const
|
||||
{
|
||||
return (seg==with.seg) &&
|
||||
(segOver==with.segOver) &&
|
||||
(segValue==with.segValue) &&
|
||||
(regi == with.regi) &&
|
||||
(off == with.off) &&
|
||||
(opz==with.opz) &&
|
||||
return (seg==with.seg) and
|
||||
(segOver==with.segOver) and
|
||||
(segValue==with.segValue) and
|
||||
(regi == with.regi) and
|
||||
(off == with.off) and
|
||||
(opz==with.opz) and
|
||||
(proc.proc==with.proc.proc);
|
||||
}
|
||||
int64_t getImm2() const {return opz;}
|
||||
@@ -330,7 +334,7 @@ public:
|
||||
int hllLabNum; /* label # for hll codegen */
|
||||
bool conditionalJump()
|
||||
{
|
||||
return (getOpcode() >= iJB) && (getOpcode() < iJCXZ);
|
||||
return (getOpcode() >= iJB) and (getOpcode() < iJCXZ);
|
||||
}
|
||||
bool testFlags(uint32_t x) const { return (flg & x)!=0;}
|
||||
void setFlags(uint32_t flag) {flg |= flag;}
|
||||
@@ -366,11 +370,11 @@ public:
|
||||
}
|
||||
bool match(llIcode op,eReg dest,eReg src_reg)
|
||||
{
|
||||
return (getOpcode()==op)&&(m_dst.regi==dest)&&(m_src.regi==src_reg);
|
||||
return (getOpcode()==op) and (m_dst.regi==dest) and (m_src.regi==src_reg);
|
||||
}
|
||||
bool match(eReg dest,eReg src_reg)
|
||||
{
|
||||
return (m_dst.regi==dest)&&(m_src.regi==src_reg);
|
||||
return (m_dst.regi==dest) and (m_src.regi==src_reg);
|
||||
}
|
||||
bool match(eReg dest)
|
||||
{
|
||||
@@ -460,14 +464,14 @@ public:
|
||||
template<int TYPE>
|
||||
struct TypeFilter
|
||||
{
|
||||
bool operator()(ICODE *ic) {return ic->type==HIGH_LEVEL;}
|
||||
bool operator()(ICODE &ic) {return ic.type==HIGH_LEVEL;}
|
||||
bool operator()(ICODE *ic) {return ic->type==TYPE;}
|
||||
bool operator()(ICODE &ic) {return ic.type==TYPE;}
|
||||
};
|
||||
template<int TYPE>
|
||||
struct TypeAndValidFilter
|
||||
{
|
||||
bool operator()(ICODE *ic) {return (ic->type==HIGH_LEVEL)&&(ic->valid());}
|
||||
bool operator()(ICODE &ic) {return (ic.type==HIGH_LEVEL)&&ic.valid();}
|
||||
bool operator()(ICODE *ic) {return (ic->type==TYPE) and (ic->valid());}
|
||||
bool operator()(ICODE &ic) {return (ic.type==TYPE) and ic.valid();}
|
||||
};
|
||||
static TypeFilter<HIGH_LEVEL> select_high_level;
|
||||
static TypeAndValidFilter<HIGH_LEVEL> select_valid_high_level;
|
||||
@@ -506,7 +510,7 @@ public:
|
||||
if(iter==uses.end())
|
||||
return;
|
||||
uses.erase(iter);
|
||||
assert("Same user more then once!" && uses.end()==std::find(uses.begin(),uses.end(),us));
|
||||
assert("Same user more then once!" and uses.end()==std::find(uses.begin(),uses.end(),us));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -6,14 +6,16 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "msvc_fixes.h"
|
||||
#include "types.h"
|
||||
#include "Enums.h"
|
||||
#include "machine_x86.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include "types.h"
|
||||
#include "Enums.h"
|
||||
#include "machine_x86.h"
|
||||
|
||||
/* Type definition */
|
||||
// this array has to stay in-order of addition i.e. not std::set<iICODE,std::less<iICODE> >
|
||||
@@ -105,11 +107,11 @@ public:
|
||||
protected:
|
||||
LONG_STKID_TYPE longStkId; /* For TYPE_LONG_(UN)SIGN on the stack */
|
||||
public:
|
||||
eReg regi; /* For TYPE_BYTE(uint16_t)_(UN)SIGN registers */
|
||||
struct { /* For TYPE_BYTE(uint16_t)_(UN)SIGN on the stack */
|
||||
eReg regi; /* For TYPE_BYTE(WORD)_(UN)SIGN registers */
|
||||
struct { /* For TYPE_BYTE(WORD)_(UN)SIGN on the stack */
|
||||
uint8_t regOff; /* register offset (if any) */
|
||||
int off; /* offset from BP */
|
||||
} bwId;
|
||||
} bwId;
|
||||
BWGLB_TYPE bwGlb; /* For TYPE_BYTE(uint16_t)_(UN)SIGN globals */
|
||||
LONGGLB_TYPE longGlb;
|
||||
struct { /* For TYPE_LONG_(UN)SIGN constants */
|
||||
@@ -118,21 +120,22 @@ public:
|
||||
} longKte;
|
||||
ID_UNION() { /*new (&longStkId) LONG_STKID_TYPE();*/}
|
||||
} id;
|
||||
LONGID_TYPE & longId() {assert(isLong() && loc==REG_FRAME); return m_longId;}
|
||||
const LONGID_TYPE & longId() const {assert(isLong() && loc==REG_FRAME); return m_longId;}
|
||||
LONG_STKID_TYPE & longStkId() {assert(isLong() && loc==STK_FRAME); return id.longStkId;}
|
||||
const LONG_STKID_TYPE & longStkId() const {assert(isLong() && loc==STK_FRAME); return id.longStkId;}
|
||||
|
||||
LONGID_TYPE & longId() {assert(isLong() and loc==REG_FRAME); return m_longId;}
|
||||
const LONGID_TYPE & longId() const {assert(isLong() and loc==REG_FRAME); return m_longId;}
|
||||
LONG_STKID_TYPE & longStkId() {assert(isLong() and loc==STK_FRAME); return id.longStkId;}
|
||||
const LONG_STKID_TYPE & longStkId() const {assert(isLong() and loc==STK_FRAME); return id.longStkId;}
|
||||
ID();
|
||||
ID(hlType t, frameType f);
|
||||
ID(hlType t, const LONGID_TYPE &s);
|
||||
ID(hlType t, const LONG_STKID_TYPE &s);
|
||||
ID(hlType t, const LONGGLB_TYPE &s);
|
||||
bool isSigned() const { return (type==TYPE_BYTE_SIGN)||(type==TYPE_WORD_SIGN)||(type==TYPE_LONG_SIGN);}
|
||||
bool isSigned() const { return (type==TYPE_BYTE_SIGN) or (type==TYPE_WORD_SIGN) or (type==TYPE_LONG_SIGN);}
|
||||
uint16_t typeBitsize() const
|
||||
{
|
||||
return TypeContainer::typeSize(type)*8;
|
||||
}
|
||||
bool isLong() const { return (type==TYPE_LONG_UNSIGN)||(type==TYPE_LONG_SIGN); }
|
||||
bool isLong() const { return (type==TYPE_LONG_UNSIGN) or (type==TYPE_LONG_SIGN); }
|
||||
void setLocalName(int i)
|
||||
{
|
||||
char buf[32];
|
||||
|
||||
@@ -3,10 +3,12 @@
|
||||
* (C) Mike van Emmerik
|
||||
*/
|
||||
#pragma once
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include "Enums.h"
|
||||
#include "types.h"
|
||||
#include "msvc_fixes.h"
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
struct Expr;
|
||||
struct AstIdent;
|
||||
struct TypeContainer;
|
||||
@@ -91,7 +93,7 @@ struct SYMTABLE
|
||||
{
|
||||
// does not yse pSymName, to ease finding by symOff/symProc combo
|
||||
// in map<SYMTABLE,X>
|
||||
return (symOff==other.symOff) && symProc==(other.symProc);
|
||||
return (symOff==other.symOff) and symProc==(other.symProc);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,9 +5,13 @@
|
||||
***************************************************************************
|
||||
*/
|
||||
#pragma once
|
||||
#include "Enums.h"
|
||||
#include "msvc_fixes.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <stdint.h>
|
||||
#include "Enums.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/**** Common definitions and macros ****/
|
||||
#define MAX 0x7FFFFFFF
|
||||
|
||||
@@ -25,7 +29,7 @@
|
||||
// Macro reads a LH word from the image regardless of host convention
|
||||
// Returns a 16 bit quantity, e.g. C000 is read into an Int as C000
|
||||
//#define LH(p) ((int16)((byte *)(p))[0] + ((int16)((byte *)(p))[1] << 8))
|
||||
#define LH(p) ((uint16_t)((uint8_t *)(p))[0] + ((uint16_t)((uint8_t *)(p))[1] << 8))
|
||||
#define LH(p) ((uint16_t)((uint8_t *)(p))[0] + ((uint16_t)((uint8_t *)(p))[1] << 8))
|
||||
|
||||
|
||||
/* Macro reads a LH word from the image regardless of host convention */
|
||||
@@ -64,12 +68,22 @@ struct eDuVal
|
||||
use = x&USE;
|
||||
val = x&VAL;
|
||||
}
|
||||
bool isUSE_VAL() {return use&&val;} //Use and Val
|
||||
bool isUSE_VAL() {return use and val;} //Use and Val
|
||||
};
|
||||
static constexpr const char * hlTypes[13] = {
|
||||
"", "char", "unsigned char", "int", "unsigned int",
|
||||
"long", "unsigned long", "record", "int *", "char *",
|
||||
"", "float", "double"
|
||||
"",
|
||||
"char",
|
||||
"unsigned char",
|
||||
"int",
|
||||
"unsigned int",
|
||||
"long",
|
||||
"unsigned long",
|
||||
"record",
|
||||
"int *",
|
||||
"char *",
|
||||
"",
|
||||
"float",
|
||||
"double"
|
||||
};
|
||||
|
||||
struct TypeContainer
|
||||
|
||||
Reference in New Issue
Block a user