Commit 2494407a authored by simonpj's avatar simonpj
Browse files

[project @ 1997-03-17 20:34:25 by simonpj]

More small changes towards 2.02
parent 1fb1ab5d
...@@ -65,28 +65,3 @@ dist :: dist-pre ...@@ -65,28 +65,3 @@ dist :: dist-pre
include $(TOP)/mk/target.mk include $(TOP)/mk/target.mk
dist :: dist-post dist :: dist-post
#
# Automatically remake update configuration files
# (from autoconf manual)
#
configure: configure.in
autoconf
#
# autoheader might not change config.h.in, so touch a stamp file.
#
mk/config.h.in: mk/stamp-h.in
mk/stamp-h.in: configure.in
autoheader
echo timestamp > mk/stamp-h.in
mk/config.h: mk/stamp-h
mk/stamp-h: mk/config.h.in config.status
./config.status
config.status: configure
./config.status --recheck
.PHONY: config
config: config.status
@:
TOP = .. TOP = ..
include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/boilerplate.mk
DOC_SRCS = installing.lit release.lit DOC_SRCS = installing.lit
SRC_TEXI2HTML_OPTS += -number -monolithic -invisible xbm SRC_TEXI2HTML_OPTS += -number -monolithic -invisible xbm
......
...@@ -784,6 +784,19 @@ and you're on the road again. ...@@ -784,6 +784,19 @@ and you're on the road again.
You need to be a bit careful, though, that any new files you create You need to be a bit careful, though, that any new files you create
(if you do any development work) are in the source tree, not a build tree! (if you do any development work) are in the source tree, not a build tree!
Remember, that the source files in the build tree are {\em symbolic
links} to the files in the source tree. (The build tree soon
accumulates lots of built files like @Foo.o@, as well.) You can {\em
delete} a source file from the build tree without affecting the source
tree (though it's an odd thing to do). On the other hand, if you {\em
edit} a source file from the build tree, you'll edit the source-tree
file directly. (You can set up Emacs so that if you edit a source
file from the build tree, Emacs will silently create an edited copy of
the source file in the build tree, leaving the source file unchanged;
but the danger is that you think you've edited the source file whereas
actually all you've done is edit the build-tree copy. More commonly
you do want to edit the source file.)
Like the source tree, the top level of your build tree must (a linked copy of) Like the source tree, the top level of your build tree must (a linked copy of)
the root directory of the @fptools@ suite. the root directory of the @fptools@ suite.
Inside Makefiles, the root of your build tree is called @$(FPTOOLS_TOP)@. Inside Makefiles, the root of your build tree is called @$(FPTOOLS_TOP)@.
...@@ -813,27 +826,32 @@ Or, you might want to compile it with debugging on (so that ...@@ -813,27 +826,32 @@ Or, you might want to compile it with debugging on (so that
extra consistency-checking code gets included) or off. And so on. extra consistency-checking code gets included) or off. And so on.
All of this stuff is called the {\em configuration} of your build. All of this stuff is called the {\em configuration} of your build.
You set the configuration using an exciting two-step process. You set the configuration using an exciting three-step process.
\begin{description} \begin{description}
\item[Step 1: system configuration.] This is easy, provided you \item[Step 1: get ready for configuration.]
have the programs mentioned in Section~\ref{sect_std-utils}. Just Change directory to @$(FPTOOLS)@ and issue the following two commands (with no arguments):
@cd@ to @$(FPTOOLS)@ and say @gmake configure@. This \begin{enumerate}
command does three things: \item @autoconf@. This GNU program
\begin{itemize}
\item
It runs a GNU program called @autoconf@, which
converts @$(FPTOOLS)/configure.in@ to a shell script converts @$(FPTOOLS)/configure.in@ to a shell script
called @$(FPTOOLS)/configure@. called @$(FPTOOLS)/configure@.
This step is completely platform-independent; it just means \item @autoheader@. This second GNU program converts
@$(FPTOOLS)/configure.in@ to @$(FPTOOLS)/mk/config.h.in@.
\end{enumerate}
Both these steps are completely platform-independent; they just mean
that the human-written file (@configure.in@) can be short, although that the human-written file (@configure.in@) can be short, although
the resulting shell script, @configure@ is long. the resulting shell script, @configure@, and @mk/config.h.in@, are long.
\item It runs a second GNU program called @autoheader@, which converts In case you don't have @autoconf@ and @autoheader@ we distribute
@$(FPTOOLS)/configure.in@ to @$(FPTOOLS)/mk/config.h.in@. the results, @configure@, and @mk/config.h.in@, with the source distribution.
Again, this step is platform-independent. They aren't kept in the repository, though.
\item It then runs the newly-created @configure@ script. @configure@'s mission \item[Step 2: system configuration.]
Runs the newly-created @configure@ script, thus:
\begin{verbatim}
./configure
\end{verbatim}
@configure@'s mission
is to scurry round your computer working out what architecture it has, is to scurry round your computer working out what architecture it has,
what operating system, whether it has the @vfork@ system call, what operating system, whether it has the @vfork@ system call,
where @yacc@ is kept, whether @gcc@ is available, where various where @yacc@ is kept, whether @gcc@ is available, where various
...@@ -853,10 +871,9 @@ all Makefiles. ...@@ -853,10 +871,9 @@ all Makefiles.
The latter is @#include@d by various C programs, which The latter is @#include@d by various C programs, which
can thereby make use of configuration information. can thereby make use of configuration information.
\end{itemize} \end{itemize}
\end{itemize}
\item[Step 2: build configuration.] Next, you say how this build \item[Step 3: build configuration.] Next, you say how this build
of @fptools@ is to differ from the standard defaults by creating a new of @fptools@ is to differ from the standard defaults by creating a new
file @mk/build.mk@ file @mk/build.mk@
{\em in the build tree}. This file is the one and only {\em in the build tree}. This file is the one and only
...@@ -883,18 +900,18 @@ want to change. (The override occurs because the main boilerplate file, ...@@ -883,18 +900,18 @@ want to change. (The override occurs because the main boilerplate file,
For example, @config.mk.in@ contains the definition: For example, @config.mk.in@ contains the definition:
\begin{verbatim} \begin{verbatim}
SUBDIRS = glafp-utils literate ghc ProjectsToBuild = glafp-utils literate ghc hslibs
\end{verbatim} \end{verbatim}
The accompanying comment explains that this is the list of enabled The accompanying comment explains that this is the list of enabled
projects; that is, if (after configuring) you type @gmake all@ projects; that is, if (after configuring) you type @gmake all@
in @FPTOOLS_TOP@ three specified projects will be made. in @FPTOOLS_TOP@ three specified projects will be made.
If you want to add @happy@, you can add this line to @build.mk@: If you want to add @happy@, you can add this line to @build.mk@:
\begin{verbatim} \begin{verbatim}
SUBDIRS += happy ProjectsToBuild += happy
\end{verbatim} \end{verbatim}
or, if you prefer, or, if you prefer,
\begin{verbatim} \begin{verbatim}
SUBDIRS = glafp-utils literate ghc happy ProjectsToBuild = glafp-utils literate ghc hslibs happy
\end{verbatim} \end{verbatim}
(GNU @make@ allows existing definitions to have new text appended using (GNU @make@ allows existing definitions to have new text appended using
the ``@+=@'' operator, which is quite a convenient feature.) the ``@+=@'' operator, which is quite a convenient feature.)
...@@ -941,10 +958,19 @@ to happen there now. ...@@ -941,10 +958,19 @@ to happen there now.
\begin{verbatim} \begin{verbatim}
cd /scratch/joe-bloggs/myfptools-sun4 cd /scratch/joe-bloggs/myfptools-sun4
\end{verbatim} \end{verbatim}
\item Prepare for system configuration:
\begin{verbatim}
autoconf
autoheader
\end{verbatim}
(You can skip this step if you are starting from a source distribution,
and you already have @configure@ and @mk/config.h.in@.)
\item Do system configuration: \item Do system configuration:
\begin{verbatim} \begin{verbatim}
gmake configure ./configure
\end{verbatim} \end{verbatim}
\item Create the file @mk/build.mk@, \item Create the file @mk/build.mk@,
adding definitions for your desired configuration options. adding definitions for your desired configuration options.
\begin{verbatim} \begin{verbatim}
......
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# $Id: Makefile,v 1.3 1997/03/14 07:53:55 simonpj Exp $ # $Id: Makefile,v 1.4 1997/03/17 20:34:29 simonpj Exp $
# #
TOP=. TOP=.
...@@ -49,7 +49,7 @@ boot :: ...@@ -49,7 +49,7 @@ boot ::
$(line) $(line)
@echo "Booting Prelude libraries" @echo "Booting Prelude libraries"
$(line) $(line)
@$(MAKE) -C compiler boot @$(MAKE) -C lib boot
# "CONTRIB" is also a SUBDIR, but there is nothing to build there. # "CONTRIB" is also a SUBDIR, but there is nothing to build there.
......
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# $Id: Makefile,v 1.8 1997/03/14 07:55:43 simonpj Exp $ # $Id: Makefile,v 1.9 1997/03/17 20:34:30 simonpj Exp $
TOP = .. TOP = ..
include $(TOP)/mk/boilerplate.mk include $(TOP)/mk/boilerplate.mk
...@@ -226,6 +226,7 @@ all :: hsp ...@@ -226,6 +226,7 @@ all :: hsp
hsp: parser/printtree.o parser/main.o libhsp.a hsp: parser/printtree.o parser/main.o libhsp.a
$(CC) -o $@ $(CC_OPTS) $^ $(CC) -o $@ $(CC_OPTS) $^
CLEAN_FILES += hsp
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Interface files # Interface files
......
...@@ -433,7 +433,7 @@ data MagicId ...@@ -433,7 +433,7 @@ data MagicId
-- Argument and return registers -- Argument and return registers
| VanillaReg -- pointers, unboxed ints and chars | VanillaReg -- pointers, unboxed ints and chars
PrimRep -- PtrRep, IntRep, CharRep, StablePtrRep or ForeignObjRep PrimRep -- PtrRep, IntRep, CharRep, StablePtrRep or ForeignObjRep
-- (in case we need to distinguish) -- (in case we need to distinguish)
FAST_INT -- its number (1 .. mAX_Vanilla_REG) FAST_INT -- its number (1 .. mAX_Vanilla_REG)
......
...@@ -747,20 +747,22 @@ ppr_casm_results sty [r] liveness ...@@ -747,20 +747,22 @@ ppr_casm_results sty [r] liveness
(result_type, assign_result) (result_type, assign_result)
= case r_kind of = case r_kind of
{- @ForeignObj@s replaces MallocPtrs and are *not* CReturnable. {-
Instead, external references have to be turned into ForeignObjs @ForeignObj@s replaces MallocPtrs and are *not* CReturnable.
Instead, external references have to explicitly turned into ForeignObjs
using the primop makeForeignObj#. Benefit: Multiple finalisation using the primop makeForeignObj#. Benefit: Multiple finalisation
routines can be accommodated and the below special case is not needed. routines can be accommodated and the below special case is not needed.
Price is, of course, that you have to explicitly wrap `foreign objects' Price is, of course, that you have to explicitly wrap `foreign objects'
with makeForeignObj#. with makeForeignObj#.
+
ForeignObjRep -> ForeignObjRep ->
(uppPStr SLIT("StgForeignObj"), (uppPStr SLIT("StgForeignObj"),
uppBesides [ uppPStr SLIT("constructForeignObj"),uppChar '(', uppBesides [ uppPStr SLIT("constructForeignObj"),uppChar '(',
liveness, uppComma, liveness, uppComma,
result_reg, uppComma, result_reg, uppComma,
local_var, local_var,
pp_paren_semi ]) -} pp_paren_semi ])
-}
_ -> _ ->
(pprPrimKind sty r_kind, (pprPrimKind sty r_kind,
uppBesides [ result_reg, uppEquals, local_var, uppSemi ]) uppBesides [ result_reg, uppEquals, local_var, uppSemi ])
......
...@@ -195,6 +195,7 @@ module Unique ( ...@@ -195,6 +195,7 @@ module Unique (
stateTyConKey, stateTyConKey,
synchVarPrimTyConKey, synchVarPrimTyConKey,
thenMClassOpKey, thenMClassOpKey,
toEnumClassOpKey,
traceIdKey, traceIdKey,
trueDataConKey, trueDataConKey,
unpackCString2IdKey, unpackCString2IdKey,
...@@ -680,4 +681,5 @@ mainPrimIoKey = mkPreludeMiscIdUnique 67 ...@@ -680,4 +681,5 @@ mainPrimIoKey = mkPreludeMiscIdUnique 67
returnMClassOpKey = mkPreludeMiscIdUnique 68 returnMClassOpKey = mkPreludeMiscIdUnique 68
-- Used for minusClassOp 69 -- Used for minusClassOp 69
otherwiseIdKey = mkPreludeMiscIdUnique 70 otherwiseIdKey = mkPreludeMiscIdUnique 70
toEnumClassOpKey = mkPreludeMiscIdUnique 71
\end{code} \end{code}
...@@ -282,7 +282,7 @@ pprDsWarnings sty warns ...@@ -282,7 +282,7 @@ pprDsWarnings sty warns
= ppCat [ppPStr SLIT("in the definition of function"), ppQuote (ppr sty fun)] = ppCat [ppPStr SLIT("in the definition of function"), ppQuote (ppr sty fun)]
pp_match CaseMatch pats pp_match CaseMatch pats
= ppHang (ppPStr SLIT("in a group of case alternative beginning:")) = ppHang (ppPStr SLIT("in a group of case alternatives beginning:"))
4 (ppSep [ppSep (map (ppr sty) pats), pp_arrow_dotdotdot]) 4 (ppSep [ppSep (map (ppr sty) pats), pp_arrow_dotdotdot])
pp_match PatBindMatch pats pp_match PatBindMatch pats
......
...@@ -15,7 +15,7 @@ module PrelInfo ( ...@@ -15,7 +15,7 @@ module PrelInfo (
eq_RDR, ne_RDR, le_RDR, lt_RDR, ge_RDR, gt_RDR, max_RDR, min_RDR, compare_RDR, eq_RDR, ne_RDR, le_RDR, lt_RDR, ge_RDR, gt_RDR, max_RDR, min_RDR, compare_RDR,
minBound_RDR, maxBound_RDR, enumFrom_RDR, enumFromTo_RDR, enumFromThen_RDR, minBound_RDR, maxBound_RDR, enumFrom_RDR, enumFromTo_RDR, enumFromThen_RDR,
enumFromThenTo_RDR, fromEnum_RDR, enumFromThenTo_RDR, fromEnum_RDR, toEnum_RDR,
range_RDR, index_RDR, inRange_RDR, readsPrec_RDR, readList_RDR, range_RDR, index_RDR, inRange_RDR, readsPrec_RDR, readList_RDR,
showsPrec_RDR, showList_RDR, plus_RDR, times_RDR, ltTag_RDR, eqTag_RDR, gtTag_RDR, showsPrec_RDR, showList_RDR, plus_RDR, times_RDR, ltTag_RDR, eqTag_RDR, gtTag_RDR,
eqH_Char_RDR, ltH_Char_RDR, eqH_Word_RDR, ltH_Word_RDR, eqH_Addr_RDR, ltH_Addr_RDR, eqH_Char_RDR, ltH_Char_RDR, eqH_Word_RDR, ltH_Word_RDR, eqH_Addr_RDR, ltH_Addr_RDR,
...@@ -299,6 +299,7 @@ knownKeyNames ...@@ -299,6 +299,7 @@ knownKeyNames
, (enumFromTo_RDR, enumFromToClassOpKey) , (enumFromTo_RDR, enumFromToClassOpKey)
, (enumFromThenTo_RDR, enumFromThenToClassOpKey) , (enumFromThenTo_RDR, enumFromThenToClassOpKey)
, (fromEnum_RDR, fromEnumClassOpKey) , (fromEnum_RDR, fromEnumClassOpKey)
, (toEnum_RDR, toEnumClassOpKey)
, (eq_RDR, eqClassOpKey) , (eq_RDR, eqClassOpKey)
, (thenM_RDR, thenMClassOpKey) , (thenM_RDR, thenMClassOpKey)
, (returnM_RDR, returnMClassOpKey) , (returnM_RDR, returnMClassOpKey)
...@@ -361,6 +362,7 @@ creturnableClass_RDR = tcQual (fOREIGN, SLIT("CReturnable")) ...@@ -361,6 +362,7 @@ creturnableClass_RDR = tcQual (fOREIGN, SLIT("CReturnable"))
fromInt_RDR = varQual (pREL_BASE, SLIT("fromInt")) fromInt_RDR = varQual (pREL_BASE, SLIT("fromInt"))
fromInteger_RDR = varQual (pREL_BASE, SLIT("fromInteger")) fromInteger_RDR = varQual (pREL_BASE, SLIT("fromInteger"))
minus_RDR = varQual (pREL_BASE, SLIT("-")) minus_RDR = varQual (pREL_BASE, SLIT("-"))
toEnum_RDR = varQual (pREL_BASE, SLIT("toEnum"))
fromEnum_RDR = varQual (pREL_BASE, SLIT("fromEnum")) fromEnum_RDR = varQual (pREL_BASE, SLIT("fromEnum"))
enumFrom_RDR = varQual (pREL_BASE, SLIT("enumFrom")) enumFrom_RDR = varQual (pREL_BASE, SLIT("enumFrom"))
enumFromTo_RDR = varQual (pREL_BASE, SLIT("enumFromTo")) enumFromTo_RDR = varQual (pREL_BASE, SLIT("enumFromTo"))
......
...@@ -154,7 +154,8 @@ data PrimOp ...@@ -154,7 +154,8 @@ data PrimOp
| TakeMVarOp | PutMVarOp | TakeMVarOp | PutMVarOp
| ReadIVarOp | WriteIVarOp | ReadIVarOp | WriteIVarOp
| MakeForeignObjOp -- foreign objects (malloc pointers or any old URL) | MakeForeignObjOp -- foreign objects (malloc pointers or any old URL)
| WriteForeignObjOp -- modifying foreign objects [obscuro factor: 200]
| MakeStablePtrOp | DeRefStablePtrOp | MakeStablePtrOp | DeRefStablePtrOp
\end{code} \end{code}
...@@ -413,26 +414,27 @@ tagOf_PrimOp PutMVarOp = ILIT(152) ...@@ -413,26 +414,27 @@ tagOf_PrimOp PutMVarOp = ILIT(152)
tagOf_PrimOp ReadIVarOp = ILIT(153) tagOf_PrimOp ReadIVarOp = ILIT(153)
tagOf_PrimOp WriteIVarOp = ILIT(154) tagOf_PrimOp WriteIVarOp = ILIT(154)
tagOf_PrimOp MakeForeignObjOp = ILIT(155) tagOf_PrimOp MakeForeignObjOp = ILIT(155)
tagOf_PrimOp MakeStablePtrOp = ILIT(156) tagOf_PrimOp WriteForeignObjOp = ILIT(156)
tagOf_PrimOp DeRefStablePtrOp = ILIT(157) tagOf_PrimOp MakeStablePtrOp = ILIT(157)
tagOf_PrimOp (CCallOp _ _ _ _ _) = ILIT(158) tagOf_PrimOp DeRefStablePtrOp = ILIT(158)
tagOf_PrimOp ErrorIOPrimOp = ILIT(159) tagOf_PrimOp (CCallOp _ _ _ _ _) = ILIT(159)
tagOf_PrimOp ReallyUnsafePtrEqualityOp = ILIT(160) tagOf_PrimOp ErrorIOPrimOp = ILIT(160)
tagOf_PrimOp SeqOp = ILIT(161) tagOf_PrimOp ReallyUnsafePtrEqualityOp = ILIT(161)
tagOf_PrimOp ParOp = ILIT(162) tagOf_PrimOp SeqOp = ILIT(162)
tagOf_PrimOp ForkOp = ILIT(163) tagOf_PrimOp ParOp = ILIT(163)
tagOf_PrimOp DelayOp = ILIT(164) tagOf_PrimOp ForkOp = ILIT(164)
tagOf_PrimOp WaitReadOp = ILIT(165) tagOf_PrimOp DelayOp = ILIT(165)
tagOf_PrimOp WaitWriteOp = ILIT(166) tagOf_PrimOp WaitReadOp = ILIT(166)
tagOf_PrimOp WaitWriteOp = ILIT(167)
tagOf_PrimOp ParGlobalOp = ILIT(167)
tagOf_PrimOp ParLocalOp = ILIT(168) tagOf_PrimOp ParGlobalOp = ILIT(168)
tagOf_PrimOp ParAtOp = ILIT(169) tagOf_PrimOp ParLocalOp = ILIT(169)
tagOf_PrimOp ParAtAbsOp = ILIT(170) tagOf_PrimOp ParAtOp = ILIT(170)
tagOf_PrimOp ParAtRelOp = ILIT(171) tagOf_PrimOp ParAtAbsOp = ILIT(171)
tagOf_PrimOp ParAtForNowOp = ILIT(172) tagOf_PrimOp ParAtRelOp = ILIT(172)
tagOf_PrimOp CopyableOp = ILIT(173) tagOf_PrimOp ParAtForNowOp = ILIT(173)
tagOf_PrimOp NoFollowOp = ILIT(174) tagOf_PrimOp CopyableOp = ILIT(174)
tagOf_PrimOp NoFollowOp = ILIT(175)
tagOf_PrimOp _ = panic# "tagOf_PrimOp: pattern-match" tagOf_PrimOp _ = panic# "tagOf_PrimOp: pattern-match"
...@@ -597,6 +599,7 @@ allThePrimOps ...@@ -597,6 +599,7 @@ allThePrimOps
ReadIVarOp, ReadIVarOp,
WriteIVarOp, WriteIVarOp,
MakeForeignObjOp, MakeForeignObjOp,
WriteForeignObjOp,
MakeStablePtrOp, MakeStablePtrOp,
DeRefStablePtrOp, DeRefStablePtrOp,
ReallyUnsafePtrEqualityOp, ReallyUnsafePtrEqualityOp,
...@@ -1147,7 +1150,7 @@ primOpInfo WaitWriteOp ...@@ -1147,7 +1150,7 @@ primOpInfo WaitWriteOp
%************************************************************************ %************************************************************************
%* * %* *
\subsubsection[PrimOps-makeForeignObj]{PrimOpInfo for Foreign Objects} \subsubsection[PrimOps-ForeignObj]{PrimOpInfo for Foreign Objects}
%* * %* *
%************************************************************************ %************************************************************************
...@@ -1164,7 +1167,7 @@ When a @ForeignObj@ becomes garbage, a user-defined finalisation routine ...@@ -1164,7 +1167,7 @@ When a @ForeignObj@ becomes garbage, a user-defined finalisation routine
associated with the object is invoked (currently, each ForeignObj has a associated with the object is invoked (currently, each ForeignObj has a
direct reference to its finaliser). -- SOF direct reference to its finaliser). -- SOF
The only function defined over @ForeignObj@s is: A @ForeignObj@ is created by the @makeForeignObj#@ primitive:
\begin{pseudocode} \begin{pseudocode}
makeForeignObj# :: Addr# -- foreign object makeForeignObj# :: Addr# -- foreign object
...@@ -1172,6 +1175,7 @@ makeForeignObj# :: Addr# -- foreign object ...@@ -1172,6 +1175,7 @@ makeForeignObj# :: Addr# -- foreign object
-> StateAndForeignObj# _RealWorld# ForeignObj# -> StateAndForeignObj# _RealWorld# ForeignObj#
\end{pseudocode} \end{pseudocode}
\begin{code} \begin{code}
primOpInfo MakeForeignObjOp primOpInfo MakeForeignObjOp
= AlgResult SLIT("makeForeignObj#") [] = AlgResult SLIT("makeForeignObj#") []
...@@ -1179,6 +1183,34 @@ primOpInfo MakeForeignObjOp ...@@ -1179,6 +1183,34 @@ primOpInfo MakeForeignObjOp
stateAndForeignObjPrimTyCon [realWorldTy] stateAndForeignObjPrimTyCon [realWorldTy]
\end{code} \end{code}
[Experimental--SOF]
In addition, another @ForeignObj@ primitive is provided for destructively modifying
the external object wrapped up inside a @ForeignObj@. This primitive is used
when a mixed programming interface of implicit and explicit de-allocation is used,
e.g., if @ForeignObj@s are used to implement @Handle@s, then @Handle@s can be
released either explicitly (through @hClose@) or implicitly (via a finaliser).
When releasing/closing the @Handle@ explicitly, care must be taken to avoid having
the finaliser for the embedded @ForeignObj@ attempt the same thing later.
We deal with this situation, by allowing the programmer to destructively modify
the data field of the @ForeignObj@ to hold a special value the finaliser recognises,
and does not attempt to free (e.g., filling the data slot with \tr{NULL}).
\begin{pseudocode}
writeForeignObj# :: ForeignObj# -- foreign object
-> Addr# -- new data value
-> StateAndForeignObj# _RealWorld# ForeignObj#
\end{pseudocode}
\begin{code}
primOpInfo WriteForeignObjOp
= let {
s = alphaTy; s_tv = alphaTyVar
} in
PrimResult SLIT("writeForeignObj#") [s_tv]
[foreignObjPrimTy, addrPrimTy, mkStatePrimTy s]
statePrimTyCon VoidRep [s]
\end{code}
%************************************************************************ %************************************************************************
%* * %* *
\subsubsection[PrimOp-stable-pointers]{PrimOpInfo for ``stable pointers''} \subsubsection[PrimOp-stable-pointers]{PrimOpInfo for ``stable pointers''}
...@@ -1411,6 +1443,7 @@ primOpHeapReq (CCallOp _ _ mayGC@True _ _) = VariableHeapRequired ...@@ -1411,6 +1443,7 @@ primOpHeapReq (CCallOp _ _ mayGC@True _ _) = VariableHeapRequired
primOpHeapReq (CCallOp _ _ mayGC@False _ _) = NoHeapRequired primOpHeapReq (CCallOp _ _ mayGC@False _ _) = NoHeapRequired
primOpHeapReq MakeForeignObjOp = VariableHeapRequired primOpHeapReq MakeForeignObjOp = VariableHeapRequired
primOpHeapReq WriteForeignObjOp = NoHeapRequired
-- this occasionally has to expand the Stable Pointer table -- this occasionally has to expand the Stable Pointer table
primOpHeapReq MakeStablePtrOp = VariableHeapRequired primOpHeapReq MakeStablePtrOp = VariableHeapRequired
...@@ -1557,7 +1590,8 @@ fragilePrimOp :: PrimOp -> Bool ...@@ -1557,7 +1590,8 @@ fragilePrimOp :: PrimOp -> Bool
fragilePrimOp ParOp = True fragilePrimOp ParOp = True
fragilePrimOp ForkOp = True fragilePrimOp ForkOp = True
fragilePrimOp SeqOp = True fragilePrimOp SeqOp = True
fragilePrimOp MakeForeignObjOp = True -- SOF fragilePrimOp MakeForeignObjOp = True -- SOF
fragilePrimOp WriteForeignObjOp = True -- SOF
fragilePrimOp MakeStablePtrOp = True fragilePrimOp MakeStablePtrOp = True
fragilePrimOp DeRefStablePtrOp = True -- ??? JSM & ADR fragilePrimOp DeRefStablePtrOp = True -- ??? JSM & ADR
...@@ -1629,6 +1663,7 @@ primOpNeedsWrapper DoubleEncodeOp = True ...@@ -1629,6 +1663,7 @@ primOpNeedsWrapper DoubleEncodeOp = True
primOpNeedsWrapper DoubleDecodeOp = True primOpNeedsWrapper DoubleDecodeOp = True
primOpNeedsWrapper MakeForeignObjOp = True primOpNeedsWrapper MakeForeignObjOp = True
primOpNeedsWrapper WriteForeignObjOp = True
primOpNeedsWrapper MakeStablePtrOp = True primOpNeedsWrapper MakeStablePtrOp = True
primOpNeedsWrapper DeRefStablePtrOp = True primOpNeedsWrapper DeRefStablePtrOp = True
......
...@@ -531,7 +531,7 @@ is_sym c#= ...@@ -531,7 +531,7 @@ is_sym c#=
'&'# -> True; '*'# -> True; '+'# -> True; '.'# -> True; '&'# -> True; '*'# -> True; '+'# -> True; '.'# -> True;
'/'# -> True; '<'# -> True; '='# -> True; '>'# -> True; '/'# -> True; '<'# -> True; '='# -> True; '>'# -> True;
'?'# -> True; '\\'# -> True; '^'# -> True; '|'# -> True; '?'# -> True; '\\'# -> True; '^'# -> True; '|'# -> True;
'-'# -> True; '~'# -> True; _ -> False } '-'# -> True; '~'# -> True; '@'# -> True; _ -> False }
--isAlphanum c || c `elem` ":_'!#$%&*+./<=>?@\\^|-~" -- ToDo: add ISOgraphic --isAlphanum c || c `elem` ":_'!#$%&*+./<=>?@\\^|-~" -- ToDo: add ISOgraphic
......
...@@ -32,7 +32,9 @@ import HsPragmas ( noGenPragmas ) ...@@ -32,7 +32,9 @@ import HsPragmas ( noGenPragmas )
import RdrHsSyn ( SYN_IE(RdrNameHsDecl), SYN_IE(RdrNameInstDecl), import RdrHsSyn ( SYN_IE(RdrNameHsDecl), SYN_IE(RdrNameInstDecl),
RdrName, rdrNameOcc RdrName, rdrNameOcc
) )
import RnEnv ( newGlobalName, lookupRn, addImplicitOccsRn, availName, availNames, addAvailToNameSet ) import RnEnv ( newGlobalName, lookupRn, addImplicitOccsRn,
availName, availNames, addAvailToNameSet, pprAvail
)
import RnSource ( rnHsType ) import RnSource ( rnHsType )
import RnMonad import RnMonad
import ParseIface ( parseIface ) import ParseIface ( parseIface )
...@@ -275,6 +277,7 @@ importDecl :: Name -> Necessity -> RnMG (Maybe RdrNameHsDecl) ...@@ -275,6 +277,7 @@ importDecl :: Name -> Necessity -> RnMG (Maybe RdrNameHsDecl)
importDecl name necessity importDecl name necessity
= checkSlurped name `thenRn` \ already_slurped -> = checkSlurped name `thenRn` \ already_slurped ->
if already_slurped then if already_slurped then
-- traceRn (ppSep [ppStr "Already slurped:", ppr PprDebug name]) `thenRn_`
returnRn Nothing -- Already dealt with returnRn Nothing -- Already dealt with
else else
if isWiredInName name then if isWiredInName name then
...@@ -336,37 +339,45 @@ that we know just what instances to bring into scope. ...@@ -336,37 +339,45 @@ that we know just what instances to bring into scope.
\begin{code} \begin{code}
getWiredInDecl name getWiredInDecl name
= -- Force in the home module in case it has instance decls for = get_wired `thenRn` \ avail ->
-- the thing we are interested in recordSlurp Nothing avail `thenRn_`
(if not is_tycon || mod == gHC__ then
returnRn () -- Mini hack 1: no point for non-tycons; and if we -- Force in the home module in case it has instance decls for
-- do this we find PrelNum trying to import PackedString, -- the thing we are interested in.
-- because PrelBase's .hi file mentions PackedString.unpackString --
-- But PackedString.hi isn't built by that point! -- Mini hack 1: no point for non-tycons/class; and if we
-- -- do this we find PrelNum trying to import PackedString,
-- Mini hack 2; GHC is guaranteed not to have -- because PrelBase's .hi file mentions PackedString.unpackString
-- instance decls, so it's a waste of time