MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ast

Method ast

tensorflow/python/autograph/pyct/qual_names.py:194–216  ·  view source on GitHub ↗

AST representation.

(self)

Source from the content-addressed store, hash-verified

192 return ssf_string + ssfs[-1]
193
194 def ast(self):
195 """AST representation."""
196 # The caller must adjust the context appropriately.
197 if self.has_subscript():
198 return gast.Subscript(
199 value=self.parent.ast(),
200 slice=gast.Index(self.qn[-1].ast()),
201 ctx=CallerMustSetThis)
202 if self.has_attr():
203 return gast.Attribute(
204 value=self.parent.ast(), attr=self.qn[-1], ctx=CallerMustSetThis)
205
206 base = self.qn[0]
207 if isinstance(base, str):
208 return gast.Name(
209 base, ctx=CallerMustSetThis, annotation=None, type_comment=None)
210 elif isinstance(base, StringLiteral):
211 return gast.Constant(base.value, kind=None)
212 elif isinstance(base, NumberLiteral):
213 return gast.Constant(base.value, kind=None)
214 else:
215 assert False, ('the constructor should prevent types other than '
216 'str, StringLiteral and NumberLiteral')
217
218
219class QnResolver(gast.NodeTransformer):

Callers 6

test_basicMethod · 0.95
test_subscriptsMethod · 0.95
test_literalsMethod · 0.95
_convert_to_astFunction · 0.80
visit_IfMethod · 0.80
_loop_var_constructsMethod · 0.80

Calls 5

has_subscriptMethod · 0.95
has_attrMethod · 0.95
IndexMethod · 0.45
NameMethod · 0.45
ConstantMethod · 0.45

Tested by 3

test_basicMethod · 0.76
test_subscriptsMethod · 0.76
test_literalsMethod · 0.76