HyperDbg Debugger
Loading...
Searching...
No Matches
type.h File Reference

Go to the source code of this file.

Classes

struct  VARIABLE_TYPE
 

Macros

#define TYPE_H
 

Typedefs

typedef struct VARIABLE_TYPE VARIABLE_TYPE
 

Enumerations

enum  VARIABLE_TYPE_KIND {
  TY_UNKNOWN , TY_VOID , TY_BOOL , TY_CHAR ,
  TY_SHORT , TY_INT , TY_LONG , TY_FLOAT ,
  TY_DOUBLE , TY_LDOUBLE , TY_ENUM , TY_PTR ,
  TY_FUNC , TY_ARRAY , TY_VLA , TY_STRUCT ,
  TY_UNION
}
 

Functions

VARIABLE_TYPEHandleType (PTOKEN_LIST PtokenStack)
 Return a variable type.
 

Variables

VARIABLE_TYPEVARIABLE_TYPE_UNKNOWN
 
VARIABLE_TYPEVARIABLE_TYPE_VOID
 
VARIABLE_TYPEVARIABLE_TYPE_BOOL
 
VARIABLE_TYPEVARIABLE_TYPE_CHAR
 
VARIABLE_TYPEVARIABLE_TYPE_SHORT
 
VARIABLE_TYPEVARIABLE_TYPE_INT
 
VARIABLE_TYPEVARIABLE_TYPE_LONG
 
VARIABLE_TYPEVARIABLE_TYPE_UCHAR
 
VARIABLE_TYPEVARIABLE_TYPE_USHORT
 
VARIABLE_TYPEVARIABLE_TYPE_UINT
 
VARIABLE_TYPEVARIABLE_TYPE_ULONG
 
VARIABLE_TYPEVARIABLE_TYPE_FLOAT
 
VARIABLE_TYPEVARIABLE_TYPE_DOUBLE
 
VARIABLE_TYPEVARIABLE_TYPE_LDOUBLE
 

Macro Definition Documentation

◆ TYPE_H

#define TYPE_H

Typedef Documentation

◆ VARIABLE_TYPE

typedef struct VARIABLE_TYPE VARIABLE_TYPE

Enumeration Type Documentation

◆ VARIABLE_TYPE_KIND

Enumerator
TY_UNKNOWN 
TY_VOID 
TY_BOOL 
TY_CHAR 
TY_SHORT 
TY_INT 
TY_LONG 
TY_FLOAT 
TY_DOUBLE 
TY_LDOUBLE 
TY_ENUM 
TY_PTR 
TY_FUNC 
TY_ARRAY 
TY_VLA 
TY_STRUCT 
TY_UNION 
7{
10 TY_BOOL,
11 TY_CHAR,
13 TY_INT,
14 TY_LONG,
18 TY_ENUM,
19 TY_PTR,
20 TY_FUNC,
22 TY_VLA, // variable-length array
VARIABLE_TYPE_KIND
Definition type.h:7
@ TY_PTR
Definition type.h:19
@ TY_SHORT
Definition type.h:12
@ TY_VOID
Definition type.h:9
@ TY_STRUCT
Definition type.h:23
@ TY_UNION
Definition type.h:24
@ TY_INT
Definition type.h:13
@ TY_DOUBLE
Definition type.h:16
@ TY_FLOAT
Definition type.h:15
@ TY_CHAR
Definition type.h:11
@ TY_VLA
Definition type.h:22
@ TY_ENUM
Definition type.h:18
@ TY_LDOUBLE
Definition type.h:17
@ TY_LONG
Definition type.h:14
@ TY_ARRAY
Definition type.h:21
@ TY_UNKNOWN
Definition type.h:8
@ TY_FUNC
Definition type.h:20
@ TY_BOOL
Definition type.h:10

Function Documentation

◆ HandleType()

VARIABLE_TYPE * HandleType ( PTOKEN_LIST PtokenStack)

Return a variable type.

Parameters
str
29{
30 enum
31 {
32 ENUM_VOID = 1 << 0,
33 ENUM_BOOL = 1 << 2,
34 ENUM_CHAR = 1 << 4,
35 ENUM_SHORT = 1 << 6,
36 ENUM_INT = 1 << 8,
37 ENUM_LONG = 1 << 10,
38 ENUM_FLOAT = 1 << 12,
39 ENUM_DOUBLE = 1 << 14,
40 ENUM_OTHER = 1 << 16,
41 ENUM_SIGNED = 1 << 17,
42 ENUM_UNSIGNED = 1 << 18,
43 };
44
46 int Counter = 0;
47 PTOKEN TopToken = NULL;
48
49 while (PtokenStack->Pointer > 0)
50 {
51 TopToken = Pop(PtokenStack);
52 if (TopToken->Type != INPUT_VARIABLE_TYPE)
53 {
54 Push(PtokenStack, TopToken);
55 break;
56 }
57 if (!strcmp(TopToken->Value, "@VOID"))
58 {
59 Counter += ENUM_VOID;
60 }
61 else if (!strcmp(TopToken->Value, "@BOOL"))
62 {
63 Counter += ENUM_BOOL;
64 }
65 else if (!strcmp(TopToken->Value, "@CHAR"))
66 {
67 Counter += ENUM_CHAR;
68 }
69 else if (!strcmp(TopToken->Value, "@SHORT"))
70 {
71 Counter += ENUM_SHORT;
72 }
73 else if (!strcmp(TopToken->Value, "@INT"))
74 {
75 Counter += ENUM_INT;
76 }
77 else if (!strcmp(TopToken->Value, "@LONG"))
78 {
79 Counter += ENUM_LONG;
80 }
81 else if (!strcmp(TopToken->Value, "@FLOAT"))
82 {
83 Counter += ENUM_FLOAT;
84 }
85 else if (!strcmp(TopToken->Value, "@DOUBLE"))
86 {
87 Counter += ENUM_DOUBLE;
88 }
89 else if (!strcmp(TopToken->Value, "@SIGNED"))
90 {
91 Counter |= ENUM_SIGNED;
92 }
93 else if (!strcmp(TopToken->Value, "@UNSIGNED"))
94 {
95 Counter |= ENUM_UNSIGNED;
96 }
97 else
98 {
100 }
101 RemoveToken(&TopToken);
102
103 switch (Counter)
104 {
105 case ENUM_VOID:
106 Result = VARIABLE_TYPE_VOID;
107 break;
108 case ENUM_BOOL:
109 Result = VARIABLE_TYPE_BOOL;
110 break;
111 case ENUM_CHAR:
112 case ENUM_SIGNED + ENUM_CHAR:
113 Result = VARIABLE_TYPE_CHAR;
114 break;
115 case ENUM_UNSIGNED + ENUM_CHAR:
116 Result = VARIABLE_TYPE_UCHAR;
117 break;
118 case ENUM_SHORT:
119 case ENUM_SHORT + ENUM_INT:
120 case ENUM_SIGNED + ENUM_SHORT:
121 case ENUM_SIGNED + ENUM_SHORT + ENUM_INT:
122 Result = VARIABLE_TYPE_INT;
123 break;
124 case ENUM_UNSIGNED + ENUM_SHORT:
125 case ENUM_UNSIGNED + ENUM_SHORT + ENUM_INT:
126 Result = VARIABLE_TYPE_USHORT;
127 break;
128 case ENUM_INT:
129 case ENUM_SIGNED:
130 case ENUM_SIGNED + ENUM_INT:
131 Result = VARIABLE_TYPE_INT;
132 break;
133 case ENUM_UNSIGNED:
134 case ENUM_UNSIGNED + ENUM_INT:
135 Result = VARIABLE_TYPE_UINT;
136 break;
137 case ENUM_LONG:
138 case ENUM_LONG + ENUM_INT:
139 case ENUM_LONG + ENUM_LONG:
140 case ENUM_LONG + ENUM_LONG + ENUM_INT:
141 case ENUM_SIGNED + ENUM_LONG:
142 case ENUM_SIGNED + ENUM_LONG + ENUM_INT:
143 case ENUM_SIGNED + ENUM_LONG + ENUM_LONG:
144 case ENUM_SIGNED + ENUM_LONG + ENUM_LONG + ENUM_INT:
145 Result = VARIABLE_TYPE_LONG;
146 break;
147 case ENUM_UNSIGNED + ENUM_LONG:
148 case ENUM_UNSIGNED + ENUM_LONG + ENUM_INT:
149 case ENUM_UNSIGNED + ENUM_LONG + ENUM_LONG:
150 case ENUM_UNSIGNED + ENUM_LONG + ENUM_LONG + ENUM_INT:
151 Result = VARIABLE_TYPE_ULONG;
152 break;
153 case ENUM_FLOAT:
154 Result = VARIABLE_TYPE_FLOAT;
155 break;
156 case ENUM_DOUBLE:
157 Result = VARIABLE_TYPE_DOUBLE;
158 break;
159 case ENUM_LONG + ENUM_DOUBLE:
160 Result = VARIABLE_TYPE_LDOUBLE;
161 break;
162 }
163 }
164 return Result;
165}
NULL()
Definition test-case-generator.py:530
PTOKEN Pop(PTOKEN_LIST TokenList)
Removes last Token of a TokenList and returns it.
Definition common.c:485
void RemoveToken(PTOKEN *Token)
Removes allocated memory of a token.
Definition common.c:104
PTOKEN_LIST Push(PTOKEN_LIST TokenList, PTOKEN Token)
Adds Token to the last empty position of TokenList.
Definition common.c:424
@ INPUT_VARIABLE_TYPE
Definition common.h:60
unsigned int Pointer
Definition common.h:85
read tokens from input stored in this structure
Definition common.h:72
char * Value
Definition common.h:74
TOKEN_TYPE Type
Definition common.h:73
Definition type.h:28
VARIABLE_TYPE * VARIABLE_TYPE_FLOAT
Definition type.c:18
VARIABLE_TYPE * VARIABLE_TYPE_UCHAR
Definition type.c:13
VARIABLE_TYPE * VARIABLE_TYPE_UNKNOWN
Definition type.c:3
VARIABLE_TYPE * VARIABLE_TYPE_DOUBLE
Definition type.c:19
VARIABLE_TYPE * VARIABLE_TYPE_ULONG
Definition type.c:16
VARIABLE_TYPE * VARIABLE_TYPE_VOID
Definition type.c:5
VARIABLE_TYPE * VARIABLE_TYPE_LONG
Definition type.c:11
VARIABLE_TYPE * VARIABLE_TYPE_BOOL
Definition type.c:6
VARIABLE_TYPE * VARIABLE_TYPE_INT
Definition type.c:10
VARIABLE_TYPE * VARIABLE_TYPE_CHAR
Definition type.c:8
VARIABLE_TYPE * VARIABLE_TYPE_UINT
Definition type.c:15
VARIABLE_TYPE * VARIABLE_TYPE_USHORT
Definition type.c:14
VARIABLE_TYPE * VARIABLE_TYPE_LDOUBLE
Definition type.c:20

Variable Documentation

◆ VARIABLE_TYPE_BOOL

VARIABLE_TYPE* VARIABLE_TYPE_BOOL
extern
6{TY_BOOL, 1, 1};

◆ VARIABLE_TYPE_CHAR

VARIABLE_TYPE* VARIABLE_TYPE_CHAR
extern
8{TY_CHAR, 1, 1};

◆ VARIABLE_TYPE_DOUBLE

VARIABLE_TYPE* VARIABLE_TYPE_DOUBLE
extern
19{TY_DOUBLE, 8, 8};

◆ VARIABLE_TYPE_FLOAT

VARIABLE_TYPE* VARIABLE_TYPE_FLOAT
extern
18{TY_FLOAT, 4, 4};

◆ VARIABLE_TYPE_INT

VARIABLE_TYPE* VARIABLE_TYPE_INT
extern
10{TY_INT, 4, 4};

◆ VARIABLE_TYPE_LDOUBLE

VARIABLE_TYPE* VARIABLE_TYPE_LDOUBLE
extern
20{TY_LDOUBLE, 16, 16};

◆ VARIABLE_TYPE_LONG

VARIABLE_TYPE* VARIABLE_TYPE_LONG
extern
11{TY_LONG, 8, 8};

◆ VARIABLE_TYPE_SHORT

VARIABLE_TYPE* VARIABLE_TYPE_SHORT
extern
9{TY_SHORT, 2, 2};

◆ VARIABLE_TYPE_UCHAR

VARIABLE_TYPE* VARIABLE_TYPE_UCHAR
extern
13{TY_CHAR, 1, 1, TRUE};
#define TRUE
Definition BasicTypes.h:55

◆ VARIABLE_TYPE_UINT

VARIABLE_TYPE* VARIABLE_TYPE_UINT
extern
15{TY_INT, 4, 4, TRUE};

◆ VARIABLE_TYPE_ULONG

VARIABLE_TYPE* VARIABLE_TYPE_ULONG
extern
16{TY_LONG, 8, 8, TRUE};

◆ VARIABLE_TYPE_UNKNOWN

VARIABLE_TYPE* VARIABLE_TYPE_UNKNOWN
extern

◆ VARIABLE_TYPE_USHORT

VARIABLE_TYPE* VARIABLE_TYPE_USHORT
extern
14{TY_SHORT, 2, 2, TRUE};

◆ VARIABLE_TYPE_VOID

VARIABLE_TYPE* VARIABLE_TYPE_VOID
extern
5{TY_VOID, 1, 1};