|
@@ -4009,19 +4009,20 @@ environment.
|
|
|
\end{figure}
|
|
|
|
|
|
\begin{exercise}\normalfont
|
|
|
-Complete the implementation of \code{type-check-R2} and test it on 10
|
|
|
-new example programs in $R_2$ that you choose based on how thoroughly
|
|
|
-they test the type checking function. Half of the example programs
|
|
|
-should have a type error to make sure that your type checker properly
|
|
|
-rejects them. The other half of the example programs should not have
|
|
|
-type errors. Your testing should check that the result of the type
|
|
|
-checker agrees with the value returned by the interpreter, that is, if
|
|
|
-the type checker returns \key{Integer}, then the interpreter should
|
|
|
-return an integer. Likewise, if the type checker returns
|
|
|
-\key{Boolean}, then the interpreter should return \code{\#t} or
|
|
|
-\code{\#f}. Note that if your type checker does not signal an error
|
|
|
-for a program, then interpreting that program should not encounter an
|
|
|
-error. If it does, there is something wrong with your type checker.
|
|
|
+Complete the implementation of \code{type-check}. Test your type
|
|
|
+checker using \code{interp-tests} and \code{compiler-tests} by passing
|
|
|
+the \code{type-check} function as the second argument. Create 10 new
|
|
|
+example programs in $R_2$ that you choose based on how thoroughly they
|
|
|
+test you type checking function. Half of the example programs should
|
|
|
+have a type error to make sure that your type checker properly rejects
|
|
|
+them. For those programs, to signal that a type error is expected,
|
|
|
+create an empty file with the same base name but with file extension
|
|
|
+\code{.tyerr}. For example, if the test \code{r2\_14.rkt} is expected
|
|
|
+to error, then create an empty file named \code{r2\_14.tyerr}. The
|
|
|
+other half of the example programs should not have type errors. Note
|
|
|
+that if your type checker does not signal an error for a program, then
|
|
|
+interpreting that program should not encounter an error. If it does,
|
|
|
+there is something wrong with your type checker.
|
|
|
\end{exercise}
|
|
|
|
|
|
|
|
@@ -4178,10 +4179,11 @@ on whether the comparison came out according to the condition code
|
|
|
\itm{cc} (\key{e} for equal, \key{l} for less, \key{le} for
|
|
|
less-or-equal, \key{g} for greater, \key{ge} for greater-or-equal).
|
|
|
The \key{set} instruction has an annoying quirk in that its
|
|
|
-destination argument must be single byte register, such as \code{al},
|
|
|
-which is part of the \code{rax} register. Thankfully, the
|
|
|
-\key{movzbq} instruction can then be used to move from a single byte
|
|
|
-register to a normal 64-bit register.
|
|
|
+destination argument must be single byte register, such as \code{al}
|
|
|
+(L for lower bits) or \code{ah} (H for higher bits), which are part of
|
|
|
+the \code{rax} register. Thankfully, the \key{movzbq} instruction can
|
|
|
+then be used to move from a single byte register to a normal 64-bit
|
|
|
+register.
|
|
|
|
|
|
The x86 instruction for conditional jump are relevant to the
|
|
|
compilation of \key{if} expressions. The \key{JmpIf} instruction
|