本文整理汇总了Golang中github.com/ark-lang/ark/src/util/log.Error函数的典型用法代码示例。如果您正苦于以下问题:Golang Error函数的具体用法?Golang Error怎么用?Golang Error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Visit
func (v *RecursiveDefinitionCheck) Visit(s *SemanticAnalyzer, n parser.Node) {
var typ parser.Type
if typeDecl, ok := n.(*parser.TypeDecl); ok {
actualType := typeDecl.NamedType.ActualType()
switch actualType.(type) {
case *parser.EnumType:
typ = actualType.(*parser.EnumType)
case *parser.StructType:
typ = actualType.(*parser.StructType)
// TODO: Check tuple types once we add named types for everything
default:
return
}
}
if ok, path := isTypeRecursive(typ); ok {
s.Err(n, "Encountered recursive type definition")
log.Errorln("semantic", "Path taken:")
for _, typ := range path {
log.Error("semantic", typ.TypeName())
log.Error("semantic", " <- ")
}
log.Error("semantic", "%s\n\n", typ.TypeName())
}
}
开发者ID:dansawkins,项目名称:ark,代码行数:31,代码来源:recursive.go
示例2: TypeOfNameNode
func (v *NameMap) TypeOfNameNode(name *NameNode) NodeType {
mod := v
typ := NODE_MODULE
for _, modName := range name.Modules {
if typ == NODE_MODULE {
typ = mod.typeOf(modName)
if typ == NODE_MODULE {
mod = mod.module(modName)
if mod == nil {
return NODE_UNKOWN
}
}
} else {
startPos := modName.Where.Start()
log.Errorln("constructor", "[%s:%d:%d] Invalid use of `::`. `%s` is not a module",
startPos.Filename, startPos.Line, startPos.Char, modName.Value)
log.Error("constructor", v.tree.Source.MarkSpan(modName.Where))
}
}
if typ == NODE_ENUM {
return NODE_ENUM_MEMBER
} else if typ == NODE_STRUCT {
return NODE_STRUCT_STATIC
}
typ = mod.typeOf(name.Name)
if typ == NODE_UNKOWN {
startPos := name.Name.Where.Start()
log.Errorln("constructor", "[%s:%d:%d] Undeclared name `%s`",
startPos.Filename, startPos.Line, startPos.Char, name.Name.Value)
log.Error("constructor", v.tree.Source.MarkSpan(name.Name.Where))
}
return typ
}
开发者ID:dansawkins,项目名称:ark,代码行数:35,代码来源:name_pass.go
示例3: err
func (v *SemanticAnalyzer) err(thing Locatable, err string, stuff ...interface{}) {
pos := thing.Pos()
log.Error("semantic", util.TEXT_RED+util.TEXT_BOLD+"Semantic error:"+util.TEXT_RESET+" [%s:%d:%d] %s\n",
pos.Filename, pos.Line, pos.Char, fmt.Sprintf(err, stuff...))
log.Error("semantic", v.Module.File.MarkPos(pos))
v.shouldExit = true
}
开发者ID:gitter-badger,项目名称:ark,代码行数:10,代码来源:semantic.go
示例4: err
func (v *Resolver) err(thing Locatable, err string, stuff ...interface{}) {
pos := thing.Pos()
log.Error("resolve", util.TEXT_RED+util.TEXT_BOLD+"Resolve error:"+util.TEXT_RESET+" [%s:%d:%d] %s\n",
pos.Filename, pos.Line, pos.Char, fmt.Sprintf(err, stuff...))
log.Error("resolve", v.Module.File.MarkPos(pos))
os.Exit(util.EXIT_FAILURE_SEMANTIC)
}
开发者ID:gitter-badger,项目名称:ark,代码行数:10,代码来源:resolve.go
示例5: Visit
func (v *RecursiveDefinitionCheck) Visit(s *SemanticAnalyzer, n ast.Node) {
if typeDecl, ok := n.(*ast.TypeDecl); ok {
typ := typeDecl.NamedType
if ok, path := isTypeRecursive(typ); ok {
s.Err(n, "Encountered recursive type definition")
log.Errorln("semantic", "Path taken:")
for _, typ := range path {
log.Error("semantic", typ.TypeName())
log.Error("semantic", " <- ")
}
log.Error("semantic", "%s\n\n", typ.TypeName())
}
}
}
开发者ID:kiljacken,项目名称:ark,代码行数:15,代码来源:recursive.go
示例6: err
func (v *Scope) err(err string, stuff ...interface{}) {
// TODO: which log tag
// TODO: These errors are unacceptably shitty
log.Error("parser", util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" %s\n",
fmt.Sprintf(err, stuff...))
os.Exit(util.EXIT_FAILURE_PARSE)
}
开发者ID:vnev,项目名称:ark,代码行数:7,代码来源:scope.go
示例7: build
func build(files []string, outputFile string, cg string, outputType LLVMCodegen.OutputType, optLevel int) {
constructedModules, _ := parseFiles(files)
// resolve
log.Timed("resolve phase", "", func() {
for _, module := range constructedModules {
res := &parser.Resolver{Module: module}
vis := parser.NewASTVisitor(res)
vis.VisitModule(module)
}
})
// type inference
log.Timed("inference phase", "", func() {
for _, module := range constructedModules {
inf := &parser.TypeInferer{Module: module}
inf.Infer()
// Dump AST
log.Debugln("main", "AST of module `%s`:", module.Name)
for _, node := range module.Nodes {
log.Debugln("main", "%s", node.String())
}
log.Debugln("main", "")
}
})
// semantic analysis
log.Timed("semantic analysis phase", "", func() {
for _, module := range constructedModules {
sem := semantic.NewSemanticAnalyzer(module, *buildOwnership, *ignoreUnused)
vis := parser.NewASTVisitor(sem)
vis.VisitModule(module)
sem.Finalize()
}
})
// codegen
if cg != "none" {
var gen codegen.Codegen
switch cg {
case "llvm":
gen = &LLVMCodegen.Codegen{
OutputName: outputFile,
OutputType: outputType,
OptLevel: optLevel,
}
default:
log.Error("main", util.Red("error: ")+"Invalid backend choice `"+cg+"`")
os.Exit(1)
}
log.Timed("codegen phase", "", func() {
gen.Generate(constructedModules)
})
}
}
开发者ID:IanMurray,项目名称:ark,代码行数:59,代码来源:main.go
示例8: errPos
func (v *lexer) errPos(pos Position, err string, stuff ...interface{}) {
log.Errorln("lexer", util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" [%s:%d:%d] %s",
pos.Filename, pos.Line, pos.Char, fmt.Sprintf(err, stuff...))
log.Error("lexer", v.input.MarkPos(pos))
os.Exit(1)
}
开发者ID:IanMurray,项目名称:ark,代码行数:8,代码来源:lexer.go
示例9: Module
func (v *NameMap) Module(name LocatedString) *NameMap {
mod := v.module(name)
if mod == nil {
startPos := name.Where.Start()
log.Errorln("constructor", "[%s:%d:%d] Unknown module `%s`",
startPos.Filename, startPos.Line, startPos.Char, name.Value)
log.Error("constructor", v.tree.Source.MarkSpan(name.Where))
}
return mod
}
开发者ID:dansawkins,项目名称:ark,代码行数:10,代码来源:name_pass.go
示例10: TypeOf
func (v *NameMap) TypeOf(name LocatedString) NodeType {
typ := v.typeOf(name)
if typ == NODE_UNKOWN {
startPos := name.Where.Start()
log.Errorln("constructor", "[%s:%d:%d] Undeclared name `%s`",
startPos.Filename, startPos.Line, startPos.Char, name.Value)
log.Error("constructor", v.tree.Source.MarkSpan(name.Where))
}
return typ
}
开发者ID:dansawkins,项目名称:ark,代码行数:10,代码来源:name_pass.go
示例11: errSpan
func (v *Constructor) errSpan(pos lexer.Span, err string, stuff ...interface{}) {
log.Errorln("constructor",
util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" [%s:%d:%d] %s",
pos.Filename, pos.StartLine, pos.StartChar,
fmt.Sprintf(err, stuff...))
log.Error("constructor", v.curTree.Source.MarkSpan(pos))
os.Exit(util.EXIT_FAILURE_CONSTRUCTOR)
}
开发者ID:kiljacken,项目名称:ark,代码行数:10,代码来源:constructor.go
示例12: errPos
func (v *Constructor) errPos(pos lexer.Position, err string, stuff ...interface{}) {
log.Errorln("constructor",
util.TEXT_RED+util.TEXT_BOLD+"Constructor error:"+util.TEXT_RESET+" [%s:%d:%d] %s",
pos.Filename, pos.Line, pos.Char,
fmt.Sprintf(err, stuff...))
log.Error("constructor", v.tree.Source.MarkPos(pos))
os.Exit(util.EXIT_FAILURE_CONSTRUCTOR)
}
开发者ID:gitter-badger,项目名称:ark,代码行数:10,代码来源:constructor.go
示例13: errPosSpecific
func (v *parser) errPosSpecific(pos lexer.Position, err string, stuff ...interface{}) {
v.dumpRules()
log.Errorln("parser",
util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" [%s:%d:%d] %s",
pos.Filename, pos.Line, pos.Char,
fmt.Sprintf(err, stuff...))
log.Error("parser", v.input.MarkPos(pos))
os.Exit(util.EXIT_FAILURE_PARSE)
}
开发者ID:IanMurray,项目名称:ark,代码行数:11,代码来源:parser.go
示例14: errTokenSpecific
func (v *parser) errTokenSpecific(tok *lexer.Token, err string, stuff ...interface{}) {
v.dumpRules()
log.Errorln("parser",
util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" [%s:%d:%d] %s",
tok.Where.Filename, tok.Where.StartLine, tok.Where.StartChar,
fmt.Sprintf(err, stuff...))
log.Error("parser", v.input.MarkSpan(tok.Where))
os.Exit(util.EXIT_FAILURE_PARSE)
}
开发者ID:IanMurray,项目名称:ark,代码行数:11,代码来源:parser.go
示例15: build
func build(files []string, outputFile string, cg string, ccArgs []string, outputType LLVMCodegen.OutputType) {
constructedModules, modules := parseFiles(files)
// resolve
timed("resolve phase", func() {
// TODO: We're looping over a map, the order we get is thus random
for _, module := range modules {
res := &parser.Resolver{Module: module}
res.Resolve(modules)
}
})
// semantic analysis
timed("semantic analysis phase", func() {
// TODO: We're looping over a map, the order we get is thus random
for _, module := range modules {
sem := &parser.SemanticAnalyzer{Module: module}
sem.Analyze(modules)
}
})
// codegen
if cg != "none" {
var gen codegen.Codegen
switch cg {
case "llvm":
gen = &LLVMCodegen.Codegen{
OutputName: outputFile,
CompilerArgs: ccArgs,
OutputType: outputType,
}
default:
log.Error("main", util.Red("error: ")+"Invalid backend choice `"+cg+"`")
os.Exit(1)
}
timed("codegen phase", func() {
gen.Generate(constructedModules, modules)
})
}
}
开发者ID:gitter-badger,项目名称:ark,代码行数:43,代码来源:main.go
示例16: Build
func (v *Context) Build(output string, outputType codegen.OutputType, usedCodegen string, optLevel int) {
// Start by loading the runtime
runtimeModule := LoadRuntime()
// Parse the passed files
v.parseFiles()
// resolve
hasMainFunc := false
log.Timed("resolve phase", "", func() {
for _, module := range v.modules {
ast.Resolve(module, v.moduleLookup)
// Use module scope to check for main function
mainIdent := module.ModScope.GetIdent(ast.UnresolvedName{Name: "main"})
if mainIdent != nil && mainIdent.Type == ast.IDENT_FUNCTION && mainIdent.Public {
hasMainFunc = true
}
}
})
// and here we check if we should
// bother continuing any further...
if !hasMainFunc {
log.Error("main", util.Red("error: ")+"main function not found\n")
os.Exit(1)
}
// type inference
log.Timed("inference phase", "", func() {
for _, module := range v.modules {
for _, submod := range module.Parts {
ast.Infer(submod)
// Dump AST
log.Debugln("main", "AST of submodule `%s/%s`:", module.Name, submod.File.Name)
for _, node := range submod.Nodes {
log.Debugln("main", "%s", node.String())
}
log.Debugln("main", "")
}
}
})
// semantic analysis
log.Timed("semantic analysis phase", "", func() {
for _, module := range v.modules {
semantic.SemCheck(module, *ignoreUnused)
}
})
// codegen
if usedCodegen != "none" {
var gen codegen.Codegen
switch usedCodegen {
case "llvm":
gen = &LLVMCodegen.Codegen{
OutputName: output,
OutputType: outputType,
OptLevel: optLevel,
}
default:
log.Error("main", util.Red("error: ")+"Invalid backend choice `"+usedCodegen+"`")
os.Exit(1)
}
log.Timed("codegen phase", "", func() {
mods := v.modules
if runtimeModule != nil {
mods = append(mods, runtimeModule)
}
gen.Generate(mods)
})
}
}
开发者ID:kiljacken,项目名称:ark,代码行数:76,代码来源:main.go
示例17: err
func (v *Scope) err(err string, stuff ...interface{}) {
// TODO: which log tag
log.Error("parser", util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" %s\n",
fmt.Sprintf(err, stuff...))
os.Exit(util.EXIT_FAILURE_CODEGEN)
}
开发者ID:gitter-badger,项目名称:ark,代码行数:6,代码来源:scope.go
示例18: setupErr
func setupErr(err string, stuff ...interface{}) {
log.Error("main", util.TEXT_RED+util.TEXT_BOLD+"error:"+util.TEXT_RESET+" %s\n",
fmt.Sprintf(err, stuff...))
os.Exit(util.EXIT_FAILURE_SETUP)
}
开发者ID:vnev,项目名称:ark,代码行数:5,代码来源:main.go
示例19: build
func build(files []string, outputFile string, cg string, outputType LLVMCodegen.OutputType, optLevel int) {
constructedModules, moduleLookup := parseFiles(files)
// resolve
hasMainFunc := false
log.Timed("resolve phase", "", func() {
for _, module := range constructedModules {
parser.Resolve(module, moduleLookup)
// Use module scope to check for main function
mainIdent := module.ModScope.GetIdent(parser.UnresolvedName{Name: "main"})
if mainIdent != nil && mainIdent.Type == parser.IDENT_FUNCTION && mainIdent.Public {
hasMainFunc = true
}
}
})
// and here we check if we should
// bother continuing any further...
if !hasMainFunc {
log.Error("main", util.Red("error: ")+"main function not found\n")
os.Exit(1)
}
// type inference
log.Timed("inference phase", "", func() {
for _, module := range constructedModules {
for _, submod := range module.Parts {
inf := &parser.TypeInferer{Submodule: submod}
inf.Infer()
// Dump AST
log.Debugln("main", "AST of submodule `%s/%s`:", module.Name, submod.File.Name)
for _, node := range submod.Nodes {
log.Debugln("main", "%s", node.String())
}
log.Debugln("main", "")
}
}
})
// semantic analysis
log.Timed("semantic analysis phase", "", func() {
for _, module := range constructedModules {
for _, submod := range module.Parts {
sem := semantic.NewSemanticAnalyzer(submod, *buildOwnership, *ignoreUnused)
vis := parser.NewASTVisitor(sem)
vis.VisitSubmodule(submod)
sem.Finalize()
}
}
})
// codegen
if cg != "none" {
var gen codegen.Codegen
switch cg {
case "llvm":
gen = &LLVMCodegen.Codegen{
OutputName: outputFile,
OutputType: outputType,
OptLevel: optLevel,
}
default:
log.Error("main", util.Red("error: ")+"Invalid backend choice `"+cg+"`")
os.Exit(1)
}
log.Timed("codegen phase", "", func() {
gen.Generate(constructedModules)
})
}
}
开发者ID:vnev,项目名称:ark,代码行数:76,代码来源:main.go
示例20: MapNames
func MapNames(nodes []ParseNode, tree *ParseTree, modules map[string]*ParseTree, parent *NameMap) *NameMap {
nameMap := &NameMap{}
nameMap.parent = parent
nameMap.tree = tree
nameMap.types = make(map[string]NodeType)
nameMap.modules = make(map[string]*NameMap)
previousLocation := make(map[string]lexer.Span)
shouldExit := false
var cModule *NameMap
if parent == nil {
for i := 0; i < len(_PrimitiveType_index); i++ {
typ := PrimitiveType(i)
name := typ.TypeName()
nameMap.types[name] = NODE_PRIMITIVE
previousLocation[name] = lexer.Span{Filename: "_builtin"}
}
cModule = &NameMap{
types: make(map[string]NodeType),
modules: make(map[string]*NameMap),
}
cModule.types["uint"] = NODE_TYPE
cModule.types["int"] = NODE_TYPE
nameMap.types["C"] = NODE_MODULE
nameMap.modules["C"] = cModule
} else {
cModule = parent.module(LocatedString{Value: "C"})
}
for _, node := range nodes {
var name LocatedString
var typ NodeType
switch node.(type) {
case *FunctionDeclNode:
fdn := node.(*FunctionDeclNode)
name, typ = fdn.Header.Name, NODE_FUNCTION
if fdn.Header.IsMethod {
continue // TODO is this right?
}
if fdn.Header.Attrs().Contains("c") || fdn.Attrs().Contains("c") {
_, occupied := nameMap.modules["C"].types[name.Value]
if occupied {
startPos := name.Where.Start()
log.Errorln("constructor", "[%s:%d:%d] Found duplicate definition of `%s`",
tree.Source.Path, startPos.Line, startPos.Char, name.Value)
log.Error("constructor", tree.Source.MarkSpan(name.Where))
prevPos := previousLocation[name.Value]
log.Errorln("constructor", "[%s:%d:%d] Previous declaration was here",
tree.Source.Path, prevPos.StartLine, prevPos.StartChar)
log.Error("constructor", tree.Source.MarkSpan(prevPos))
shouldExit = true
}
cModule.types[name.Value] = typ
previousLocation[name.Value] = name.Where
continue
}
case *VarDeclNode:
vd := node.(*VarDeclNode)
name, typ = vd.Name, NODE_VARIABLE
case *TypeDeclNode:
vd := node.(*TypeDeclNode)
name, typ = vd.Name, NODE_TYPE
switch vd.Type.(type) {
case *EnumTypeNode:
typ = NODE_ENUM
case *StructTypeNode:
typ = NODE_STRUCT
}
case *UseDeclNode:
udn := node.(*UseDeclNode)
baseModuleName := udn.Module.Name
if len(udn.Module.Modules) > 0 {
baseModuleName = udn.Module.Modules[0]
}
mod, ok := modules[baseModuleName.Value]
if !ok {
startPos := baseModuleName.Where.Start()
log.Errorln("constructor", "[%s:%d:%d] Unknown module `%s`",
tree.Source.Path, startPos.Line, startPos.Char, baseModuleName.Value)
log.Error("constructor", tree.Source.MarkSpan(baseModuleName.Where))
shouldExit = true
}
nameMap.modules[baseModuleName.Value] = MapNames(mod.Nodes, mod, modules, nil)
modNameMap := nameMap.modules[baseModuleName.Value]
for _, mod := range udn.Module.Modules {
nextMap, ok := modNameMap.modules[mod.Value]
if !ok {
startPos := mod.Where.Start()
//.........这里部分代码省略.........
开发者ID:dansawkins,项目名称:ark,代码行数:101,代码来源:name_pass.go
注:本文中的github.com/ark-lang/ark/src/util/log.Error函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论