• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(139)  |  Call(81)  |  Derive(0)  |  Import(58)
code(argcount, nlocals, stacksize, flags, codestring, constants, names,
      varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])

Create a code object.  Not for the faint of heart.

src/p/y/pylibs-HEAD/optimise.py   pylibs(Download)
import sys
 
from opcode import opmap, HAVE_ARGUMENT, EXTENDED_ARG
from types import FunctionType, ClassType, CodeType
 
# ------------------------------------------------------------------------------
# some konstants
 
    codestr = ''.join(map(chr, newcode))
    codeobj = CodeType(
        co.co_argcount, co.co_nlocals, co.co_stacksize,
        co.co_flags, codestr, tuple(newconsts), co.co_names,
        co.co_varnames, co.co_filename, co.co_name,
        co.co_firstlineno, co.co_lnotab, co.co_freevars,

src/d/e/Dejavu-1.5.0/dejavu/codewalk.py   Dejavu(Download)
 
import operator
import sets
from types import CodeType, FunctionType, MethodType
 
from compiler.consts import *
CO_NOFREE = 0x0040
# CodeType(argcount, nlocals, stacksize, flags, codestring, constants,
#          names, varnames, filename, name, firstlineno,
#          lnotab[, freevars[, cellvars]])
_derefblock = CodeType(0, 0, 1, 3, ''.join(map(chr, _deref_bytecode)),
                       (None,), ('cell',), (), '', '', 2, '', ('cell',))
def deref_cell(cell):
    """Return the value of 'cell' (an object from a func_closure)."""
    def code_object(self):
        """Walk self and produce a new code object."""
        self.walk()
        codestr = ''.join(map(chr, self.newcode))
        return CodeType(self.co_argcount, self.co_nlocals, self.co_stacksize,
                        # Notice co_consts should *not* be safe_tupled.
                        self.co_flags, codestr, tuple(self.co_consts),
    def code_object(self):
        """Walk self and produce a new code object."""
        self.walk()
        codestr = ''.join(map(chr, self.newcode))
        # Assert CO_NOFREE, since all free vars should have been made constant.
        self.co_flags |= CO_NOFREE
        co = CodeType(self.co_argcount, self.co_nlocals, self.stack.maxsize,

src/i/r/ironruby-HEAD/External.LCA_RESTRICTED/Languages/IronPython/27/Lib/compiler/pyassem.py   ironruby(Download)
        argcount = self.argcount
        if self.flags & CO_VARKEYWORDS:
            argcount = argcount - 1
        return types.CodeType(argcount, nlocals, self.stacksize, self.flags,
                        self.lnotab.getCode(), self.getConsts(),
                        tuple(self.names), tuple(self.varnames),
                        self.filename, self.name, self.lnotab.firstline,

src/i/r/ironruby-HEAD/External.LCA_RESTRICTED/Languages/CPython/27/Lib/compiler/pyassem.py   ironruby(Download)
        argcount = self.argcount
        if self.flags & CO_VARKEYWORDS:
            argcount = argcount - 1
        return types.CodeType(argcount, nlocals, self.stacksize, self.flags,
                        self.lnotab.getCode(), self.getConsts(),
                        tuple(self.names), tuple(self.varnames),
                        self.filename, self.name, self.lnotab.firstline,

src/f/l/flioops-HEAD/py/trunk/utils/func.py   flioops(Download)
		try:
			codeNote= ''
			if len(co.co_consts)== 0:
				co= types.CodeType(co.co_argcount, co.co_nlocals, co.co_stacksize, \
						co.co_flags, co.co_code, (None, ), co.co_names, co.co_varnames, \
						co.co_filename, co.co_name, co.co_firstlineno, co.co_lnotab, \
						co.co_freevars, co.co_cellvars)
def bld_getCellValues():
	GETCELL_CODESTR= ''.join([chr(x) for x in [dis.opmap['LOAD_GLOBAL'], 0, 0, dis.opmap['STORE_FAST'], 0, 0, \
			dis.opmap['LOAD_DEREF'], 0, 0, dis.opmap['RETURN_VALUE']]])
	co= types.CodeType(0, 0, 1, 19, GETCELL_CODESTR, 
			(), ('cell',), ('_cell',), '<string>', 'co', 1, '\x00\x01', (), ('_cell',))
 
	def getCellValues(cells):
			operand%= 65536L
		code+= (chr(op) + chr(operand % 256) + chr(operand / 256))
	if out_co:
		code = types.CodeType(arg_cnt, len(varnames), stksz, 67, code, consts, names,
				varnames, '<string>', '<lambda>', 1, '', freevars, cellvars)
	return code
 

src/i/r/ironruby-HEAD/External.LCA_RESTRICTED/Languages/IronPython/27/Lib/modulefinder.py   ironruby(Download)
            if isinstance(consts[i], type(co)):
                consts[i] = self.replace_paths_in_code(consts[i])
 
        return types.CodeType(co.co_argcount, co.co_nlocals, co.co_stacksize,
                         co.co_flags, co.co_code, tuple(consts), co.co_names,
                         co.co_varnames, new_filename, co.co_name,
                         co.co_firstlineno, co.co_lnotab,

src/i/r/ironruby-HEAD/External.LCA_RESTRICTED/Languages/CPython/27/Lib/modulefinder.py   ironruby(Download)
            if isinstance(consts[i], type(co)):
                consts[i] = self.replace_paths_in_code(consts[i])
 
        return types.CodeType(co.co_argcount, co.co_nlocals, co.co_stacksize,
                         co.co_flags, co.co_code, tuple(consts), co.co_names,
                         co.co_varnames, new_filename, co.co_name,
                         co.co_firstlineno, co.co_lnotab,

src/p/y/pypy3-HEAD/pypy/lib/_marshal.py   pypy3(Download)
        name = self.load()
        firstlineno = self.r_long()
        lnotab = self.load()
        return types.CodeType(argcount, nlocals, stacksize, flags, code, consts,
                              names, varnames, filename, name, firstlineno,
                              lnotab, freevars, cellvars)
    dispatch[TYPE_CODE] = load_code
        name = self.load()
        firstlineno = _r_long(self)
        lnotab = self.load()
        return types.CodeType(argcount, nlocals, stacksize, flags, code, consts,
                              names, varnames, filename, name, firstlineno,
                              lnotab, freevars, cellvars)
    dispatch[TYPE_CODE] = load_code

src/p/y/pypy-HEAD/lib_pypy/_marshal.py   pypy(Download)
        name = self.load()
        firstlineno = self.r_long()
        lnotab = self.load()
        return types.CodeType(argcount, nlocals, stacksize, flags, code, consts,
                              names, varnames, filename, name, firstlineno,
                              lnotab, freevars, cellvars)
    dispatch[TYPE_CODE] = load_code
        name = self.load()
        firstlineno = _r_long(self)
        lnotab = self.load()
        return types.CodeType(argcount, nlocals, stacksize, flags, code, consts,
                              names, varnames, filename, name, firstlineno,
                              lnotab, freevars, cellvars)
    dispatch[TYPE_CODE] = load_code

src/p/y/pynomic-HEAD/jinja2/debug.py   pynomic(Download)
    :license: BSD.
"""
import sys
from types import CodeType
 
 
def translate_exception(exc_info):
            location = 'block "%s"' % function[6:]
        else:
            location = 'template'
        code = CodeType(0, code.co_nlocals, code.co_stacksize,
                        code.co_flags, code.co_code, code.co_consts,
                        code.co_names, code.co_varnames, filename,
                        location, code.co_firstlineno,

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next