本文整理匯總了Python中compiler.misc.mangle方法的典型用法代碼示例。如果您正苦於以下問題:Python misc.mangle方法的具體用法?Python misc.mangle怎麽用?Python misc.mangle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類compiler.misc
的用法示例。
在下文中一共展示了misc.mangle方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _nameOp
# 需要導入模塊: from compiler import misc [as 別名]
# 或者: from compiler.misc import mangle [as 別名]
def _nameOp(self, prefix, name):
name = self.mangle(name)
scope = self.scope.check_name(name)
if scope == SC_LOCAL:
if not self.optimized:
self.emit(prefix + '_NAME', name)
else:
self.emit(prefix + '_FAST', name)
elif scope == SC_GLOBAL_EXPLICIT:
self.emit(prefix + '_GLOBAL', name)
elif scope == SC_GLOBAL_IMPLICIT:
if not self.optimized:
self.emit(prefix + '_NAME', name)
else:
self.emit(prefix + '_GLOBAL', name)
elif scope == SC_FREE or scope == SC_CELL:
self.emit(prefix + '_DEREF', name)
else:
raise RuntimeError, "unsupported scope for var %s: %d" % \
(name, scope)
示例2: _nameOp
# 需要導入模塊: from compiler import misc [as 別名]
# 或者: from compiler.misc import mangle [as 別名]
def _nameOp(self, prefix, name):
name = self.mangle(name)
scope = self.scope.check_name(name)
if scope == SC_LOCAL:
if not self.optimized:
self.emit(prefix + '_NAME', name)
else:
self.emit(prefix + '_FAST', name)
elif scope == SC_GLOBAL:
if not self.optimized:
self.emit(prefix + '_NAME', name)
else:
self.emit(prefix + '_GLOBAL', name)
elif scope == SC_FREE or scope == SC_CELL:
self.emit(prefix + '_DEREF', name)
else:
raise RuntimeError, "unsupported scope for var %s: %d" % \
(name, scope)
示例3: mangle
# 需要導入模塊: from compiler import misc [as 別名]
# 或者: from compiler.misc import mangle [as 別名]
def mangle(self, name):
if self.class_name is not None:
return misc.mangle(name, self.class_name)
else:
return name
示例4: visitGetattr
# 需要導入模塊: from compiler import misc [as 別名]
# 或者: from compiler.misc import mangle [as 別名]
def visitGetattr(self, node):
self.visit(node.expr)
self.emit('LOAD_ATTR', self.mangle(node.attrname))
# next five implement assignments
示例5: visitAssAttr
# 需要導入模塊: from compiler import misc [as 別名]
# 或者: from compiler.misc import mangle [as 別名]
def visitAssAttr(self, node):
self.visit(node.expr)
if node.flags == 'OP_ASSIGN':
self.emit('STORE_ATTR', self.mangle(node.attrname))
elif node.flags == 'OP_DELETE':
self.emit('DELETE_ATTR', self.mangle(node.attrname))
else:
print "warning: unexpected flags:", node.flags
print node
示例6: visitAugGetattr
# 需要導入模塊: from compiler import misc [as 別名]
# 或者: from compiler.misc import mangle [as 別名]
def visitAugGetattr(self, node, mode):
if mode == "load":
self.visit(node.expr)
self.emit('DUP_TOP')
self.emit('LOAD_ATTR', self.mangle(node.attrname))
elif mode == "store":
self.emit('ROT_TWO')
self.emit('STORE_ATTR', self.mangle(node.attrname))
示例7: add_def
# 需要導入模塊: from compiler import misc [as 別名]
# 或者: from compiler.misc import mangle [as 別名]
def add_def(self, name):
self.defs[self.mangle(name)] = 1
示例8: add_use
# 需要導入模塊: from compiler import misc [as 別名]
# 或者: from compiler.misc import mangle [as 別名]
def add_use(self, name):
self.uses[self.mangle(name)] = 1
示例9: add_global
# 需要導入模塊: from compiler import misc [as 別名]
# 或者: from compiler.misc import mangle [as 別名]
def add_global(self, name):
name = self.mangle(name)
if name in self.uses or name in self.defs:
pass # XXX warn about global following def/use
if name in self.params:
raise SyntaxError, "%s in %s is global and parameter" % \
(name, self.name)
self.globals[name] = 1
self.module.add_def(name)
示例10: add_param
# 需要導入模塊: from compiler import misc [as 別名]
# 或者: from compiler.misc import mangle [as 別名]
def add_param(self, name):
name = self.mangle(name)
self.defs[name] = 1
self.params[name] = 1