aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-12-01 22:31:08 +0100
committertomsmeding <tom.smeding@gmail.com>2017-12-01 22:31:08 +0100
commitbe8e209956b3f93b181eb730c743a6d72ddfbbb3 (patch)
tree515eca6fc9156c054f8853f898507504dfda84a0
parent6111c84e1b3ff9a64a9974998bfe75e9b8db2719 (diff)
Fix string offsets
-rw-r--r--BuildIR.hs4
1 files changed, 3 insertions, 1 deletions
diff --git a/BuildIR.hs b/BuildIR.hs
index c70d538..e34d7f5 100644
--- a/BuildIR.hs
+++ b/BuildIR.hs
@@ -135,8 +135,10 @@ internString :: String -> BuildM Ref
internString str = do
i <- genId
let n = "__str_cnst_" ++ show i
+ ref' <- genTempForType TInt
ref <- genTempForType TInt
- addIns $ ILea ref n
+ addIns $ ILea ref' n
+ addIns $ IAri AAdd ref ref' (Constant (refSize ref') (fromIntegral $ sizeof TInt))
state $ \s -> (ref, s {internedStrings = internedStrings s ++ [(n, str)]})