File: inlinables_staticvar.d

package info (click to toggle)
ldc 1%3A1.30.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 59,248 kB
  • sloc: cpp: 61,598; ansic: 14,545; sh: 1,014; makefile: 972; asm: 510; objc: 135; exp: 48; python: 12
file content (85 lines) | stat: -rw-r--r-- 2,053 bytes parent folder | download | duplicates (4)
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
module inputs.inlinables_staticvar;

/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/

private int atModuleScope;

pragma(inline, true) void addToModuleScopeInline(int i)
{
    atModuleScope += i;
}

pragma(inline, false) void addToModuleScopeOutline(int i)
{
    atModuleScope += i;
}

pragma(inline, false) bool equalModuleScope(int i)
{
    return atModuleScope == i;
}

/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/

pragma(inline, true) bool addAndCheckInsideFunc(int checkbefore, int increment)
{
    static int insideFunc;

    if (insideFunc != checkbefore)
        return false;

    insideFunc += increment;
    return true;
}

pragma(inline, false) bool addAndCheckInsideFuncIndirect(int checkbefore, int increment)
{
    return addAndCheckInsideFunc(checkbefore, increment);
}

/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/

pragma(inline, true) bool addAndCheckInsideNestedFunc(int checkbefore, int increment)
{
    pragma(inline, true)
    bool addCheckNested(int checkbefore, int increment)
    {
        static int insideFunc;

        if (insideFunc != checkbefore)
            return false;

        insideFunc += increment;
        return true;
    }

    return addCheckNested(checkbefore, increment);
}

pragma(inline, false) bool addAndCheckInsideNestedFuncIndirect(int checkbefore, int increment)
{
    return addAndCheckInsideNestedFunc(checkbefore, increment);
}

/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/

pragma(inline, true) bool addAndCheckNestedStruct(int checkbefore, int increment)
{
    struct NestedStruct
    {
        static int structValue;
    }

    if (NestedStruct.structValue != checkbefore)
        return false;

    NestedStruct.structValue += increment;
    return true;
}

pragma(inline, false) bool addAndCheckNestedStructIndirect(int checkbefore, int increment)
{
    return addAndCheckNestedStruct(checkbefore, increment);
}

/+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++/