Commit 7c377a7a authored by rl@cse.unsw.edu.au's avatar rl@cse.unsw.edu.au
Browse files

Extend vectorisation built-in mappings with datacons

parent 91b99be0
......@@ -7,7 +7,8 @@
module VectBuiltIn (
Builtins(..), sumTyCon, prodTyCon, combinePAVar,
initBuiltins, initBuiltinTyCons, initBuiltinPAs, initBuiltinPRs,
initBuiltins, initBuiltinTyCons, initBuiltinDataCons,
initBuiltinPAs, initBuiltinPRs,
initBuiltinBoxedTyCons,
primMethod, primPArray
......@@ -19,7 +20,7 @@ import DsMonad
import IfaceEnv ( lookupOrig )
import Module ( Module )
import DataCon ( DataCon )
import DataCon ( DataCon, dataConName )
import TyCon ( TyCon, tyConName, tyConDataCons )
import Var ( Var )
import Id ( mkSysLocal )
......@@ -32,7 +33,7 @@ import Type ( Type )
import TysPrim
import TysWiredIn ( unitTyCon, tupleTyCon,
intTyCon, intTyConName,
boolTyCon, boolTyConName )
boolTyCon, boolTyConName, trueDataCon, falseDataCon )
import Module
import BasicTypes ( Boxity(..) )
......@@ -191,6 +192,12 @@ initBuiltinTyCons bi = (tyConName funTyCon, closureTyCon bi)
defaultTyCons :: [TyCon]
defaultTyCons = [intTyCon, boolTyCon]
initBuiltinDataCons :: Builtins -> [(Name, DataCon)]
initBuiltinDataCons bi = [(dataConName dc, dc)| dc <- defaultDataCons]
defaultDataCons :: [DataCon]
defaultDataCons = [trueDataCon, falseDataCon]
initBuiltinDicts :: [(Name, Module, FastString)] -> DsM [(Name, Var)]
initBuiltinDicts ps
= do
......
......@@ -162,6 +162,10 @@ extendTyConsEnv :: [(Name, TyCon)] -> GlobalEnv -> GlobalEnv
extendTyConsEnv ps genv
= genv { global_tycons = extendNameEnvList (global_tycons genv) ps }
extendDataConsEnv :: [(Name, DataCon)] -> GlobalEnv -> GlobalEnv
extendDataConsEnv ps genv
= genv { global_datacons = extendNameEnvList (global_datacons genv) ps }
extendPAFunsEnv :: [(Name, Var)] -> GlobalEnv -> GlobalEnv
extendPAFunsEnv ps genv
= genv { global_pa_funs = extendNameEnvList (global_pa_funs genv) ps }
......@@ -485,7 +489,8 @@ initV hsc_env guts info p
go =
do
builtins <- initBuiltins
let builtin_tycons = initBuiltinTyCons builtins
let builtin_tycons = initBuiltinTyCons builtins
builtin_datacons = initBuiltinDataCons builtins
builtin_pas <- initBuiltinPAs builtins
builtin_prs <- initBuiltinPRs builtins
builtin_boxed <- initBuiltinBoxedTyCons builtins
......@@ -495,6 +500,7 @@ initV hsc_env guts info p
instEnvs = (eps_inst_env eps, mg_inst_env guts)
let genv = extendTyConsEnv builtin_tycons
. extendDataConsEnv builtin_datacons
. extendPAFunsEnv builtin_pas
. setPRFunsEnv builtin_prs
. setBoxedTyConsEnv builtin_boxed
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment