diff options
Diffstat (limited to 'crowbar_reference_compiler')
-rw-r--r-- | crowbar_reference_compiler/ssagen.py | 9 |
1 files changed, 8 insertions, 1 deletions
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 |