Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Christoph Reichenbach
EDAP15-exercise-3
Commits
44aa4345
Commit
44aa4345
authored
Dec 13, 2020
by
Christoph Reichenbach
Browse files
Fixed examples wrt new location code and added one more
parent
331f4bd0
Changes
6
Hide whitespace changes
Inline
Side-by-side
examples/dereference.expected
0 → 100644
View file @
44aa4345
N 4 6 -> obj 14 4
NI 5 9 -> null 9 25
NI 5 9 -> obj 9 21
N 10 2 -> null 12 7
N 10 2 -> obj 9 15
NO 16 9 -> null 12 7
NO 16 9 -> obj 9 15
examples/dereference.teal
0 → 100644
View file @
44aa4345
type T(x : string, y : int);
fun f(a : nonnull array[int], y : int) : int = {
return a[y];
}
fun main() = {
var b : T := new T("", null);
var c : nonnull T := b;
b := null;
f([1, 2], c.y);
return b.x;
}
examples/pair.expected
View file @
44aa4345
N 6 29 -> obj 6 29
N 8 4 -> null 3 50
N 14 4 -> null 12 13
N 14 4 -> null 5 14
N 14 4 -> obj 11 29
N 14 4 -> obj 11 32
examples/pair.teal
View file @
44aa4345
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) = {
fun main(n : int)
: nonnull int
= {
var p : Pair := new Pair(0, 1);
p.snd := null;
// this should be fine
p.snd := null;
p.fst := null_producer(n);
return p.fst;
}
\ No newline at end of file
}
examples/simple-struct.expected
View file @
44aa4345
N 4 25 -> obj 4 25
N 4 28 -> obj 4 28
N 5 15 -> obj 5 15
N 5 18 -> obj 5 18
N 8 6 -> obj 4 17
N 8 6 -> obj 5 7
N 8 6 -> null 4 31
\ No newline at end of file
N 8 2 -> null 4 31
N 8 2 -> obj 4 17
N 8 2 -> obj 4 25
N 8 2 -> obj 4 28
N 8 2 -> obj 5 15
N 8 2 -> obj 5 18
N 8 2 -> obj 5 7
examples/simple-struct.teal
View file @
44aa4345
type ABC(a :
nonnull int, b : nonnull
int, c : ABC);
type ABC(a :
int, b :
int, c : ABC);
fun main() = {
var x : ABC := new ABC(1, 2, null);
x := new ABC(3, 4, x);
var sum : int := 0;
var it : nonnull ABC := x;
var it : nonnull ABC := x;
while it != null {
print(it.a);
sum := sum + it.b;
it := it.c;
}
return sum;
}
\ No newline at end of file
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment