-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.h
97 lines (81 loc) · 1.94 KB
/
main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef __MAIN_H__
#define __MAIN_H__
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#define items(a) (sizeof(a) / sizeof(*(a)))
#define bool int
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
#define VERSION "3.50"
// Some declarations
extern bool language_c;
extern bool no_array_assign_operator;
extern bool compile_system_library;
extern bool small_enum;
extern bool unsigned_comparison;
extern bool nological;
extern bool force_logical;
extern bool turbo_pascal;
extern bool use_c_strings;
extern bool extern_vars;
extern bool preserve_case;
extern bool nested_comments;
extern bool copy_array;
extern bool comment_tags;
extern bool use_namespaces;
extern bool smart_union;
extern bool no_index_decrement;
extern bool ignore_preprocessor_directives;
extern bool hp_pascal;
extern bool do_not_use_enums;
extern char* pascall;
extern char path_sep;
#define CALL_GRAPH_FILE "call.grp"
#define RECURSIVE_PROC_FILE "recur.prc"
#ifdef PREFIX
#define CONFIG_FILE PREFIX "/etc/ptoc.cfg"
#else
#define CONFIG_FILE "ptoc.cfg"
#endif
#ifdef _WIN32
#define PATH_SEP '\\'
#else
#define PATH_SEP '/'
#endif
extern bool use_call_graph;
extern bool pio_init;
extern bool short_set;
extern FILE* call_graph_file;
bool is_recursive_proc(const char* name);
void scanner_input(char *file);
class memory_allocator {
private:
size_t free;
char* ptr;
public:
void* alloc(size_t size) {
const size_t alloc_quant = 8;
const size_t alloc_block = 1024*1024;
size = (size + alloc_quant - 1) & ~(alloc_quant - 1);
if (size > free) {
free = (alloc_block < size) ? size : alloc_block;
ptr = (char*)malloc(free);
}
free -= size;
void* t = (void*)ptr;
ptr += size;
return t;
}
memory_allocator() { free = 0; }
};
extern memory_allocator heap;
class heap_object {
public:
void* operator new(size_t size) { return heap.alloc(size); }
};
#endif