diff --git a/llvm_emulator/stepper.py b/llvm_emulator/stepper.py index 8a89db1..013756c 100644 --- a/llvm_emulator/stepper.py +++ b/llvm_emulator/stepper.py @@ -25,7 +25,10 @@ class Garbage(Enum): return '<>' -builtins = ['allocRecord', 'initArray'] +builtins = ['allocRecord', 'initArray', 'stringEqual', 'stringNotEq', 'stringLess', + 'stringLessEq', 'stringGreater', 'stringGreaterEq', 'exponent', 'print', + 'flush', 'getChar', 'ord', 'chr', 'size', 'substring', 'concat', 'not', + 'exit_tig'] def step(insns, terminator, blocks, stack_frames, ssa_env, global_env, heap, @@ -580,6 +583,18 @@ def emulate_builtin(name, arguments_v, ssa_env, heap): struct_begin + 1, array_begin, array_init_s)) res = struct_begin + elif name == 'print': + if len(arguments_v) != 2: + err('Number of arguments to {} should be 3' + .format(name)) + else: + struct_begin = arguments_v[1] + print('Printing string, heap[{}]:' + .format(struct_begin)) + printee = heap[struct_begin + 1] + print(printee) + if not isinstance(printee, str): + warn('What was printed, was not stored as a string in the heap') elif name in builtins: TODO('Have not implemented builtin function {}, yet.' .format(name))