Commit 5e1ec053 authored by Christoph Reichenbach's avatar Christoph Reichenbach
Browse files

WIP Exercise 3 update

parent 44aa4345
......@@ -120,13 +120,18 @@ If you wish, you an omit `NA`, `NO`, and `NI` output in cases where the variable
If you analyze the following file:
```
type Pair(fst : nonnull int, snd : int); // line 1
type Pair(fst : nonnull int, snd : int);
fun null_producer(n : int) = if (n == 0) { return null; } else { return n; }
fun null_producer(n : int) = {
if (n == 0) {
return null;
}
return n;
}
fun main(n : int) = {
var p : Pair := new Pair(5, 1);
p.snd := null; // this should be fine
fun main(n : int) : nonnull int = { // line 10
var p : Pair := new Pair(0, 1);
p.snd := null;
p.fst := null_producer(n);
return p.fst;
}
......@@ -135,13 +140,15 @@ fun main(n : int) = {
Your analysis should print the following:
```
N 6 29 -> obj 6 29
N 8 4 -> null 3 50
N 14 4 -> null 12 13
N 14 4 -> obj 11 29
N 14 4 -> obj 11 32
N 14 4 -> null 5 14
```
Where:
- `N` means that we are talking about an assignment to a nonnull variable (here, a field).
- `6 29` refers to the source location that Teal associates with the initial field assignment
- `14 4` refers to the source location that Teal associates with the initial field assignment
- `obj 6 29` refers to the literal number `5`
- `8 4` is the source location of the second assignment
- `null 3 50` is the source location in which `null` occurs in `null_producer` (from which it can make its way into `p.fst`).
......@@ -154,8 +161,10 @@ but we don't require that.)
Likewise, for the input:
```
fun main() = { // line 1
var a := null;
type XY(x : int, y : int);
fun main() = { // line 3
var a : XY := null;
a.x := 1;
}
```
......@@ -163,7 +172,7 @@ fun main() = { // line 1
Your analysis should print:
```
NO 3 4 -> null 2 13
NO 5 4 -> null 4 18
```
## Hints and Starting Points
......
Supports Markdown
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