@@ -4,6 +4,8 @@ Require Export New.code.github_com.goose_lang.primitive.disk.
4
4
Require Export New.code.github_com.tchajed.marshal.
5
5
Require Export New.code.sync.
6
6
7
+ Definition append_log : go_string := "github.com/goose-lang/goose/testdata/examples/append_log".
8
+
7
9
From New Require Import disk_prelude.
8
10
Module append_log.
9
11
Section code.
@@ -21,23 +23,21 @@ Definition Log__mkHdr : val :=
21
23
exception_do (let : "log" := (ref_ty ptrT "log") in
22
24
let : "enc" := (ref_ty marshal.Enc (zero_val marshal.Enc)) in
23
25
let : "$r0" := (let: "$a0" := disk.BlockSize in
24
- (func_call #marshal.pkg_name' #"NewEnc"%go) "$a0") in
26
+ (func_call #marshal #"NewEnc"%go) "$a0") in
25
27
do: ("enc" <-[marshal.Enc] "$r0");;;
26
28
do: (let: "$a0" := (![uint64T] (struct.field_ref Log "sz" (![ptrT] "log"))) in
27
- (method_call #marshal.pkg_name' #"Enc" #"PutInt" (![marshal.Enc] "enc")) "$a0");;;
29
+ (method_call #marshal #"Enc" #"PutInt" (![marshal.Enc] "enc")) "$a0");;;
28
30
do: (let: "$a0" := (![uint64T] (struct.field_ref Log "diskSz" (![ptrT] "log"))) in
29
- (method_call #marshal.pkg_name' #"Enc" #"PutInt" (![marshal.Enc] "enc")) "$a0");;;
30
- return : ((method_call #marshal.pkg_name' #"Enc" #"Finish" (![marshal.Enc] "enc")) #())).
31
-
32
- Definition pkg_name' : go_string := "github.com/goose-lang/goose/testdata/examples/append_log".
31
+ (method_call #marshal #"Enc" #"PutInt" (![marshal.Enc] "enc")) "$a0");;;
32
+ return : ((method_call #marshal #"Enc" #"Finish" (![marshal.Enc] "enc")) #())).
33
33
34
34
(* go: append_log.go:29:17 *)
35
35
Definition Log__writeHdr : val :=
36
36
rec: "Log__writeHdr" "log" <> :=
37
37
exception_do (let : "log" := (ref_ty ptrT "log") in
38
38
do: (let : "$a0" := #(W64 0) in
39
- let : "$a1" := ((method_call #pkg_name' #"Log'ptr" #"mkHdr" (![ptrT] "log")) #()) in
40
- (func_call #disk.pkg_name' #"Write"%go) "$a0" "$a1")).
39
+ let : "$a1" := ((method_call #append_log #"Log'ptr" #"mkHdr" (![ptrT] "log")) #()) in
40
+ (func_call #disk #"Write"%go) "$a0" "$a1")).
41
41
42
42
(* go: append_log.go:33:6 *)
43
43
Definition Init : val :=
@@ -64,25 +64,25 @@ Definition Init : val :=
64
64
"diskSz" ::= "$diskSz"
65
65
}])) in
66
66
do: ("log" <-[ptrT] "$r0");;;
67
- do: ((method_call #pkg_name' #"Log'ptr" #"writeHdr" (![ptrT] "log")) #());;;
67
+ do: ((method_call #append_log #"Log'ptr" #"writeHdr" (![ptrT] "log")) #());;;
68
68
return : (![ptrT] "log", #true)).
69
69
70
70
(* go: append_log.go:42:6 *)
71
71
Definition Open : val :=
72
72
rec: "Open " <> :=
73
73
exception_do (let : "hdr" := (ref_ty sliceT (zero_val sliceT)) in
74
74
let : "$r0" := (let : "$a0" := #(W64 0) in
75
- (func_call #disk.pkg_name' #"Read"%go) "$a0") in
75
+ (func_call #disk #"Read"%go) "$a0") in
76
76
do: ("hdr" <-[sliceT] "$r0");;;
77
77
let : "dec" := (ref_ty marshal.Dec (zero_val marshal.Dec)) in
78
78
let : "$r0" := (let : "$a0" := (![sliceT] "hdr") in
79
- (func_call #marshal.pkg_name' #"NewDec"%go) "$a0") in
79
+ (func_call #marshal #"NewDec"%go) "$a0") in
80
80
do: ("dec" <-[marshal.Dec] "$r0");;;
81
81
let : "sz" := (ref_ty uint64T (zero_val uint64T)) in
82
- let : "$r0" := ((method_call #marshal.pkg_name' #"Dec" #"GetInt" (![marshal.Dec] "dec")) #()) in
82
+ let : "$r0" := ((method_call #marshal #"Dec" #"GetInt" (![marshal.Dec] "dec")) #()) in
83
83
do: ("sz" <-[uint64T] "$r0");;;
84
84
let : "diskSz" := (ref_ty uint64T (zero_val uint64T)) in
85
- let : "$r0" := ((method_call #marshal.pkg_name' #"Dec" #"GetInt" (![marshal.Dec] "dec")) #()) in
85
+ let : "$r0" := ((method_call #marshal #"Dec" #"GetInt" (![marshal.Dec] "dec")) #()) in
86
86
do: ("diskSz" <-[uint64T] "$r0");;;
87
87
return : (ref_ty Log (let: "$m" := (ref_ty sync.Mutex (zero_val sync.Mutex)) in
88
88
let : "$sz" := (![uint64T] "sz") in
@@ -104,7 +104,7 @@ Definition Log__get : val :=
104
104
(if : (![uint64T] "i") < (![uint64T] "sz")
105
105
then
106
106
return : (let : "$a0" := (#(W64 1) + (![uint64T] "i")) in
107
- (func_call #disk.pkg_name' #"Read"%go) "$a0", #true)
107
+ (func_call #disk #"Read"%go) "$a0", #true)
108
108
else do: #());;;
109
109
return : (#slice.nil, #false)).
110
110
@@ -113,16 +113,16 @@ Definition Log__Get : val :=
113
113
rec: "Log__Get" "log" "i" :=
114
114
exception_do (let : "log" := (ref_ty ptrT "log") in
115
115
let : "i" := (ref_ty uint64T "i") in
116
- do: ((method_call #sync.pkg_name' #"Mutex'ptr" #"Lock" (![ptrT] (struct .field_ref Log "m" (![ptrT] "log")))) #());;;
116
+ do: ((method_call #sync #"Mutex'ptr" #"Lock" (![ptrT] (struct.field_ref Log "m" (![ptrT] "log")))) #());;;
117
117
let : "b" := (ref_ty boolT (zero_val boolT)) in
118
118
let : "v" := (ref_ty sliceT (zero_val sliceT)) in
119
119
let : ("$ret0", "$ret1") := (let : "$a0" := (![uint64T] "i") in
120
- (method_call #pkg_name' #"Log'ptr" #"get" (![ptrT] "log")) "$a0") in
120
+ (method_call #append_log #"Log'ptr" #"get" (![ptrT] "log")) "$a0") in
121
121
let : "$r0" := "$ret0" in
122
122
let : "$r1" := "$ret1" in
123
123
do: ("v" <-[sliceT] "$r0");;;
124
124
do: ("b" <-[boolT] "$r1");;;
125
- do: ((method_call #sync.pkg_name' #"Mutex'ptr" #"Unlock" (![ptrT] (struct .field_ref Log "m" (![ptrT] "log")))) #());;;
125
+ do: ((method_call #sync #"Mutex'ptr" #"Unlock" (![ptrT] (struct.field_ref Log "m" (![ptrT] "log")))) #());;;
126
126
return : (![sliceT] "v", ![boolT] "b")).
127
127
128
128
(* go: append_log.go:65:6 *)
@@ -138,7 +138,7 @@ Definition writeAll : val :=
138
138
do: ("i" <-[intT] "$key");;;
139
139
do: (let : "$a0" := ((![uint64T] "off") + (![intT] "i")) in
140
140
let : "$a1" := (![sliceT] "bk") in
141
- (func_call #disk.pkg_name' #"Write"%go) "$a0" "$a1")))).
141
+ (func_call #disk #"Write"%go) "$a0" "$a1")))).
142
142
143
143
(* go: append_log.go:71:17 *)
144
144
Definition Log__append : val :=
@@ -154,23 +154,23 @@ Definition Log__append : val :=
154
154
else do: #());;;
155
155
do: (let : "$a0" := (![sliceT] "bks") in
156
156
let : "$a1" := (#(W64 1) + (![uint64T] "sz")) in
157
- (func_call #pkg_name' #"writeAll"%go) "$a0" "$a1");;;
157
+ (func_call #append_log.append_log #"writeAll"%go) "$a0" "$a1");;;
158
158
do: ((struct.field_ref Log "sz" (![ptrT] "log")) <-[uint64T] ((![uint64T] (struct .field_ref Log "sz" (![ptrT] "log"))) + (let : "$a0" := (![sliceT] "bks") in
159
159
slice.len "$a0")));;;
160
- do: ((method_call #pkg_name' #"Log'ptr" #"writeHdr" (![ptrT] "log")) #());;;
160
+ do: ((method_call #append_log #"Log'ptr" #"writeHdr" (![ptrT] "log")) #());;;
161
161
return : (#true)).
162
162
163
163
(* go: append_log.go:82:17 *)
164
164
Definition Log__Append : val :=
165
165
rec: "Log__Append" "log" "bks" :=
166
166
exception_do (let : "log" := (ref_ty ptrT "log") in
167
167
let : "bks" := (ref_ty sliceT "bks") in
168
- do: ((method_call #sync.pkg_name' #"Mutex'ptr" #"Lock" (![ptrT] (struct .field_ref Log "m" (![ptrT] "log")))) #());;;
168
+ do: ((method_call #sync #"Mutex'ptr" #"Lock" (![ptrT] (struct.field_ref Log "m" (![ptrT] "log")))) #());;;
169
169
let : "b" := (ref_ty boolT (zero_val boolT)) in
170
170
let : "$r0" := (let : "$a0" := (![sliceT] "bks") in
171
- (method_call #pkg_name' #"Log'ptr" #"append" (![ptrT] "log")) "$a0") in
171
+ (method_call #append_log #"Log'ptr" #"append" (![ptrT] "log")) "$a0") in
172
172
do: ("b" <-[boolT] "$r0");;;
173
- do: ((method_call #sync.pkg_name' #"Mutex'ptr" #"Unlock" (![ptrT] (struct .field_ref Log "m" (![ptrT] "log")))) #());;;
173
+ do: ((method_call #sync #"Mutex'ptr" #"Unlock" (![ptrT] (struct.field_ref Log "m" (![ptrT] "log")))) #());;;
174
174
return : (![boolT] "b")).
175
175
176
176
(* go: append_log.go:89:17 *)
@@ -179,33 +179,33 @@ Definition Log__reset : val :=
179
179
exception_do (let : "log" := (ref_ty ptrT "log") in
180
180
let : "$r0" := #(W64 0) in
181
181
do: ((struct.field_ref Log "sz" (![ptrT] "log")) <-[uint64T] "$r0");;;
182
- do: ((method_call #pkg_name' #"Log'ptr" #"writeHdr" (![ptrT] "log")) #())).
182
+ do: ((method_call #append_log #"Log'ptr" #"writeHdr" (![ptrT] "log")) #())).
183
183
184
184
(* go: append_log.go:94:17 *)
185
185
Definition Log__Reset : val :=
186
186
rec: "Log__Reset" "log" <> :=
187
187
exception_do (let : "log" := (ref_ty ptrT "log") in
188
- do: ((method_call #sync.pkg_name' #"Mutex'ptr" #"Lock" (![ptrT] (struct .field_ref Log "m" (![ptrT] "log")))) #());;;
189
- do: ((method_call #pkg_name' #"Log'ptr" #"reset" (![ptrT] "log")) #());;;
190
- do: ((method_call #sync.pkg_name' #"Mutex'ptr" #"Unlock" (![ptrT] (struct .field_ref Log "m" (![ptrT] "log")))) #())).
188
+ do: ((method_call #sync #"Mutex'ptr" #"Lock" (![ptrT] (struct.field_ref Log "m" (![ptrT] "log")))) #());;;
189
+ do: ((method_call #append_log #"Log'ptr" #"reset" (![ptrT] "log")) #());;;
190
+ do: ((method_call #sync #"Mutex'ptr" #"Unlock" (![ptrT] (struct.field_ref Log "m" (![ptrT] "log")))) #())).
191
191
192
192
Definition vars' : list (go_string * go_type) := [].
193
193
194
194
Definition functions' : list (go_string * val) := [("Init"%go, Init); ("Open "%go, Open ); ("writeAll"%go, writeAll)].
195
195
196
196
Definition msets' : list (go_string * (list (go_string * val))) := [("Log"%go, []); ("Log'ptr"%go, [("Append"%go, Log__Append); ("Get"%go, Log__Get); ("Reset "%go, Log__Reset); ("append"%go, Log__append); ("get"%go, Log__get); ("mkHdr"%go, Log__mkHdr); ("reset"%go, Log__reset); ("writeHdr"%go, Log__writeHdr)])].
197
197
198
- #[global] Instance info' : PkgInfo pkg_name' :=
198
+ #[global] Instance info' : PkgInfo append_log.append_log :=
199
199
{|
200
200
pkg_vars := vars';
201
201
pkg_functions := functions';
202
202
pkg_msets := msets';
203
- pkg_imported_pkgs := [sync.pkg_name' ; marshal.pkg_name' ; disk.pkg_name' ];
203
+ pkg_imported_pkgs := [sync; marshal; disk];
204
204
|}.
205
205
206
206
Definition initialize' : val :=
207
207
rec: "initialize'" <> :=
208
- globals.package_init pkg_name' (λ: <>,
208
+ globals.package_init append_log.append_log (λ: <>,
209
209
exception_do (do: disk.initialize';;;
210
210
do: marshal.initialize';;;
211
211
do: sync.initialize')
0 commit comments