mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Add some more built-in functions
This commit is contained in:
1 parent
d14b56ea39
commit
333b11dc65
2 files changed
+14
-36
No files matched your search
+14
-2
@@ -76,8 +76,20 @@ var Types = []string{
|
|||||||
var Funcs = []string{
|
var Funcs = []string{
|
||||||
// TODO: some methods like "mark" should probably have a trailing "!".
|
// TODO: some methods like "mark" should probably have a trailing "!".
|
||||||
//
|
//
|
||||||
// TODO: status methods (is_error, etc), [] u8 methods (length, etc), u32
|
// TODO: [] u8 methods (length, etc).
|
||||||
// methods (low_bits, etc).
|
|
||||||
|
"u8.high_bits(n u32)(ret u8)",
|
||||||
|
"u8.low_bits(n u32)(ret u8)",
|
||||||
|
"u16.high_bits(n u32)(ret u16)",
|
||||||
|
"u16.low_bits(n u32)(ret u16)",
|
||||||
|
"u32.high_bits(n u32)(ret u32)",
|
||||||
|
"u32.low_bits(n u32)(ret u32)",
|
||||||
|
"u64.high_bits(n u32)(ret u64)",
|
||||||
|
"u64.low_bits(n u32)(ret u64)",
|
||||||
|
|
||||||
|
"status.is_error()(ret bool)",
|
||||||
|
"status.is_ok()(ret bool)",
|
||||||
|
"status.is_suspension()(ret bool)",
|
||||||
|
|
||||||
"reader1.read_u8?()(ret u8)",
|
"reader1.read_u8?()(ret u8)",
|
||||||
"reader1.read_u16be?()(ret u16)",
|
"reader1.read_u16be?()(ret u16)",
|
||||||
|
|||||||
@@ -425,40 +425,6 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error {
|
|||||||
// n.LHS().Expr().LHS().Expr(). Doing this properly will probably
|
// n.LHS().Expr().LHS().Expr(). Doing this properly will probably
|
||||||
// require a TypeExpr being able to express function and method types.
|
// require a TypeExpr being able to express function and method types.
|
||||||
|
|
||||||
// TODO: delete this hack that only matches "foo.bar_bits(etc)".
|
|
||||||
if isThatMethod(q.tm, n, t.KeyLowBits, 1) || isThatMethod(q.tm, n, t.KeyHighBits, 1) {
|
|
||||||
foo := n.LHS().Expr().LHS().Expr()
|
|
||||||
if err := q.tcheckExpr(foo, depth); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
n.LHS().SetTypeChecked()
|
|
||||||
n.LHS().Expr().SetMType(typeExprPlaceholder) // HACK.
|
|
||||||
for _, o := range n.Args() {
|
|
||||||
if err := q.tcheckArg(o.Arg(), nil, depth); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
n.SetMType(foo.MType().Unrefined())
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
// TODO: delete this hack that only matches "foo.is_suspension(etc)".
|
|
||||||
if isThatMethod(q.tm, n, t.KeyIsError, 0) ||
|
|
||||||
isThatMethod(q.tm, n, t.KeyIsOK, 0) ||
|
|
||||||
isThatMethod(q.tm, n, t.KeyIsSuspension, 0) {
|
|
||||||
foo := n.LHS().Expr().LHS().Expr()
|
|
||||||
if err := q.tcheckExpr(foo, depth); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
n.LHS().SetTypeChecked()
|
|
||||||
n.LHS().Expr().SetMType(typeExprPlaceholder) // HACK.
|
|
||||||
for _, o := range n.Args() {
|
|
||||||
if err := q.tcheckArg(o.Arg(), nil, depth); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
n.SetMType(typeExprBool)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
// TODO: delete this hack that only matches "foo.suffix(etc)".
|
// TODO: delete this hack that only matches "foo.suffix(etc)".
|
||||||
if isThatMethod(q.tm, n, t.KeySuffix, 1) {
|
if isThatMethod(q.tm, n, t.KeySuffix, 1) {
|
||||||
foo := n.LHS().Expr().LHS().Expr()
|
foo := n.LHS().Expr().LHS().Expr()
|
||||||
|
|||||||
Reference in new issue
Block a user