Support recursive types (through pointers).
Increment version.
This commit is contained in:
parent
5381c0037f
commit
dda7b25c15
|
@ -211,19 +211,26 @@ def step(insns, terminator, blocks, stack_frames, ssa_env, global_env, heap,
|
||||||
if not isinstance(actual_oper_ty, ll.PointerType):
|
if not isinstance(actual_oper_ty, ll.PointerType):
|
||||||
err('Type of main operand to getelementptr must be a pointer type. It was {}'
|
err('Type of main operand to getelementptr must be a pointer type. It was {}'
|
||||||
.format(ll.ty2s(actual_oper_ty)))
|
.format(ll.ty2s(actual_oper_ty)))
|
||||||
elif actual_base_ty != actual_oper_ty.inner_ty:
|
|
||||||
err(('Type of the main operand does not match the type getelementptr'
|
|
||||||
' navigates through.\n'
|
|
||||||
' Getelementptr type: {}\n'
|
|
||||||
' Operand type: {}')
|
|
||||||
.format(ll.ty2s(actual_base_ty), ll.ty2s(actual_oper_ty.inner_ty)))
|
|
||||||
else:
|
else:
|
||||||
|
oper_inner_ty = ty2base_ty(actual_oper_ty.inner_ty, tdecs)
|
||||||
|
if actual_base_ty != oper_inner_ty:
|
||||||
|
warn(('Type of the main operand might not match the type getelementptr'
|
||||||
|
' navigates through.\n'
|
||||||
|
' Getelementptr type: {}\n'
|
||||||
|
' Operand type: {}')
|
||||||
|
.format(ll.ty2s(actual_base_ty), ll.ty2s(oper_inner_ty)))
|
||||||
|
|
||||||
oper_v = eval_oper(oper, ssa_env, global_env)
|
oper_v = eval_oper(oper, ssa_env, global_env)
|
||||||
gep_res, formula = handle_gep(oper_v, actual_base_ty, steps, ssa_env,
|
gep_res, formula = handle_gep(oper_v, actual_base_ty, steps, ssa_env,
|
||||||
global_env)
|
global_env)
|
||||||
res = gep_res
|
res = gep_res
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
print('Getting adress of {}{}'.
|
||||||
|
format(ll.ty2s(actual_base_ty),
|
||||||
|
''.join('[{}]'
|
||||||
|
.format(eval_oper(step_oper, ssa_env, global_env))
|
||||||
|
for _, step_oper in steps)))
|
||||||
print('Gep formula: {}'
|
print('Gep formula: {}'
|
||||||
.format(formula))
|
.format(formula))
|
||||||
elif isinstance(next_insn, ll.Zext):
|
elif isinstance(next_insn, ll.Zext):
|
||||||
|
@ -357,6 +364,9 @@ def eval_oper(operand, ssa_env, global_env):
|
||||||
err('Unable to find %{} in environment:\n{}'
|
err('Unable to find %{} in environment:\n{}'
|
||||||
.format(id, ssa_env))
|
.format(id, ssa_env))
|
||||||
return 0
|
return 0
|
||||||
|
else:
|
||||||
|
err('Unknown operand in eval_oper: {}'
|
||||||
|
.format(operand))
|
||||||
|
|
||||||
|
|
||||||
def eval_binop(bop, left, right):
|
def eval_binop(bop, left, right):
|
||||||
|
@ -461,7 +471,7 @@ def ty2base_ty(ty, tdecs, seen=[]):
|
||||||
elif isinstance(ty, ll.PointerType):
|
elif isinstance(ty, ll.PointerType):
|
||||||
# TODO: Consider if types behind pointers should not be
|
# TODO: Consider if types behind pointers should not be
|
||||||
# expanded. They might be allowed for cyclic types
|
# expanded. They might be allowed for cyclic types
|
||||||
return ll.PointerType(ty2base_ty(ty.inner_ty, tdecs, seen))
|
return ty
|
||||||
if isinstance(ty, ll.StructType):
|
if isinstance(ty, ll.StructType):
|
||||||
return ll.StructType([ty2base_ty(t, tdecs, seen)
|
return ll.StructType([ty2base_ty(t, tdecs, seen)
|
||||||
for t in ty.fields])
|
for t in ty.fields])
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -17,7 +17,7 @@ with open('pypi_readme.rst') as f:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='llvm-minusminus-emulator',
|
name='llvm-minusminus-emulator',
|
||||||
version='1.0.2',
|
version='1.0.3',
|
||||||
description='A simple hacky emulator/debugger for LLVM--',
|
description='A simple hacky emulator/debugger for LLVM--',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
url='https://gitlab.com/cfreksen/llvm--emulator',
|
url='https://gitlab.com/cfreksen/llvm--emulator',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user