本文整理匯總了Python中Memory.read_plain方法的典型用法代碼示例。如果您正苦於以下問題:Python Memory.read_plain方法的具體用法?Python Memory.read_plain怎麽用?Python Memory.read_plain使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Memory
的用法示例。
在下文中一共展示了Memory.read_plain方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: exec_getvar
# 需要導入模塊: import Memory [as 別名]
# 或者: from Memory import read_plain [as 別名]
def exec_getvar(inst):
func_addr = Memory.read_plain(Registers.read_fp() - 4)
rs_val = Registers.get_reg(inst['rs'])
while True:
arg_field = Memory.get_field(func_addr, Constants.get_str('arguments'))
arg_obj = Memory.get_prop(arg_field)['value']
var_field = Memory.get_field(arg_obj, rs_val)
if var_field: # The field is found in arguments.
offset_addr = Memory.get_prop(var_field)['value']
offset = Memory.get_int(offset_addr)
Registers.set_reg(inst['rd'], Memory.read_plain(Registers.read_fp() + offset))
break
scope_field = Memory.get_field(func_addr, Constants.get_str('scope'))
scope_obj = Memory.get_prop(scope_field)['value']
var_field = Memory.get_field(scope_obj, rs_val)
if var_field: # The field is found in scope.
var_obj = Memory.get_prop(var_field)['value']
Registers.set_reg(inst['rd'], var_obj)
break
outer_field = Memory.get_field(func_addr, Constants.get_str('outer'))
outer_obj = Memory.get_prop(outer_field)['value']
if not outer_obj: # The field 'outer' is empty.
func_addr = Memory.read_plain(Registers.read_fp() - 4)
scope_field = Memory.get_field(func_addr, Constants.get_str('scope'))
scope_obj = Memory.get_prop(scope_field)['value']
prop_addr = Memory.new_field(scope_obj, rs_val)
obj_addr = Memory.new_obj()
Memory.set_prop(prop_addr, value=obj_addr)
Registers.set_reg(inst['rd'], obj_addr)
break
else:
func_addr = outer_obj
inc_pc(4)
示例2: exec_jalr
# 需要導入模塊: import Memory [as 別名]
# 或者: from Memory import read_plain [as 別名]
def exec_jalr(inst):
Memory.write_plain(Registers.read_fp(), read_pc()) # set return address
func_obj = Memory.get_obj(Registers.get_reg(inst['rd']))
if func_obj['type'] == 7: # panel.readInt()
num = int(raw_input('Please enter an integer.\n'))
num_addr = Memory.new_int(num)
Memory.write_plain(Registers.read_fp() - 12, num_addr)
inc_pc(4)
elif func_obj['type'] == 8: # panel.readStr()
string = raw_input('Please enter an string.\n')
str_addr = Memory.new_str(string)
Memory.write_plain(Registers.read_fp() - 12, str_addr)
inc_pc(4)
elif func_obj['type'] == 9: # panel.show()
arg = Memory.read_plain(Registers.read_fp() - 16)
Memory.print_obj(arg)
inc_pc(4)
else:
assert func_obj['type'] == 4
func_addr = Registers.get_reg(inst['rd'])
address_field = Memory.get_field(func_addr, Constants.get_str('address'))
address_addr = Memory.get_prop(address_field)['value']
address = Memory.get_int(address_addr)
Memory.write_plain(Registers.read_fp(), read_pc() + 4)
write_pc(address)
示例3: exec_newfunc
# 需要導入模塊: import Memory [as 別名]
# 或者: from Memory import read_plain [as 別名]
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)
示例4: exec_ld
# 需要導入模塊: import Memory [as 別名]
# 或者: from Memory import read_plain [as 別名]
def exec_ld(inst):
src_addr = Memory.get_int(Registers.get_reg(inst['rs'])) + inst['offset']
Registers.set_reg(inst['rd'], Memory.read_plain(src_addr))
inc_pc(4)
示例5: exec_ret
# 需要導入模塊: import Memory [as 別名]
# 或者: from Memory import read_plain [as 別名]
def exec_ret(inst):
ret_addr = Memory.read_plain(Registers.read_fp())
write_pc(ret_addr)