本文整理汇总了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))
示例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)
示例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
示例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()
示例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
示例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
示例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)
示例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
示例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()
示例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()
示例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)
示例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)
示例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()
示例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()
示例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()