當前位置: 首頁>>代碼示例>>Python>>正文


Python misc.mangle方法代碼示例

本文整理匯總了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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:22,代碼來源:pycodegen.py

示例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) 
開發者ID:ofermend,項目名稱:medicare-demo,代碼行數:20,代碼來源:pycodegen.py

示例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 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:pycodegen.py

示例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 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:7,代碼來源:pycodegen.py

示例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 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:pycodegen.py

示例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)) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:10,代碼來源:pycodegen.py

示例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 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:4,代碼來源:symbols.py

示例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 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:4,代碼來源:symbols.py

示例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) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:11,代碼來源:symbols.py

示例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 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:6,代碼來源:symbols.py


注:本文中的compiler.misc.mangle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。