• Home
  • Raw
  • Download

Lines Matching full:scope

14 class Scope:  class
88 """Return scope of name.
90 The scope of a name could be LOCAL, GLOBAL, FREE, or CELL.
123 """Force name to be global in scope.
127 variable. Now that all its enclosing scope have been
143 """Process list of free vars from nested scope.
147 the nested scope should treat them as globals.
172 class ModuleScope(Scope):
173 __super_init = Scope.__init__
178 class FunctionScope(Scope):
181 class GenExprScope(Scope):
182 __super_init = Scope.__init__
193 keys = Scope.get_names(self)
197 __super_init = Scope.__init__
206 class ClassScope(Scope):
207 __super_init = Scope.__init__
220 scope = self.module = self.scopes[node] = ModuleScope()
221 self.visit(node.node, scope)
231 scope = FunctionScope(node.name, self.module, self.klass)
233 scope.nested = 1
234 self.scopes[node] = scope
235 self._do_args(scope, node.argnames)
236 self.visit(node.code, scope)
237 self.handle_free_vars(scope, parent)
240 scope = GenExprScope(self.module, self.klass);
243 scope.nested = 1
245 self.scopes[node] = scope
246 self.visit(node.code, scope)
248 self.handle_free_vars(scope, parent)
250 def visitGenExprInner(self, node, scope): argument
252 self.visit(genfor, scope)
254 self.visit(node.expr, scope)
256 def visitGenExprFor(self, node, scope): argument
257 self.visit(node.assign, scope, 1)
258 self.visit(node.iter, scope)
260 self.visit(if_, scope)
262 def visitGenExprIf(self, node, scope): argument
263 self.visit(node.test, scope)
273 scope = LambdaScope(self.module, self.klass)
275 scope.nested = 1
276 self.scopes[node] = scope
277 self._do_args(scope, node.argnames)
278 self.visit(node.code, scope)
279 self.handle_free_vars(scope, parent)
281 def _do_args(self, scope, args): argument
284 self._do_args(scope, name)
286 scope.add_param(name)
288 def handle_free_vars(self, scope, parent): argument
289 parent.add_child(scope)
290 scope.handle_children()
296 scope = ClassScope(node.name, self.module)
298 scope.nested = 1
300 scope.add_def('__doc__')
301 scope.add_def('__module__')
302 self.scopes[node] = scope
305 self.visit(node.code, scope)
307 self.handle_free_vars(scope, parent)
315 def visitName(self, node, scope, assign=0): argument
317 scope.add_def(node.name)
319 scope.add_use(node.name)
323 def visitFor(self, node, scope): argument
324 self.visit(node.assign, scope, 1)
325 self.visit(node.list, scope)
326 self.visit(node.body, scope)
328 self.visit(node.else_, scope)
330 def visitFrom(self, node, scope): argument
334 scope.add_def(asname or name)
336 def visitImport(self, node, scope): argument
341 scope.add_def(asname or name)
343 def visitGlobal(self, node, scope): argument
345 scope.add_global(name)
347 def visitAssign(self, node, scope): argument
361 self.visit(n, scope, 1)
362 self.visit(node.expr, scope)
364 def visitAssName(self, node, scope, assign=1): argument
365 scope.add_def(node.name)
367 def visitAssAttr(self, node, scope, assign=0): argument
368 self.visit(node.expr, scope, 0)
370 def visitSubscript(self, node, scope, assign=0): argument
371 self.visit(node.expr, scope, 0)
373 self.visit(n, scope, 0)
375 def visitSlice(self, node, scope, assign=0): argument
376 self.visit(node.expr, scope, 0)
378 self.visit(node.lower, scope, 0)
380 self.visit(node.upper, scope, 0)
382 def visitAugAssign(self, node, scope): argument
385 self.visit(node.node, scope)
387 self.visit(node.node, scope, 1) # XXX worry about this
388 self.visit(node.expr, scope)
394 def visitIf(self, node, scope): argument
400 self.visit(test, scope)
401 self.visit(body, scope)
403 self.visit(node.else_, scope)
407 def visitYield(self, node, scope): argument
408 scope.generator = 1
409 self.visit(node.value, scope)