Source file: /~heha/hsn/gputils64-210929.zip/libgputils/gptypes.h

/* libgputils typedefs
   Copyright 2001-2005	Craig Franklin
   Copyright 2016	Molnár Károly
*/

#pragma once
#include "stdhdr.h"

typedef long    gp_symvalue_t;

typedef int     gpasmVal;               /* The type that internal arithmetic uses. */

typedef struct hash128_t{
#ifdef __cplusplus
  hash128_t(const char*s,size_t l, bool tolower=false) {reset(); hash(s,l,tolower);}
  hash128_t(const char*s=0,bool tolower=false) {reset(); hash(s,tolower);}
  void reset();
  int compare(const hash128_t&)const;	// Vergleichsfunktion (Spaceship-Operator <=>), liefert -1, 0 oder +1
  void hash(uint32_t);			// Hash-Funktion Einzelzeichen
  void hash(const char*s,size_t l,bool tolower=false);	// Hash-Funktion Byte-Array
  void hash(const char*s,bool tolower=false) {if (s) hash(s,strlen(s),tolower);}
  bool operator==(const hash128_t&b)const{return compare(b)==0;}
  bool operator< (const hash128_t&b)const{return compare(b)<0;}
  bool operator> (const hash128_t&b)const{return compare(b)>0;}
private:
#endif
  uint64_t lo,hi;
}hash128_t;

#define BYTE_SIZE               (sizeof(uint8_t))
#define WORD_SIZE               (sizeof(uint16_t))
#define DWORD_SIZE              (sizeof(uint32_t))
#define QWORD_SIZE              (sizeof(uint64_t))

/*------------------------------------------------------------------------------------------------*/

/* Parse node: created by the parser, interpreted by the 'backend' */
enum pnode_tag {
    PTAG_CONSTANT = 0,
    PTAG_SYMBOL,
    PTAG_STRING,
    PTAG_OFFSET,
    PTAG_LIST,
    PTAG_BINOP,
    PTAG_UNOP
};

typedef struct pnode_t {
  enum pnode_tag tag;

  union {
    int             constant;
    const char     *symbol;
    char           *string;

    struct pnode_t   *offset;

    struct {
      struct pnode_t *head;
      struct pnode_t *tail;
    } list;

    struct {
      int           op;
      struct pnode_t *p0;
      struct pnode_t *p1;
    } binop;

    struct {
      int           op;
      struct pnode_t *p0;
    } unop;
  } value;
#ifdef __cplusplus
  pnode_t(pnode_tag ini):tag(ini) {}
#endif
}pnode_t;

#define PnIsConstant(Node)              (Node)->tag == PTAG_CONSTANT
#define PnIsSymbol(Node)                (Node)->tag == PTAG_SYMBOL
#define PnIsString(Node)                (Node)->tag == PTAG_STRING
#define PnIsOffset(Node)                (Node)->tag == PTAG_OFFSET
#define PnIsList(Node)                  (Node)->tag == PTAG_LIST
#define PnIsBinOp(Node)                 (Node)->tag == PTAG_BINOP
#define PnIsUnOp(Node)                  (Node)->tag == PTAG_UNOP

#define PnConstant(Node)                (Node)->value.constant
#define PnSymbol(Node)                  (Node)->value.symbol
#define PnString(Node)                  (Node)->value.string
#define PnOffset(Node)                  (Node)->value.offset
#define PnListHead(Node)                (Node)->value.list.head
#define PnListTail(Node)                (Node)->value.list.tail
#define PnBinOpOp(Node)                 (Node)->value.binop.op
#define PnBinOpP0(Node)                 (Node)->value.binop.p0
#define PnBinOpP1(Node)                 (Node)->value.binop.p1
#define PnUnOpOp(Node)                  (Node)->value.unop.op
#define PnUnOpP0(Node)                  (Node)->value.unop.p0
Detected encoding: UTF-80