Add support for print from runtime.c.
This commit is contained in:
parent
8afdf563b3
commit
cea1cece13
|
@ -25,7 +25,10 @@ class Garbage(Enum):
|
|||
return '<<Garbage>>'
|
||||
|
||||
|
||||
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))
|
||||
|
|
Loading…
Reference in New Issue
Block a user