aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Sil/Compile.icl10
1 files changed, 10 insertions, 0 deletions
diff --git a/Sil/Compile.icl b/Sil/Compile.icl
index 81196bf..e342a66 100644
--- a/Sil/Compile.icl
+++ b/Sil/Compile.icl
@@ -47,6 +47,8 @@ where
opt ['ABC'.PushI i:'ABC'.Update_b 0 l:'ABC'.Pop_b n:ss] | l == n = ['ABC'.Pop_b n:'ABC'.PushI i:opt ss]
opt ['ABC'.Pop_a i:'ABC'.Pop_a j:ss] = opt ['ABC'.Pop_a (i+j):ss]
opt ['ABC'.Pop_b i:'ABC'.Pop_b j:ss] = opt ['ABC'.Pop_b (i+j):ss]
+ opt ['ABC'.Rtn:ss] = ['ABC'.Rtn:opt $ skipUntilEntryPoint ss]
+ opt ['ABC'.Jmp l:ss] = ['ABC'.Jmp l:opt $ skipUntilEntryPoint ss]
opt [s:ss] = [s:opt ss]
opt [] = []
@@ -58,6 +60,14 @@ where
isUseful ('ABC'.Comment _) = False
isUseful _ = True
+ skipUntilEntryPoint :: 'ABC'.Assembler -> 'ABC'.Assembler
+ skipUntilEntryPoint ss
+ | all (\t -> t =: ('ABC'.Annotation _)) before = ss
+ | otherwise = skipUntilEntryPoint $ tl ss
+ where
+ (before,after) = span (not o (\t -> t =: ('ABC'.Label _))) ss
+ skipUntilEntryPoint [] = []
+
:: Address
= AAddr Int
| BAddr Int