Commit 0f9750be authored by krc's avatar krc

[project @ 2003-08-19 21:59:40 by krc]

Two issues:

1. According to the spec for External Core, datatype declarations are required
to have at least one data constructor. Previously, if you tried to generate
External Core for a program containing a datatype declaration with no
constructors, generating the Core file would succeed, but compiling it would
result in a parse error. Changed MkExternalCore to signal an error if such
a declaration is encountered while compiling to External Core.

2. Previously, MachLabel literals were translated into Externals when compiling
to External Core. This is wrong -- such literals are not foreign calls and
can't be handled in the same way (compiling any External Core code generated
from code containing literals resulting from "foreign label" declarations would
result in a strange error message). There doesn't seem to be any way to
correctly represent these labels in External Core, so MkExternalCore now
signals an error if one of these is encountered as well.
parent f3c159a9
......@@ -96,6 +96,7 @@ collect_tdefs tcon tdefs
where
tdef | isNewTyCon tcon =
C.Newtype (make_con_qid (tyConName tcon)) (map make_tbind tyvars) repclause
| null (tyConDataCons tcon) = error "MkExternalCore died: can't handle datatype declarations with no data constructors"
| otherwise =
C.Data (make_con_qid (tyConName tcon)) (map make_tbind tyvars) (map make_cdef (tyConDataCons tcon))
where repclause | isRecursiveTyCon tcon = Nothing
......@@ -135,7 +136,7 @@ make_exp (Var v) =
FCallId (CCall (CCallSpec (StaticTarget nm) _ _)) -> C.External (unpackFS nm) (make_ty (varType v))
FCallId _ -> error "MkExternalCore died: can't handle non-static-C foreign call"
_ -> C.Var (make_var_qid (Var.varName v))
make_exp (Lit (l@(MachLabel s _))) = C.External (unpackFS s) (make_ty (literalType l))
make_exp (Lit (l@(MachLabel s _))) = error "MkExternalCore died: can't handle \"foreign label\" declarations"
make_exp (Lit l) = C.Lit (make_lit l)
make_exp (App e (Type t)) = C.Appt (make_exp e) (make_ty t)
make_exp (App e1 e2) = C.App (make_exp e1) (make_exp e2)
......
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