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


Python Memory類代碼示例

本文整理匯總了Python中Memory的典型用法代碼示例。如果您正苦於以下問題:Python Memory類的具體用法?Python Memory怎麽用?Python Memory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Memory類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: callbefore

    def callbefore(self, pid, call, args):
	state = ()
	handle2 = handle = -1
	if call == 'socketcall':
	    if args[0] > sockettable_num:
		raise 'Trying to do invalid socketcall?'
	    subcall, pattern = sockettable[args[0]]
	    nargs = len(pattern)
	    if debug: print 'Doing ', subcall, ' with ', nargs, ' parameters', 
	    params = Memory.getMemory(pid).peek(args[1], nargs*4)
	    params = list(params)

	    curfd = -1
	    addrlen = -1

	    for i in range(len(pattern)):
		if pattern[i] == 'l':
		    if debug: print 'Getint returned ', getint(params, i*4)
		    addrlen = getint(params, i*4)
# Note: this is not true for unix domain sockets
#		    assert getint(params, i*4) == 16, '== %s' % getint(params, i*4)

	    for i in range(len(pattern)):
		if pattern[i] == 'f':
		    curfd = getint(params, i*4)
		    if debug: print '(fd = ', curfd, ')',

		if pattern[i] == 'A':
		    paddr = getint(params, i*4)
#		    print 'Call = ', subcall
		    address = Memory.getMemory(pid).peek(paddr, addrlen)
		    #address = list(address) # WHY?
		    if not self.checkaddress(self.fdmap[pid][curfd], address, addrlen, call):
			return (None, -errno.EPERM, None, None)
		    if debug: print 'Address is ', address
		    handle2, addr2 = scratch.alloc_bytes(address, addrlen)
		    if debug: print 'Addr = %x' % addr2
		    setint(params, i*4, addr2)
		    if addr2 != getint(params, i*4):
			raise 'addr2 not equal to getint'

	    handle, addr = scratch.alloc_bytes(params, nargs*4)
	    if subcall == 'socket':
		state = ( getint(params, 0), getint(params, 4), getint(params, 8) )

	    if subcall == 'connect':
#	        assert 0
		pass

	    if subcall == 'bind':
		print 'Trying to bind'
		return (None, -errno.EPERM, None, None)

	    if subcall == 'invalid_call':
		raise 'Invalid socket call'

	    if debug: print state, '... copied them to ',
	    if debug: print '%x' % addr
	return ((subcall, handle, handle2, state), None, None, (args[0], addr))
開發者ID:pombredanne,項目名稱:subterfugue,代碼行數:59,代碼來源:NetTrick.py

示例2: exec_cmp

def exec_cmp(inst):
    rs_obj = Memory.get_obj(Registers.get_reg(inst['rs']))
    rt_obj = Memory.get_obj(Registers.get_reg(inst['rt']))
    if rs_obj['type'] == rt_obj['type'] and rs_obj['data'] == rt_obj['data']:
        Registers.set_reg(inst['rd'], Constants.get_int(1))
    else:
        Registers.set_reg(inst['rd'], Constants.get_int(0))
    inc_pc(4)
開發者ID:SundongCandy,項目名稱:lift-js,代碼行數:8,代碼來源:Processor.py

示例3: i_ISZ

def i_ISZ(indirect, address, instruction):
    global PC

    value = (Memory.get(address, indirect) + 1) & WORDMASK
    Memory.put(value, address, indirect)
    if value == 0:
        PC = (PC + 1) & WORDMASK
    Trace.itrace('ISZ', indirect, address)
    return 3 if indirect else 2
開發者ID:Goku0858756,項目名稱:rzzzwilson,代碼行數:9,代碼來源:MainCPU.py

示例4: init

def init(run_address, tracefile, tstart, tend, boot_rom=None, corefile=None):
    global tracestart, traceend

    Memory.init(boot_rom, corefile)
    Trace.init(tracefile)
    tracestart = tstart
    traceend = tend
    DisplayCPU.init()
    MainCPU.init()
開發者ID:Goku0858756,項目名稱:rzzzwilson,代碼行數:9,代碼來源:Imlac.py

示例5: i_XAM

def i_XAM(indirect, address, instruction):
    global AC

    if indirect:
        address = Memory.get(address, False)
    tmp = Memory.get(address, False)
    Memory.put(AC, address, False)
    AC = tmp
    Trace.itrace('XAM', indirect, address)
    return 3 if indirect else 2
開發者ID:Goku0858756,項目名稱:rzzzwilson,代碼行數:10,代碼來源:MainCPU.py

示例6: i_SAM

def i_SAM(indirect, address, instruction):
    global PC

    samaddr = EFFADDR(address)
    if indirect:
        samaddr = Memory.get(samaddr, False)
    if AC == Memory.get(samaddr, False):
        PC = (PC + 1) & PCMASK
    Trace.itrace('SAM', indirect, address)
    return 3 if indirect else 2
開發者ID:Goku0858756,項目名稱:rzzzwilson,代碼行數:10,代碼來源:MainCPU.py

示例7: load_text

def load_text(text):
    addr = 0
    for line in text:
        if line.startswith(';'):
            continue
        if line.find(':') == -1:
            Memory.write(addr, {'type': 2, 'inst': Parser.inst(line)})
            addr += 4
        else:
            Labels.add(line.strip().split(':')[0], addr)
開發者ID:SundongCandy,項目名稱:lift-js,代碼行數:10,代碼來源:Machine.py

示例8: i_JMS

def i_JMS(indirect, address, instruction):
    global PC

    jmsaddr = EFFADDR(address)
    if indirect:
        jmsaddr = Memory.get(jmsaddr, False)
    Memory.put(PC, jmsaddr, False)
    PC = (jmsaddr + 1) & PCMASK
    Trace.itrace('JMS', indirect, address)
    return 3 if indirect else 2
開發者ID:Goku0858756,項目名稱:rzzzwilson,代碼行數:10,代碼來源:MainCPU.py

示例9: visit

 def visit(self, node):
     fun = self.functionStack.get(node.id)
     function_memory = Memory(node.id)
     for actualArg, argExpr in zip(fun.args.accept(self), node.arglist.accept(self)):
         function_memory.put(actualArg, argExpr)
     self.variableStack.push(function_memory)
     try:
         fun.body.accept(self)
     except ReturnValueException as e:
         return e.value
     finally:
         self.variableStack.pop()
開發者ID:Kurtzz,項目名稱:CompilationTheory,代碼行數:12,代碼來源:Interpreter.py

示例10: visit

 def visit(self, node):
     fun = self.memoryStack.get(node.name)#EXCEPTION
     funMemory = Memory(node.name)
     for argExpr, actualArg in zip(node.args.children, fun.args.children):
         funMemory.put(actualArg.accept(self), argExpr.accept(self))
     self.memoryStack.push(funMemory)
     try:
         fun.body.accept(self)
     except ReturnValueException as e:
         return e.value
     finally:
         self.memoryStack.pop()
開發者ID:atryda12,項目名稱:Compilation-Theory,代碼行數:12,代碼來源:Interpreter.py

示例11: exec_newfunc

def exec_newfunc(inst):
    func_addr = Memory.new_func()
    address_prop = Memory.get_field(func_addr, Constants.get_str('address'))
    Memory.set_prop(address_prop, value=Memory.new_int(Labels.query(inst['label'])))
    outer_func = Memory.read_plain(Registers.read_fp() - 4)
    outer_prop = Memory.get_field(func_addr, Constants.get_str('outer'))
    Memory.set_prop(outer_prop, value=outer_func)
    Registers.set_reg(inst['rd'], func_addr)
    inc_pc(4)
開發者ID:SundongCandy,項目名稱:lift-js,代碼行數:9,代碼來源:Processor.py

示例12: exec_slt

def exec_slt(inst):
    rs_obj = Memory.get_obj(Registers.get_reg(inst['rs']))
    rt_obj = Memory.get_obj(Registers.get_reg(inst['rt']))
    if (rs_obj['type'] == 0 and rt_obj['type'] == 0) or \
       (rs_obj['type'] == 2 and rt_obj['type'] == 2):
        if rs_obj['data'] < rt_obj['data']:
           Registers.set_reg(inst['rd'], Constants.get_int(1))
        else:
            Registers.set_reg(inst['rd'], Constants.get_int(0))
    else:
        raise Exception('The following object are not comparable yet.\n' +
                        '%s\n%s' % (str(rs_obj), str(rt_obj)))
    inc_pc(4)
開發者ID:SundongCandy,項目名稱:lift-js,代碼行數:13,代碼來源:Processor.py

示例13: visit

 def visit(self, node):
     function = self.memoryStack.get(node.id)
     functionMemory = Memory(node.id)
     for argId, argExpr in zip(function.arglist.arg_list, node.expression_list.expressions):
         functionMemory.put(argId.accept(self), argExpr.accept(self))
     self.memoryStack.push(functionMemory)
     self.isFunctionScope = True
     try:
         function.compound_instr.accept(self)
     except ReturnValueException as e:
         return e.value
     finally:
         self.isFunctionScope = False
         self.memoryStack.pop()
開發者ID:tmachows,項目名稱:kompilatory,代碼行數:14,代碼來源:Interpreter.py

示例14: visit

 def visit(self, node):
     fun = self.globalMemory.get(node.name)
     funFrame = Memory(node.name)
     if (fun.arg_list != None):
         for arg, val in list(zip(fun.arg_list.children, node.expr.children)):
             funFrame.put(arg.accept(self), val.accept(self))
     self.functionMemory.push(funFrame)
     self.isFunctionCompound = True
     try:
         fun.compound_instr.accept(self)
     except ReturnValueException as e:
         return e.value
     finally:
         self.functionMemory.pop()
開發者ID:WiktorJ,項目名稱:Compilation-Theory,代碼行數:14,代碼來源:Interpreter.py

示例15: visit

 def visit(self, node, create_memory=True):
     fun = self.memory_stack.get(node.id)
     fun_memory = Memory(node.id)
     if node.expr_list is not None:
         for arg_expression, actual_arg in zip(node.expr_list.expr_list, fun.args_list.arg_list):
             arg = actual_arg.accept(self)
             expr = arg_expression.accept(self)
             fun_memory.put(arg, expr)
     self.memory_stack.push(fun_memory)
     try:
         fun.comp_instr.accept(self, False)
     except ReturnValueException as e:
         return e.value
     finally:
         self.memory_stack.pop()
開發者ID:salceson,項目名稱:kompilatory,代碼行數:15,代碼來源:Interpreter.py


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