summaryrefslogtreecommitdiff
path: root/src/cmd/godefs/a.h
blob: 9b495746719aedcad2db577fffd00a164ff6bbb7 (plain)
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
97
98
99
100
101
102
103
104
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

#include <u.h>
#include <libc.h>
#include <bio.h>

enum
{
	Void = 1,
	Int8,
	Uint8,
	Int16,
	Uint16,
	Int32,
	Uint32,
	Int64,
	Uint64,
	Float32,
	Float64,
	Ptr,
	Struct,
	Array,
	Union,
	Typedef,
};

typedef struct Field Field;
typedef struct Type Type;

struct Type
{
	Type *next;	// next in hash table

	// stabs name and two-integer id
	char *name;
	int n1;
	int n2;

	// int kind
	int kind;

	// sub-type for ptr, array
	Type *type;

	// struct fields
	Field *f;
	int nf;
	int size;

	int saved;	// recorded in typ array
	int warned;	// warned about needing type
	int printed;	// has the definition been printed yet?
};

struct Field
{
	char *name;
	Type *type;
	int offset;
	int size;
};

// Constants
typedef struct Const Const;
struct Const
{
	char *name;
	vlong value;
};

// Recorded constants and types, to be printed.
extern Const *con;
extern int ncon;
extern Type **typ;
extern int ntyp;
extern int kindsize[];

// Language output
typedef struct Lang Lang;
struct Lang
{
	char *constbegin;
	char *constfmt;
	char *constend;

	char *typdef;
	char *typdefend;

	char *structbegin;
	char *unionbegin;
	char *structpadfmt;
	char *structend;

	int (*typefmt)(Fmt*);
};

extern Lang go, c;

void*	emalloc(int);
char*	estrdup(char*);
void*	erealloc(void*, int);
void		parsestabtype(char*);