aboutsummaryrefslogtreecommitdiff
path: root/crowbar_reference_compiler/ssagen.py
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2020-12-28 14:26:11 -0700
committerMelody Horn <melody@boringcactus.com>2020-12-28 14:26:11 -0700
commit2a17d1324bd7c93a06b0abe687bf6e4d3953c003 (patch)
treeb08c12a6ed2f4f9958b4231ddb345eb981801cfb /crowbar_reference_compiler/ssagen.py
parent960e8c898dc0826d6dd5991f087fcd9d3ee6fcd1 (diff)
downloadreference-compiler-2a17d1324bd7c93a06b0abe687bf6e4d3953c003.tar.gz
reference-compiler-2a17d1324bd7c93a06b0abe687bf6e4d3953c003.zip
make different incorrect assumptions about types
Diffstat (limited to 'crowbar_reference_compiler/ssagen.py')
-rw-r--r--crowbar_reference_compiler/ssagen.py9
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