diff --git a/lang/builtin/builtin.go b/lang/builtin/builtin.go index 297cfefe..0853e937 100644 --- a/lang/builtin/builtin.go +++ b/lang/builtin/builtin.go @@ -76,8 +76,20 @@ var Types = []string{ var Funcs = []string{ // TODO: some methods like "mark" should probably have a trailing "!". // - // TODO: status methods (is_error, etc), [] u8 methods (length, etc), u32 - // methods (low_bits, etc). + // TODO: [] u8 methods (length, 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_u16be?()(ret u16)", diff --git a/lang/check/type.go b/lang/check/type.go index 7450c597..54f41daa 100644 --- a/lang/check/type.go +++ b/lang/check/type.go @@ -425,40 +425,6 @@ func (q *checker) tcheckExprOther(n *a.Expr, depth uint32) error { // n.LHS().Expr().LHS().Expr(). Doing this properly will probably // 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)". if isThatMethod(q.tm, n, t.KeySuffix, 1) { foo := n.LHS().Expr().LHS().Expr()