From 2a17d1324bd7c93a06b0abe687bf6e4d3953c003 Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Mon, 28 Dec 2020 14:26:11 -0700 Subject: make different incorrect assumptions about types --- crowbar_reference_compiler/ssagen.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'crowbar_reference_compiler') diff --git a/crowbar_reference_compiler/ssagen.py b/crowbar_reference_compiler/ssagen.py index b326239..abf5c56 100644 --- a/crowbar_reference_compiler/ssagen.py +++ b/crowbar_reference_compiler/ssagen.py @@ -103,10 +103,17 @@ def _(target: ConstantExpression, context: CompileContext) -> SsaResult: context.next_temp += 1 code = [f"%t{temp} =l copy $data{data_dest}"] elif target.type(context.declarations) == BasicType('char'): + value = target.value.strip("'") + if len(value) == 1: + value = ord(value) + elif value == r'\0': + value = 0 + else: + raise NotImplementedError('escape sequence ' + value) data = [] temp = context.next_temp context.next_temp += 1 - code = [f"%t{temp} =l copy {ord(target.value[1])}"] # TODO handle escape sequences + code = [f"%t{temp} =l copy {value}"] elif target.type(context.declarations) == BasicType('bool'): data = [] temp = context.next_temp -- cgit v1.2.3