Generate C code for "var x T = foo?()".

This commit is contained in:
Nigel Tao committed 2017-06-16 14:54:51 +10:00
1 parent f6501ec2d9
commit e6f5fd7f53
3 files changed
+37 -1

No files matched your search

+9
View File
@@ -1,6 +1,8 @@
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
// The GIF spec is https://www.w3.org/Graphics/GIF/spec-gif89a.txt
pub error "bad GIF header"
pub struct decoder?(
@@ -13,4 +15,11 @@ pub func decoder.decode?(dst ptr buf1, src ptr buf1)() {
(in.src.read_u8?() != 0x46) or (in.src.read_u8?() != 0x38) {
return error "bad GIF header"
}
var c u8 = in.src.read_u8?()
if (c != 0x37) and (c != 0x39) {
return error "bad GIF header"
}
if in.src.read_u8?() != 0x61 {
return error "bad GIF header"
}
}