當前位置: 首頁>>代碼示例>>Golang>>正文


Golang lex8.Logger類代碼示例

本文整理匯總了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)
}
開發者ID:NickDaison,項目名稱:e8vm,代碼行數:34,代碼來源:sort.go

示例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
}
開發者ID:NickDaison,項目名稱:e8vm,代碼行數:8,代碼來源:arg.go

示例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
}
開發者ID:NickDaison,項目名稱:e8vm,代碼行數:9,代碼來源:check_type.go

示例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
}
開發者ID:NickDaison,項目名稱:e8vm,代碼行數:11,代碼來源:inst.go

示例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
}
開發者ID:NickDaison,項目名稱:e8vm,代碼行數:12,代碼來源:reg.go

示例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)
}
開發者ID:272489711,項目名稱:e8vm,代碼行數:15,代碼來源:inst_imm.go

示例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
}
開發者ID:272489711,項目名稱:e8vm,代碼行數:15,代碼來源:inst_imm.go

示例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)
}
開發者ID:272489711,項目名稱:e8vm,代碼行數:14,代碼來源:inst_reg.go

示例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
}
開發者ID:NickDaison,項目名稱:e8vm,代碼行數:16,代碼來源:label.go

示例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)
}
開發者ID:NickDaison,項目名稱:e8vm,代碼行數:45,代碼來源:data_nums.go

示例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}
}
開發者ID:272489711,項目名稱:e8vm,代碼行數:18,代碼來源:func_stmt.go

示例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
}
開發者ID:NickDaison,項目名稱:e8vm,代碼行數:18,代碼來源:data_hex.go

示例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
}
開發者ID:NickDaison,項目名稱:e8vm,代碼行數:19,代碼來源:import_decl.go

示例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
}
開發者ID:NickDaison,項目名稱:e8vm,代碼行數:19,代碼來源:sym_chk.go

示例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
}
開發者ID:272489711,項目名稱:e8vm,代碼行數:20,代碼來源:import_stmt.go


注:本文中的e8vm/io/e8vm/lex8.Logger類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。