Commit a503084a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent ca3c4e76
...@@ -30,7 +30,6 @@ package main ...@@ -30,7 +30,6 @@ package main
import ( import (
"bufio" "bufio"
"bytes"
"flag" "flag"
"fmt" "fmt"
"go/ast" "go/ast"
...@@ -468,77 +467,9 @@ func removeFile(path string) error { ...@@ -468,77 +467,9 @@ func removeFile(path string) error {
return err return err
} }
// Buffer is bytes.Buffer + syntatic sugar // Program represents loaded program for tracepoint analysis
type Buffer struct { // It is generalization of loader.Program due to loader not allowing to
bytes.Buffer // construct programs incrementally.
}
func (b *Buffer) emit(format string, argv ...interface{}) {
fmt.Fprintf(b, format + "\n", argv...)
}
// StrSet is set<string>
type StrSet map[string]struct{}
func (s StrSet) Add(itemv ...string) {
for _, item := range itemv {
s[item] = struct{}{}
}
}
func (s StrSet) Delete(item string) {
delete(s, item)
}
// Itemv returns ordered slice of set items
func (s StrSet) Itemv() []string {
itemv := make([]string, 0, len(s))
for item := range s {
itemv = append(itemv, item)
}
sort.Strings(itemv)
return itemv
}
/*
// findPackageNoZTrace is (*build.Context).Import but filters-out ztrace* files from found package
//
// we don't load what should be generated by us for 2 reasons:
// - code generated could be wrong with older version of the
// tool - it should not prevent from regenerating.
// - generated code imports packages which might be not there
// yet in gopath (lab.nexedi.com/kirr/go123/tracing)
func findPackageNoZTrace(ctxt *build.Context, importPath, fromDir string, mode build.ImportMode) (*build.Package, error) {
bp, err := ctxt.Import(importPath, fromDir, mode)
filter := func(filev *[]string) {
var okv []string
for _, f := range *filev {
if strings.HasPrefix(f, "ztrace") {
bp.IgnoredGoFiles = append(bp.IgnoredGoFiles, f)
} else {
okv = append(okv, f)
}
}
*filev = okv
}
if bp != nil {
filter(&bp.GoFiles)
filter(&bp.CgoFiles)
filter(&bp.TestGoFiles)
filter(&bp.XTestGoFiles)
filter(&bp.SFiles)
// XXX also adjust .Import{s,Pos}, .TestImport{s,Pos}, .XTestImport{s,Pos} ?
}
return bp, err
}
*/
type Program struct { type Program struct {
// list of loader.Programs in use // list of loader.Programs in use
// //
......
// Copyright (C) 2017 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
package main
// misc utilities
import (
"bytes"
"fmt"
"sort"
)
// Buffer is bytes.Buffer + syntatic sugar
type Buffer struct {
bytes.Buffer
}
func (b *Buffer) emit(format string, argv ...interface{}) {
fmt.Fprintf(b, format + "\n", argv...)
}
// StrSet is set<string>
type StrSet map[string]struct{}
func (s StrSet) Add(itemv ...string) {
for _, item := range itemv {
s[item] = struct{}{}
}
}
func (s StrSet) Delete(item string) {
delete(s, item)
}
// Itemv returns ordered slice of set items
func (s StrSet) Itemv() []string {
itemv := make([]string, 0, len(s))
for item := range s {
itemv = append(itemv, item)
}
sort.Strings(itemv)
return itemv
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment