diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-05-12 18:08:55 +0200 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-05-12 18:08:55 +0200 |
commit | 4460e137aaea9edf282de7e363f12507eacdc8a4 (patch) | |
tree | b7e7793c9fb29c44f6b916157fe3c76828a9e919 | |
parent | 4dd21ad51771619a0f750122f928872ed48e8c3b (diff) |
refactoring
-rw-r--r-- | src/LambdaCube/Compiler/DesugaredSource.hs | 7 | ||||
-rw-r--r-- | src/LambdaCube/Compiler/Parser.hs | 13 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/LambdaCube/Compiler/DesugaredSource.hs b/src/LambdaCube/Compiler/DesugaredSource.hs index 6dc35f95..608d669f 100644 --- a/src/LambdaCube/Compiler/DesugaredSource.hs +++ b/src/LambdaCube/Compiler/DesugaredSource.hs | |||
@@ -198,10 +198,12 @@ data FNameTag | |||
198 | | F'Ordering | FLT | FGT | FEQ | 198 | | F'Ordering | FLT | FGT | FEQ |
199 | | F'List | FNil | FCons | 199 | | F'List | FNil | FCons |
200 | | F'HList | FHCons | FHNil | 200 | | F'HList | FHCons | FHNil |
201 | | F'VecS | FV2 | FV3 | FV4 | ||
201 | | FRecordCons | 202 | | FRecordCons |
202 | | FRecItem | 203 | | FRecItem |
204 | | FSx | FSy | FSz | FSw | ||
203 | -- type constructors | 205 | -- type constructors |
204 | | F'Int | F'Word | F'Float | F'String | F'Char | F'VecS | F'Output | 206 | | F'Int | F'Word | F'Float | F'String | F'Char | F'Output |
205 | -- functions | 207 | -- functions |
206 | | Fcoe | FparEval | Ft2C | FprimFix | 208 | | Fcoe | FparEval | Ft2C | FprimFix |
207 | | F'T2 | F'EqCT | F'CW | F'Split | F'VecScalar | 209 | | F'T2 | F'EqCT | F'CW | F'Split | F'VecScalar |
@@ -314,9 +316,6 @@ pattern SAppV2 f a b = f `SAppV` a `SAppV` b | |||
314 | 316 | ||
315 | infixl 2 `SAppV`, `SAppH` | 317 | infixl 2 `SAppV`, `SAppH` |
316 | 318 | ||
317 | pattern SBuiltin' s <- SGlobal (SIName _ s) | ||
318 | where SBuiltin' s = SGlobal (SIName (debugSI $ "builtin " ++ s) s) | ||
319 | |||
320 | pattern SBuiltin s = SGlobal (Tag s) | 319 | pattern SBuiltin s = SGlobal (Tag s) |
321 | 320 | ||
322 | pattern ConsName <- SIName _ ":" | 321 | pattern ConsName <- SIName _ ":" |
diff --git a/src/LambdaCube/Compiler/Parser.hs b/src/LambdaCube/Compiler/Parser.hs index e7c6e541..154f5c7a 100644 --- a/src/LambdaCube/Compiler/Parser.hs +++ b/src/LambdaCube/Compiler/Parser.hs | |||
@@ -227,13 +227,20 @@ parseTermApp = | |||
227 | parseTermSwiz = level parseTermProj $ \t -> | 227 | parseTermSwiz = level parseTermProj $ \t -> |
228 | mkSwizzling t <$> lexeme (try_ "swizzling" $ char '%' *> count' 1 4 (satisfy (`elem` ("xyzwrgba" :: String)))) | 228 | mkSwizzling t <$> lexeme (try_ "swizzling" $ char '%' *> count' 1 4 (satisfy (`elem` ("xyzwrgba" :: String)))) |
229 | where | 229 | where |
230 | mkSwizzling term = swizzcall . map (sc . synonym) | 230 | mkSwizzling term = swizzcall . map (SBuiltin . sc . synonym) |
231 | where | 231 | where |
232 | swizzcall [] = error "impossible: swizzling parsing returned empty pattern" | 232 | swizzcall [] = error "impossible: swizzling parsing returned empty pattern" |
233 | swizzcall [x] = SBuiltin Fswizzscalar `SAppV` term `SAppV` x | 233 | swizzcall [x] = SBuiltin Fswizzscalar `SAppV` term `SAppV` x |
234 | swizzcall xs = SBuiltin Fswizzvector `SAppV` term `SAppV` foldl SAppV (SBuiltin' $ "V" ++ show (length xs)) xs | 234 | swizzcall xs = SBuiltin Fswizzvector `SAppV` term `SAppV` foldl SAppV (SBuiltin $ f (length xs)) xs |
235 | 235 | ||
236 | sc c = SBuiltin' ['S', c] | 236 | sc 'x' = FSx |
237 | sc 'y' = FSy | ||
238 | sc 'z' = FSz | ||
239 | sc 'w' = FSw | ||
240 | |||
241 | f 2 = FV2 | ||
242 | f 3 = FV3 | ||
243 | f 4 = FV4 | ||
237 | 244 | ||
238 | synonym 'r' = 'x' | 245 | synonym 'r' = 'x' |
239 | synonym 'g' = 'y' | 246 | synonym 'g' = 'y' |