-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtuple.naml
65 lines (56 loc) · 1.41 KB
/
tuple.naml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
(interface "Tuple"
(func "index" (param-list
(param "p_result" "*")
(param "index" "int")
))
(func "slice" (param-list
(param "p_result" "array *")
(param "lower_bound" "int")
(param "upper_bound" "int")
))
(func "empty" (param-list
(param "p_result" "bool *")
))
(func "size" (param-list
(param "p_result" "int *")
))
)
(type "tuple" ( "Tuple" )
(struct
(field "a" "array")
(field "l" "int")
)
(func "index" (param-list
(param "p_result" "*")
(param "index" "int")
)
(store "p_result"
(index
(get "a")
(param "index")
)
)
)
(func "slice" (param-list
(param "p_result" "array *")
(param "lower_bound" "int")
(param "upper_bound" "int")
)
(
(set "ret" ())
(set "i" (- (param upper_bound) (param lower_bound)))
(while ( !=, (get, "i"), 0 )
(
(add "ret")
(set "i" (- (get "i") 1))
)
)
)
)
(func "empty" (param-list (param "p_result" "bool *") )
( (store (param p_result) (== (field "l") 0 ) ) )
)
(func "size" (param-list (param "p_result" "int *") )
( (store (param p_result) (field "l") ) )
)
)