• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rjfarmer / gfModParser / 13873397857

15 Mar 2025 01:37PM UTC coverage: 81.897% (-3.5%) from 85.347%
13873397857

push

github

rjfarmer
Keyword only version

14 of 14 new or added lines in 9 files covered. (100.0%)

43 existing lines in 1 file now uncovered.

475 of 580 relevant lines covered (81.9%)

0.82 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

63.49
/gfModParser/modules/expressions.py
1
# SPDX-License-Identifier: GPL-2.0+
2

3
from .. import utils
1✔
4

5

6
class expression:
1✔
7
    def __init__(self, expression, *, version):
1✔
8
        self._expression = expression
×
9
        self.version = version
×
10

11
    @property
1✔
12
    def type(self):
1✔
13
        t = self._expression[0]
×
UNCOV
14
        return _map[t](t, self.typespec.kind, self._expression, version=self.version)
×
15

16
    @property
1✔
17
    def typespec(self):
1✔
UNCOV
18
        return typespec(self._expression[1], version=self.version)
×
19

20
    @property
1✔
21
    def rank(self):
1✔
UNCOV
22
        return int(self._expression[2])
×
23

24
    @property
1✔
25
    def arglist(self):
1✔
UNCOV
26
        if len(self._args) == 7:
×
UNCOV
27
            return self._args[6]  # actual_arglist
×
28

29

30
class ExpGeneric:
1✔
31
    def __init__(self, type, kind, args, *, version):
1✔
UNCOV
32
        self._args = args
×
UNCOV
33
        self.version = version
×
UNCOV
34
        self._type = type
×
UNCOV
35
        self._kind = kind
×
36

37
    def __str__(self):
1✔
UNCOV
38
        return self._type
×
39

40
    def __repr__(self):
1✔
UNCOV
41
        return self._type
×
42

43
    @property
1✔
44
    def value(self):
1✔
UNCOV
45
        return None
×
46

47

48
class ExpOp(ExpGeneric):
1✔
49

50
    @property
1✔
51
    def unary_op(self):
1✔
UNCOV
52
        return self._args[3]
×
53

54
    @property
1✔
55
    def unary_args(self):
1✔
UNCOV
56
        return expression(self._args[4], version=self.version), expression(
×
57
            self._args[5], version=self.version
58
        )
59

60

61
class ExpNotImplemented(ExpGeneric):
1✔
62
    @property
1✔
63
    def value(self):
1✔
UNCOV
64
        raise NotImplementedError
×
65

66

67
class ExpFunction(ExpGeneric):
1✔
68
    @property
1✔
69
    def value(self):
1✔
UNCOV
70
        return self._args[3]
×
71

72
    @property
1✔
73
    def args(self):
1✔
UNCOV
74
        return expression(self._args[4], version=self.version)
×
75

76

77
class ExpConstant(ExpGeneric):
1✔
78
    @property
1✔
79
    def value(self):
1✔
UNCOV
80
        if self._type == "REAL":
×
UNCOV
81
            return utils.hextofloat(utils.string_clean(self._args[3]), self._kind)
×
UNCOV
82
        elif self._type == "INTEGER":
×
UNCOV
83
            return int(utils.string_clean(self._args[3]))
×
UNCOV
84
        elif self._type == "CHARACTER":
×
UNCOV
85
            return utils.string_clean(self._args[4])
×
UNCOV
86
        elif self._type == "COMPLEX":
×
UNCOV
87
            return complex(
×
88
                utils.hextofloat(utils.string_clean(self._args[3]), self._kind),
89
                utils.hextofloat(utils.string_clean(self._args[4]), self._kind),
90
            )
UNCOV
91
        elif self._type == "LOGICAL":
×
UNCOV
92
            return int(self._args[3]) == 1
×
93
        else:
UNCOV
94
            raise NotImplementedError(self._args)
×
95

96
    def len(self):
1✔
UNCOV
97
        if self._type == "CHARACTER":
×
UNCOV
98
            return int(self._args[3])
×
99

100

101
class ExpVariable(ExpGeneric):
1✔
102
    @property
1✔
103
    def value(self):
1✔
UNCOV
104
        return self._args[3]
×
105

106

107
class ExpArray(ExpGeneric):
1✔
108
    @property
1✔
109
    def value(self):
1✔
UNCOV
110
        value = []
×
UNCOV
111
        for i in self._args[3]:
×
UNCOV
112
            value.append(expression(i, version=self.version))
×
113

UNCOV
114
        return value
×
115

116

117
class ExpSubString(ExpNotImplemented):
1✔
118
    pass
1✔
119

120

121
class ExpNull(ExpNotImplemented):
1✔
122
    pass
1✔
123

124

125
class ExpCompCall(ExpNotImplemented):
1✔
126
    pass
1✔
127

128

129
class ExpPPC(ExpNotImplemented):
1✔
130
    pass
1✔
131

132

133
class ExpUnknown(ExpNotImplemented):
1✔
134
    pass
1✔
135

136

137
# Need to store this here as we get a cyclic dependency
138
# between expressions and typespec
139
class typespec:
1✔
140
    def __init__(self, typespec, *, version):
1✔
141
        self._typespec = typespec
1✔
142
        self.version = version
1✔
143

144
    @property
1✔
145
    def type(self):
1✔
146
        return self._typespec[0]
1✔
147

148
    def _isclass(self):
1✔
149
        return self.type == "CLASS" or self.type == "DERIVED"
1✔
150

151
    @property
1✔
152
    def kind(self):
1✔
153
        if not self._isclass():
1✔
154
            return int(self._typespec[1])
1✔
155

156
    @property
1✔
157
    def class_ref(self):
1✔
UNCOV
158
        if self._isclass():
×
UNCOV
159
            return int(self._typespec[1])
×
160

161
    @property
1✔
162
    def interface(self):
1✔
UNCOV
163
        return self._typespec[2]
×
164

165
    @property
1✔
166
    def is_c_interop(self):
1✔
167
        return int(self._typespec[3]) == 1
1✔
168

169
    @property
1✔
170
    def is_iso_c(self):
1✔
171
        return int(self._typespec[4]) == 1
1✔
172

173
    @property
1✔
174
    def type2(self):
1✔
175
        # Whats this?
UNCOV
176
        return self._typespec[5]
×
177

178
    @property
1✔
179
    def charlen(self):
1✔
UNCOV
180
        return self._typespec[6]
×
181

182
    #     try:
183
    #         if not args[6][0]:
184
    #             self.charlen = -1
185
    #         else:
186
    #             self.charlen = expression(
187
    #                 *args[6][0]
188
    #             )  # TODO: might this need to be iterated for mulit-d strings?
189
    #     except IndexError:
190
    #         self.charlen = -1
191

192
    @property
1✔
193
    def deferred_cl(self):
1✔
UNCOV
194
        if len(self._typespec) == 8:
×
UNCOV
195
            return self._typespec[7] == "DEFERRED_CL"
×
196

UNCOV
197
        return False
×
198

199

200
_map = {
1✔
201
    "OP": ExpOp,
202
    "FUNCTION": ExpFunction,
203
    "CONSTANT": ExpConstant,
204
    "VARIABLE": ExpVariable,
205
    "SUBSTRING": ExpSubString,
206
    "NULL": ExpNull,
207
    "COMPCALL": ExpCompCall,
208
    "PPC": ExpPPC,
209
    "UNKNOWN": ExpUnknown,
210
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc