本文整理汇总了Golang中e8vm/io/e8vm/lex8.Logger类的典型用法代码示例。如果您正苦于以下问题:Golang Logger类的具体用法?Golang Logger怎么用?Golang Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: push
func (s *Sorter) push(log lex8.Logger, node *node) {
node.queuing = true
name := node.name
for _, dep := range node.deps {
if dep == name {
log.Errorf(node.tok.Pos, "%s %s depends on itself",
s.typ, name,
)
s.err = true
continue
}
depNode := s.m[dep]
if depNode == nil || depNode.queued {
continue
}
if depNode.queuing {
log.Errorf(node.tok.Pos,
"%s %s circular depends on %s %s",
s.typ, node.tok.Lit, s.typ, dep,
)
s.err = true
continue
}
s.push(log, depNode)
}
node.queuing = false
node.queued = true
s.order = append(s.order, node.name)
}
示例2: argCount
func argCount(log lex8.Logger, ops []*lex8.Token, n int) bool {
if len(ops) == n+1 {
return true
}
log.Errorf(ops[0].Pos, "%q needs %d arguments", ops[0].Lit, n)
return false
}
示例3: checkTypeAll
func checkTypeAll(p lex8.Logger, toks []*lex8.Token, typ int) bool {
for _, t := range toks {
if t.Type != typ {
p.Errorf(t.Pos, "expect operand, got %s", parse.TypeStr(t.Type))
return false
}
}
return true
}
示例4: resolve
func (rs instResolvers) resolve(log lex8.Logger, ops []*lex8.Token) *inst {
for _, r := range rs {
if i, hit := r(log, ops); hit {
return i
}
}
op0 := ops[0]
log.Errorf(op0.Pos, "invalid asm instruction %q", op0.Lit)
return nil
}
示例5: resolveReg
func resolveReg(p lex8.Logger, op *lex8.Token) uint32 {
if op.Type != parse.Operand {
panic("not an operand")
}
ret, found := regNameMap[op.Lit]
if !found {
p.Errorf(op.Pos, "invalid register name %q", op.Lit)
return 0
}
return ret
}
示例6: parseImu
// parseImu parses an unsigned 16-bit immediate
func parseImu(p lex8.Logger, op *lex8.Token) uint32 {
ret, e := strconv.ParseUint(op.Lit, 0, 32)
if e != nil {
p.Errorf(op.Pos, "invalid unsigned immediate %q: %s", op.Lit, e)
return 0
}
if (ret & 0xffff) != ret {
p.Errorf(op.Pos, "immediate too large: %s", op.Lit)
return 0
}
return uint32(ret)
}
示例7: parseImm
// parseImm parses an unsigned 16-bit immediate
func parseImm(p lex8.Logger, op *lex8.Token) uint32 {
ret, e := strconv.ParseInt(op.Lit, 0, 32)
if e != nil {
p.Errorf(op.Pos, "invalid signed immediate %q: %s", op.Lit, e)
return 0
}
if ret > 0xffff || ret < -0x8000 {
p.Errorf(op.Pos, "immediate out of 16-bit range: %s", op.Lit)
return 0
}
return uint32(ret) & 0xffff
}
示例8: parseShift
func parseShift(p lex8.Logger, op *lex8.Token) uint32 {
ret, e := strconv.ParseUint(op.Lit, 0, 32)
if e != nil {
p.Errorf(op.Pos, "invalid shift %q: %s", op.Lit, e)
return 0
}
if (ret & 0x1f) != ret {
p.Errorf(op.Pos, "shift too large: %s", op.Lit)
return 0
}
return uint32(ret)
}
示例9: checkLabel
func checkLabel(log lex8.Logger, t *lex8.Token) bool {
if t.Type != parse.Operand {
panic("not an operand")
}
lab := t.Lit
if !isLabelStart(lab) {
return false
}
if !isLabel(lab) {
log.Errorf(t.Pos, "invalid label: %q", lab)
}
return true
}
示例10: parseDataNums
func parseDataNums(p lex8.Logger, args []*lex8.Token, mode int) (
[]byte, uint32,
) {
if !checkTypeAll(p, args, parse.Operand) {
return nil, 0
}
var ui uint32
nbit := 8
if mode&modeWord != 0 {
nbit = 32
}
var e error
buf := new(bytes.Buffer)
for _, arg := range args {
if mode&modeFloat != 0 {
var f float64
f, e = strconv.ParseFloat(arg.Lit, 32)
ui = math.Float32bits(float32(f))
} else if mode&modeSigned != 0 {
var i int64
i, e = strconv.ParseInt(arg.Lit, 0, nbit)
ui = uint32(i)
} else {
var ui64 uint64
ui64, e = strconv.ParseUint(arg.Lit, 0, nbit)
ui = uint32(ui64)
}
if e != nil {
p.Errorf(arg.Pos, "%s", e)
return nil, 0
}
if nbit == 8 {
buf.WriteByte(byte(ui))
} else if nbit == 32 {
var bs [4]byte
arch8.Endian.PutUint32(bs[:], ui)
buf.Write(bs[:])
}
}
return buf.Bytes(), nbitAlign(nbit)
}
示例11: resolveFuncStmt
func resolveFuncStmt(log lex8.Logger, s *ast.FuncStmt) *funcStmt {
ops := s.Ops
op0 := ops[0]
lead := op0.Lit
if lead == "" {
panic("empty operand")
}
if checkLabel(log, op0) {
if len(ops) > 1 {
log.Errorf(op0.Pos, "label should take the entire line")
return nil
}
return &funcStmt{label: lead, FuncStmt: s}
}
return &funcStmt{inst: resolveInst(log, ops), FuncStmt: s}
}
示例12: parseDataHex
func parseDataHex(p lex8.Logger, args []*lex8.Token) ([]byte, uint32) {
if !checkTypeAll(p, args, parse.Operand) {
return nil, 0
}
buf := new(bytes.Buffer)
for _, arg := range args {
b, e := strconv.ParseUint(arg.Lit, 16, 8)
if e != nil {
p.Errorf(arg.Pos, "%s", e)
return nil, 0
}
buf.WriteByte(byte(b))
}
return buf.Bytes(), 0
}
示例13: resolveImportDecl
func resolveImportDecl(log lex8.Logger, imp *ast.Import) *importDecl {
ret := new(importDecl)
ret.Import = imp
ret.stmts = make(map[string]*importStmt)
for _, stmt := range imp.Stmts {
r := resolveImportStmt(log, stmt)
if other, found := ret.stmts[r.as]; found {
log.Errorf(r.pos(), "%s already imported", r.as)
log.Errorf(other.pos(), " previously imported here")
continue
}
ret.stmts[r.as] = r
}
return ret
}
示例14: parseSym
func parseSym(p lex8.Logger, t *lex8.Token) (pack, sym string) {
if t.Type != parse.Operand {
panic("symbol not an operand")
}
sym = t.Lit
dot := strings.Index(sym, ".")
if dot >= 0 {
pack, sym = sym[:dot], sym[dot+1:]
}
if dot >= 0 && !lex8.IsPkgName(pack) {
p.Errorf(t.Pos, "invalid package name: %q", pack)
} else if !parse.IsIdent(sym) {
p.Errorf(t.Pos, "invalid symbol: %q", t.Lit)
}
return pack, sym
}
示例15: resolveImportStmt
func resolveImportStmt(log lex8.Logger, imp *ast.ImportStmt) *importStmt {
ret := new(importStmt)
ret.ImportStmt = imp
s, e := strconv.Unquote(imp.Path.Lit)
if e != nil {
log.Errorf(imp.Path.Pos, "invalid string %s", imp.Path.Lit)
return nil
}
ret.path = s
if imp.As != nil {
ret.as = imp.As.Lit
} else {
ret.as = path.Base(ret.path)
}
return ret
}