This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
loc.d
83 lines (71 loc) · 1.79 KB
/
loc.d
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
/**
* C preprocessor
* Copyright: 2013 by Digital Mars
* License: $(LINK2 http://boost.org/LICENSE_1_0.txt, Boost License 1.0).
* Authors: Walter Bright
*/
module loc;
import std.format;
import std.stdio;
import sources;
/*************************************
* Flags that indicate system file status.
*/
enum Sys : ubyte
{
none = 0, // not a system file
angle = 1, // #include'd with < >
syspath = 2, // appears in --isystem path, or was #include'd from a Sys.syspath file
}
/*************************************
* Current location.
*/
struct Loc
{
SrcFile* srcFile;
string fileName; // because #line may change the filename
uint lineNumber; // line number of current position
Sys system; // system file status
/********************************************
* Write out linemarker for current location to range r.
*/
void linemarker(R)(R r)
{
r.formattedWrite("# %d \"%s\"", lineNumber - 1, fileName);
if (system)
{
r.put(' ');
/* Values are:
* 1 start of file
* 2 return to this file
* 3 system file
* 4 file should be wrapped in implicit extern "C"
*/
r.put('3');
}
r.put('\n');
}
/**********************************************
* Write out current location to File*
*/
void write(File* f)
{
//writefln("%s(%s) %s", fileName, lineNumber, system);
if (srcFile)
f.writef("%s:%d: ", fileName, lineNumber);
}
}
/*************************************************
* Element of a linked list of locations.
*/
struct LocList
{
Loc first;
LocList* rest;
}
/*
* Local Variables:
* mode: d
* c-basic-offset: 4
* End:
*/