本文整理汇总了Golang中lonnie/io/e8vm/lex8.Logger.Errorf方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Errorf方法的具体用法?Golang Logger.Errorf怎么用?Golang Logger.Errorf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lonnie/io/e8vm/lex8.Logger
的用法示例。
在下文中一共展示了Logger.Errorf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: 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
}
示例3: 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
}
示例4: 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
}
示例5: 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
}
示例6: 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)
}
示例7: 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)
}
示例8: 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
}
示例9: 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)
}
示例10: 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}
}
示例11: 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
}
示例12: 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
}
示例13: resolveImportDecl
func resolveImportDecl(log lex8.Logger, imp *ast.Import) *importDecl {
ret := new(importDecl)
ret.Import = imp
ret.stmts = make(map[string]*importStmt)
ret.paths = make(map[string]struct{})
for _, stmt := range imp.Stmts {
r := resolveImportStmt(log, stmt)
if other, found := ret.stmts[r.as]; found {
log.Errorf(r.As.Pos, "%s already imported", r.as)
log.Errorf(other.As.Pos, " previously imported here", other.as)
continue
}
ret.stmts[r.as] = r
ret.paths[r.path] = struct{}{}
}
return ret
}
示例14: 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
}
示例15: parseDataStr
func parseDataStr(p lex8.Logger, args []*lex8.Token) ([]byte, uint32) {
if !checkTypeAll(p, args, parse.String) {
return nil, 0
}
buf := new(bytes.Buffer)
for _, arg := range args {
if arg.Lit[0] != '"' {
p.Errorf(arg.Pos, "expect string for string data")
return nil, 0
}
s, e := strconv.Unquote(arg.Lit)
if e != nil {
p.Errorf(arg.Pos, "invalid string %s", arg.Lit)
return nil, 0
}
buf.Write([]byte(s))
}
return buf.Bytes(), 0
}