本文整理汇总了Golang中github.com/kpmy/ypk/assert.For函数的典型用法代码示例。如果您正苦于以下问题:Golang For函数的具体用法?Golang For怎么用?Golang For使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了For函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: conv
func conv(v *value, target types.Type) (ret *value) {
switch {
case v.typ == types.ANY && target == types.UNIT:
a := v.toAny()
assert.For(a.x == nil, 20)
ret = &value{typ: types.UNIT, val: &Ref{}}
case v.typ == types.INTEGER && target == types.REAL:
i := v.toInt()
x := big.NewRat(0, 1)
ret = &value{typ: target, val: ThisRat(x.SetInt(i))}
case v.typ == types.BOOLEAN && target == types.TRILEAN:
b := v.toBool()
x := tri.This(b)
ret = &value{typ: target, val: x}
case v.typ == types.ANY && target == types.ATOM:
ret = &value{typ: target, val: Atom("")}
case target == types.ANY && v.typ != types.ANY:
x := ThisAny(v)
ret = &value{typ: target, val: x}
case target == types.ANY && v.typ == types.ANY:
x := v.toAny()
ret = &value{typ: target, val: x}
case v.typ == target:
ret = v
}
assert.For(ret != nil, 60, v.typ, target, v.val)
return
}
示例2: dyPTR
/*
func dyPTR() {
putDyadic(types.PTR, types.PTR, ops.Eq, b_(b_ptr_(b_ptr_ptr_(func(lp *Ptr, rp *Ptr) bool {
return lp.adr == rp.adr
}))))
putDyadic(types.PTR, types.PTR, ops.Neq, b_(b_ptr_(b_ptr_ptr_(func(lp *Ptr, rp *Ptr) bool {
return lp.adr != rp.adr
}))))
}
*/
func dyPROC() {
putDyadic(types.UNIT, types.UNIT, ops.Eq, b_(b_proc_(b_proc_proc_(func(lp *Ref, rp *Ref) bool {
return lp.u == rp.u
}))))
putDyadic(types.UNIT, types.UNIT, ops.Neq, b_(b_proc_(b_proc_proc_(func(lp *Ref, rp *Ref) bool {
return lp.u != rp.u
}))))
putDyadic(types.UNIT, types.ANY, ops.Eq, b_(b_proc_(b_proc_z_(func(la *Ref, ra *Any) bool {
assert.For(ra.x == nil, 40, "UNDEF comparision only")
return la.u == nil
}))))
putDyadic(types.ANY, types.UNIT, ops.Eq, b_(b_z_(b_z_proc_(func(la *Any, ra *Ref) bool {
assert.For(la.x == nil, 40, "UNDEF comparision only")
return ra.u == nil
}))))
putDyadic(types.UNIT, types.ANY, ops.Neq, b_(b_proc_(b_proc_z_(func(la *Ref, ra *Any) bool {
assert.For(ra.x == nil, 40, "UNDEF comparision only")
return la.u != nil
}))))
putDyadic(types.ANY, types.UNIT, ops.Neq, b_(b_z_(b_z_proc_(func(la *Any, ra *Ref) bool {
assert.For(la.x == nil, 40, "UNDEF comparision only")
return ra.u != nil
}))))
}
示例3: data
func (i *intern) data(t types.Type, cd xml.CharData) (ret interface{}) {
switch t {
case types.INTEGER, types.REAL:
ret = string(cd)
case types.BOOLEAN:
ret = string(cd) == "true"
case types.TRILEAN:
if s := string(cd); s == "null" {
ret = tri.NIL
} else if s == "true" {
ret = tri.TRUE
} else {
ret = tri.FALSE
}
case types.CHAR:
c, _ := strconv.ParseUint(string(cd), 16, 64)
ret = rune(c)
case types.STRING:
data, err := base64.StdEncoding.DecodeString(string(cd))
assert.For(err == nil, 30)
ret = strings.TrimPrefix(string(data), prefix)
case types.ANY:
assert.For(string(cd) == "null", 20)
ret = nil
default:
halt.As(100, t)
}
return
}
示例4: rulesDecl
func (p *pr) rulesDecl() {
assert.For(p.sym.Code == lss.Process, 20, "PROCESS block expected")
p.next()
for stop := false; !stop; {
p.pass(lss.Delimiter, lss.Separator)
expr := &exprBuilder{tgt: &p.target, marker: p}
p.expression(expr)
p.expect(lss.ArrowRight, "assign expected", lss.Delimiter, lss.Separator)
p.next()
p.pass(lss.Delimiter, lss.Separator)
id := p.ident()
var fid string
p.next()
if p.is(lss.Period) {
u := p.target.unit.Variables[id]
if u.Type.Basic {
p.mark("only foreign types are selectable")
}
p.next()
p.expect(lss.Ident, "foreign variable expected")
fid = p.ident()
p.next()
} else {
fid = id
id = p.target.unit.Name
}
assert.For(fid != "", 40)
p.target.assign(id, fid, expr)
p.pass(lss.Separator, lss.Delimiter)
stop = p.is(lss.End)
}
}
示例5: Construct
func Construct(name otm.Qualident) (ret schema.Guide) {
assert.For(name.Template == "ng", 20, name)
fn := Constructors[name.Class]
assert.For(fn != nil, 40, name)
ret = fn()
assert.For(ret != nil, 60, name)
return
}
示例6: Object
func (l *futureLink) Object() otm.Object {
if l.o == nil {
assert.For(!fn.IsNil(l.up), 20)
l.o = otm.RootOf(l.up).FindById(l.to).(*object)
assert.For(l.o != nil, 60, "object not found ", l.to)
}
return l.o
}
示例7: dyINT2REAL
func dyINT2REAL() {
putDyadic(types.REAL, types.INTEGER, ops.Quot,
r_(r_ir_(r_ir_ir_(func(l *big.Rat, r *big.Rat) *big.Rat {
return l.Quo(l, r)
}))))
putDyadic(types.INTEGER, types.REAL, ops.Quot,
r_(r_ir_(r_ir_ir_(func(l *big.Rat, r *big.Rat) *big.Rat {
return l.Quo(l, r)
}))))
putDyadic(types.REAL, types.INTEGER, ops.Pow,
r_(r_ir_(r_ir_ir_(func(l *big.Rat, r *big.Rat) *big.Rat {
n := l.Num()
d := l.Denom()
assert.For(r.IsInt(), 40)
p := r.Num()
assert.For(p.Cmp(big.NewInt(0)) >= 0, 40, "positive only")
n = n.Exp(n, p, nil)
d = d.Exp(d, p, nil)
ret := big.NewRat(0, 1)
ret = ret.SetFrac(n, d)
return ret
}))))
putDyadic(types.INTEGER, types.REAL, ops.Pow,
r_(r_ir_(r_ir_ir_(func(l *big.Rat, r *big.Rat) *big.Rat {
assert.For(l.IsInt(), 40)
n := l.Num()
p := r.Num()
q := r.Denom()
assert.For(p.Cmp(big.NewInt(0)) >= 0, 40, "positive only")
assert.For(q.Cmp(big.NewInt(1)) == 0, 41, "извлечение корня не поддерживается")
n = n.Exp(n, p, q)
ret := big.NewRat(0, 1)
ret = ret.SetFrac(n, big.NewInt(1))
return ret
}))))
putDyadic(types.INTEGER, types.REAL, ops.Prod,
r_(r_ir_(r_ir_ir_(func(l *big.Rat, r *big.Rat) *big.Rat {
return l.Mul(l, r)
}))))
putDyadic(types.REAL, types.INTEGER, ops.Prod,
r_(r_ir_(r_ir_ir_(func(l *big.Rat, r *big.Rat) *big.Rat {
return l.Mul(l, r)
}))))
putDyadic(types.REAL, types.INTEGER, ops.Sum,
r_(r_ir_(r_ir_ir_(func(l *big.Rat, r *big.Rat) *big.Rat {
return l.Add(l, r)
}))))
putDyadic(types.REAL, types.INTEGER, ops.Diff,
r_(r_ir_(r_ir_ir_(func(l *big.Rat, r *big.Rat) *big.Rat {
return l.Sub(l, r)
}))))
putDyadic(types.INTEGER, types.INTEGER, ops.Quot,
r_(r_ir_(r_ir_ir_(func(l *big.Rat, r *big.Rat) *big.Rat {
return l.Quo(l, r)
}))))
}
示例8: TestSome
func TestSome(t *testing.T) {
assert.For(Do2(Do2(Int(4), SUM, Int(24)), EQ, Int(4+24)).ToBool(), 20)
assert.For(Do2(Do2(Int(4), DIFF, Int(24)), EQ, Int(4-24)).ToBool(), 20)
assert.For(Do2(Do2(Int(4), MULT, Int(24)), EQ, Int(4*24)).ToBool(), 20)
t.Log(Do2(Int(4), QUOT, Int(24)))
t.Log(Do(NEG, Int(45)))
t.Log(Flo(34.5))
t.Log(Cpx(complex(3, 5)))
t.Log(Do(CON, Cpx(complex(3.5, 14))))
}
示例9: Child
func (b *builder) Child(prod otm.Producer, mod ...otm.Modifier) otm.Builder {
assert.For(b.root != nil, 20)
n := prod(mod...).(*object)
if n.id != "" {
old := b.root.FindById(n.id)
assert.For(fn.IsNil(old), 40, "non unique id")
}
b.root.vl = append(b.root.vl, n)
n.up = b.root
return b
}
示例10: expect
//expect is the most powerful step forward runner, breaks the compilation if unexpected sym found
func (p *common) expect(sym lss.Symbol, msg string, skip ...lss.Symbol) {
assert.For(p.done, 20)
if !p.await(sym, skip...) {
p.mark(msg)
}
p.done = false
}
示例11: comment
func (s *sc) comment() {
assert.For(s.ch == '*', 20, "expected ", s.opts.CommentTriplet[1], "got ", Token(s.ch))
for {
for s.err == nil && s.ch != s.opts.CommentTriplet[1] {
if s.ch == s.opts.CommentTriplet[0] {
if s.next() == s.opts.CommentTriplet[1] {
s.comment()
}
} else {
s.next()
}
}
for s.err == nil && s.ch == s.opts.CommentTriplet[1] {
s.next()
}
if s.err != nil || s.ch == s.opts.CommentTriplet[2] {
break
}
}
if s.err == nil {
s.next()
} else {
s.mark("unclosed comment")
}
}
示例12: emit
func (t *target) emit(_s ir.Statement) {
assert.For(!fn.IsNil(_s), 20)
switch s := _s.(type) {
default:
t.tpl.Stmt = append(t.tpl.Stmt, s)
}
}
示例13: expect
//expect is the most powerful step forward runner, breaks the compilation if unexpected sym found
func (p *common) expect(sym ots.SymCode, msg string, skip ...ots.SymCode) {
assert.For(p.done, 20)
if !p.await(sym, skip...) {
p.mark(msg)
}
p.done = false
}
示例14: Join
func Join(in *model.Layer, out *model.Layer) {
j := 0
type im map[int]interface{}
cache := make([]im, len(out.Nodes))
for k, n := range in.Nodes {
for i := 0; i < len(n.Out); {
assert.For(len(n.Out) <= len(out.Nodes), 20, len(n.Out), len(out.Nodes))
l := model.Link{NodeId: k, LinkId: i}
skip := false
if cache[j] != nil {
if _, ok := cache[j][k]; ok {
skip = true
j++
if j == len(cache) {
j = 0
}
}
}
if !skip {
out.Nodes[j].In[l] = nil
if cache[j] == nil {
cache[j] = make(im)
}
cache[j][k] = l
//log.Println(l, "to", j)
i++
}
//log.Println(k, len(n.Out), i, j)
}
}
in.Next = out
}
示例15: Expect
//expect is the most powerful step forward runner, breaks the compilation if unexpected sym found
func (r *rn) Expect(sym SymCode, msg interface{}, skip ...SymCode) {
assert.For(r.done, 20, "previous symbol unhandled")
if !r.Await(sym, skip...) {
r.marker.Mark(msg)
}
r.done = false
}