diff options
author | Melody Horn <melody@boringcactus.com> | 2020-12-28 14:26:11 -0700 |
---|---|---|
committer | Melody Horn <melody@boringcactus.com> | 2020-12-28 14:26:11 -0700 |
commit | 2a17d1324bd7c93a06b0abe687bf6e4d3953c003 (patch) | |
tree | b08c12a6ed2f4f9958b4231ddb345eb981801cfb | |
parent | 960e8c898dc0826d6dd5991f087fcd9d3ee6fcd1 (diff) | |
download | reference-compiler-2a17d1324bd7c93a06b0abe687bf6e4d3953c003.tar.gz reference-compiler-2a17d1324bd7c93a06b0abe687bf6e4d3953c003.zip |
make different incorrect assumptions about types
-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 |