Lhogho
0.0.028
Main Page
Related Pages
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Macros
Pages
atoms.h
Go to the documentation of this file.
1
//
2
// Project: Lhogho
3
// File: atoms.h
4
//
5
// Copyright (C) 2007 P.Boytchev
6
//
7
// Revision history:
8
// 2006-09-28 - file created
9
// 2006-09-30 - removed things supported by pools
10
// 2006-10-01 - added WORD_SIZE
11
// 2006-10-07 - introduced *_t types
12
// 2006-10-10 - read_word() and write_word()
13
// 2006-10-11 - UNICODE macro
14
// - export of parse_data_list()
15
// 2006-10-13 - append()
16
// 2006-10-17 - errpos/errchar to parse_data_list()
17
// SAFEMODE for parse()
18
// 2006-10-26 - IS_ERROR(), ERRPOS(), ERRSRC(), ERRCODE()
19
// - parse() return error atom
20
// - export of parse()
21
// 2006-10-27 - FLAG_*
22
// 2006-10-28 - bytes_t
23
// 2007-02-15 - removing EXPR and LISP types of lists
24
// 2007-02-27 - DESCR1(), DESCR2()
25
// - export of new_var()
26
// - module renamed to ATOMS
27
// 2007-03-01 - NULL
28
// 2007-03-18 - NEXT(),PREV(),DATA()
29
// - equal()
30
// 2007-03-20 - FLAG_PRIORITY_MUL/ADD/LOG/CMP
31
// 2007-05-17 - added license info
32
// 2007-05-22 - Added doxygen-friendly documentation
33
// 2007-05-27 - behead()
34
// 2007-05-31 - use_stdout()
35
// - hook
36
// 2007-06-05 - definitions spread to where they belong
37
// 2007-06-09 - word-related stuff moved to words module
38
// - list-related stuff moved to words module
39
// - number-related stuff moved to words module
40
// 2007-06-19 - added mem atoms
41
// 2009-06-02 - added use_stdin()
42
// 2010-06-25 - added inner_eof
43
//
44
//
45
// This program is free software; you can redistribute it and/or modify
46
// it under the terms of the GNU General Public License as published by
47
// the Free Software Foundation; either version 2 of the License, or
48
// (at your option) any later version.
49
//
50
// This program is distributed in the hope that it will be useful,
51
// but WITHOUT ANY WARRANTY; without even the implied warranty of
52
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
53
// GNU General Public License for more details.
54
//
55
// You should have received a copy of the GNU General Public License
56
// along with this program; if not, write to the Free Software
57
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
58
//
59
60
#ifndef LHOGHO_ATOMS_H
61
#define LHOGHO_ATOMS_H
62
63
#include "stdint.h"
64
#include "stddef.h"
65
#include "stdio.h"
66
#include "
globals.h
"
67
68
69
70
71
//===================================================
78
//===================================================
79
typedef
struct
node
{
80
union
{
81
byte_t
b
[16];
82
uint_t
u
[4];
83
int_t
n
[4];
84
ushort_t
s
[8];
85
chars_t
c
[4];
86
struct
node
*
a
[4];
87
int64_t
i
[2];
88
float64_t
f
[2];
89
void
*
v
[4];
90
}
unode
;
91
}
atomrec_t
;
92
93
typedef
atomrec_t
*
atom_t
;
94
95
typedef
struct
node_ex
{
96
union
{
97
struct
node
*
a
[5];
98
}
unode_ex
;
99
}
atomrec_ex_t
;
100
101
typedef
atomrec_ex_t
*
atom_ex_t
;
102
103
104
105
//==============================================
110
//==============================================
111
112
#define MIN_ID INTEGER_ID
113
#define INTEGER_ID 0
114
#define FLOAT_ID 1
115
#define LIST_ID 2
116
#define WORD_ID 3
117
#define SUBWORD_ID 4
118
#define ERROR_ID 5
119
#define VAR_ID 6
120
#define MEM_ID 7
121
#define MAX_ID (MEM_ID+1)
122
123
124
125
126
//==============================================
128
//==============================================
129
#define OFFSET_ID 4
130
#define OFFSET_INT 8
131
#define OFFSET_REPCOUNT 8
132
#define OFFSET_REPLIMIT 12
133
134
#define REF(x) ((x)->unode.u[0])
135
#define ID(x) ((x)->unode.b[OFFSET_ID])
136
#define FLAGS(x) ((x)->unode.s[3])
137
138
#define GET_FLAGS(a,bitmask) (FLAGS(a) & (bitmask))
139
#define SET_FLAGS(a,bitmask) FLAGS(a) |= (bitmask)
140
#define CLR_FLAGS(a,bitmask) FLAGS(a) &= ~(bitmask)
141
142
//#define DEUSE(x) {printf("deuse %x %s:%d %s()\n",(int)x,__FILE__,__LINE__,__FUNCTION__); deuse(x); }
143
144
#define DEUSE(x) deuse(x)
145
#define USE(x) use(x)
146
147
148
//==============================================
150
//==============================================
151
// @{
152
#define ATOM_SIZE sizeof(atomrec_t)
153
#define ATOM_SIZE_EX (ATOM_SIZE+1*sizeof(int_t))
154
#define CHAR_SIZE sizeof(char_t)
155
#define UNKNOWN -1
156
// @}
157
158
159
160
161
#ifdef ADVANCED
162
extern
int
stats_free
;
163
#endif //ADVANCED
164
165
166
167
168
extern
void
init_atoms
();
169
extern
void
finit_atoms
();
170
extern
atom_t
use
(
atom_t
a
);
171
extern
void
__attribute__
((used,noinline,regparm(0),stdcall))
deuse
(
atom_t
a
);
172
173
extern FILE*
input_stream
;
174
extern FILE*
output_stream
;
175
extern
int
outter_size
;
176
extern
void
outter
(
chars_t
string
,
int
len );
177
extern
char_t
inner
( );
178
extern
int
inner_eof
( );
179
extern FILE*
dribble_handle
;
180
181
extern struct lconv *
locale_info
;
182
extern
void
dump
(
atom_t
a );
183
extern
void
dumpln
(
atom_t
a );
184
extern
void
dump_atom
(
atom_t
a,
int
level );
185
extern
void
init_output
(
outter_t
new_outter );
186
extern
void
init_input
(
inner_t
new_inner,
inner_eof_t
new_inner_eof );
187
188
#endif //LHOGHO_ATOMS_H
[
HOME
|
INDEX
|
ATOMS
|
VARS
|
REFERENCE
]
Lhogho Developer's Documentation
Wed Jul 10 2013