Homework #10: Extending a (byte code) continuation based interpreter
Out: Friday, March 31st, Due: Thursday, April 13th, 11:59pm
Background
The language for this homework is:
#lang plait
In this assignment you will start with the interpreter from
Lecture 18
and add some list-related primitives to it.
Unlike Homework 8,
we’ll be taking a dynamically typed approach, and allow things like e.g.
Added builtin identifier empty for the empty list, along with
builtin function non-empty? so the following tests pass ( (read-int is defined in
in the given skeleton).
Defined FLANG variants Cons, First, and Rest to represent
analogous operations to cons, first, rest in racket.
Updated compile with appropriate .... based stubs to get things compiling again.
Updated the parser to understand concrete syntax for cons, first, rest.
Added the following tests
Note that an earlier version of byte code FLANG interpreter had the read-int
function defined inside the test submodule. You need it defined in
the top level module for the handin server.
Part 1: Compilation to byte code for first and rest
Use the given tags tag:Cons, tag:First and tag:Rest
for byte compiled syntax to update the compile function to pass the following tests:
Use the given tags tag:Cons, tag:consSecondK, and tag:doConsK to add appropriate cases for the new tags to interp and continue so that cons syntax is properly intepreted.
A simple test that does not need first or rest is as follows
(let ([result (run `{cons 1 2})])
(begin
(test (ref result 0) tag:ConsV)
(test (read-int (ref result 1)) 1)
(test (read-int (ref result 2)) 2)))
Use the given tags to extend interp and continue to handle first and rest.
Your updated code should pass the following tests.
Update move and update to handle the new tags you used above. You will have to take into account both the size
and the shape (i.e. what is contained in each slot). One subtlty is that code references (i.e. indexes into code-memory) do not need to be relocated.
A low level sanity check for the updated GC is as follows