Changeset 6248 for src/Pugs/Compile.hs
- Timestamp:
- 08/14/05 17:32:14 (3 years ago)
- svk:copy_cache_prev:
- 8452
- Files:
-
- 1 modified
-
src/Pugs/Compile.hs (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Compile.hs
r6230 r6248 49 49 50 50 -- Compile instances 51 instance Compile (Var, [(TVar Bool, TVar VRef)]) (PIL_Decl) where 51 instance Compile () PIL_Environment where 52 compile _ = do 53 glob <- askGlobal 54 main <- asks envBody 55 globPIL <- compile glob 56 mainPIL <- compile main 57 return $ PIL_Environment globPIL mainPIL 58 59 instance Compile (Var, [(TVar Bool, TVar VRef)]) PIL_Decl where 52 60 compile = compError 53 61 … … 126 134 return [PSub name (subType vsub) paramsC bodyC] 127 135 128 instance Compile (String, [(TVar Bool, TVar VRef)]) (PIL_Expr)where136 instance Compile (String, [(TVar Bool, TVar VRef)]) PIL_Expr where 129 137 compile (name, _) = return $ PRawName name 130 138 131 instance Compile Exp (PIL_Stmts)where139 instance Compile Exp PIL_Stmts where 132 140 compile (Pos _ rest) = compile rest -- fmap (PPos pos rest) $ compile rest 133 141 compile (Cxt cxt rest) = enter cxt $ compile rest … … 149 157 enter cxt = local (\e -> e{ envContext = cxt }) 150 158 151 compileStmts :: Exp -> Comp (PIL_Stmts)159 compileStmts :: Exp -> Comp PIL_Stmts 152 160 compileStmts exp = case exp of 153 161 Stmts this Noop -> do … … 170 178 _ -> compile (Stmts exp Noop) 171 179 172 instance Compile Val (PIL_Stmt)where180 instance Compile Val PIL_Stmt where 173 181 compile = fmap PStmt . compile . Val 174 182 175 instance Compile Val (PIL_Expr)where183 instance Compile Val PIL_Expr where 176 184 compile = compile . Val 177 185 178 instance Compile Exp (PIL_Stmt)where186 instance Compile Exp PIL_Stmt where 179 187 compile (Pos pos rest) = fmap (PPos pos rest) $ compile rest 180 188 compile (Cxt cxt rest) = enter cxt $ compile rest … … 250 258 compile x = compError x 251 259 252 instance Compile Exp (PIL_LValue)where260 instance Compile Exp PIL_LValue where 253 261 compile (Pos _ rest) = compile rest -- fmap (PPos pos rest) $ compile rest 254 262 compile (Cxt cxt rest) = enter cxt $ compile rest … … 311 319 compile exp = compError exp 312 320 313 compLoop :: Exp -> Comp (PIL_Stmt)321 compLoop :: Exp -> Comp PIL_Stmt 314 322 compLoop (Syn name [cond, body]) = do 315 323 cxt <- askTCxt … … 323 331 appropriate function call (@&statement_control:if@ or 324 332 @&statement_control:unless@). -} 325 compConditional :: Exp -> Comp (PIL_LValue)333 compConditional :: Exp -> Comp PIL_LValue 326 334 compConditional (Syn name exps) = do 327 335 [condC, trueC, falseC] <- compile exps … … 332 340 333 341 {-| Compiles various 'Exp's to 'PIL_Expr's. -} 334 instance Compile Exp (PIL_Expr)where342 instance Compile Exp PIL_Expr where 335 343 compile (Pos _ rest) = compile rest -- fmap (PPos pos rest) $ compile rest 336 344 compile (Cxt cxt rest) = enter cxt $ compile rest … … 363 371 364 372 {-| Compiles a 'Val' to a 'PIL_Literal'. -} 365 instance Compile Val (PIL_Literal)where373 instance Compile Val PIL_Literal where 366 374 compile val = return $ PVal val 367 375
