Support recursive types (through pointers).

Increment version.
This commit is contained in:
cfreksen 2017-11-09 18:23:21 +01:00
parent 5381c0037f
commit dda7b25c15
No known key found for this signature in database
GPG Key ID: EAC13EE101008978
2 changed files with 18 additions and 8 deletions

View File

@ -211,19 +211,26 @@ def step(insns, terminator, blocks, stack_frames, ssa_env, global_env, heap,
if not isinstance(actual_oper_ty, ll.PointerType):
err('Type of main operand to getelementptr must be a pointer type. It was {}'
.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:
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)
gep_res, formula = handle_gep(oper_v, actual_base_ty, steps, ssa_env,
global_env)
res = gep_res
# 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: {}'
.format(formula))
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{}'
.format(id, ssa_env))
return 0
else:
err('Unknown operand in eval_oper: {}'
.format(operand))
def eval_binop(bop, left, right):
@ -461,7 +471,7 @@ def ty2base_ty(ty, tdecs, seen=[]):
elif isinstance(ty, ll.PointerType):
# TODO: Consider if types behind pointers should not be
# 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):
return ll.StructType([ty2base_ty(t, tdecs, seen)
for t in ty.fields])

View File

@ -17,7 +17,7 @@ with open('pypi_readme.rst') as f:
setup(
name='llvm-minusminus-emulator',
version='1.0.2',
version='1.0.3',
description='A simple hacky emulator/debugger for LLVM--',
long_description=long_description,
url='https://gitlab.com/cfreksen/llvm--emulator',