diff --git a/cue/token/position.go b/cue/token/position.go index a0542df4ad9..8a8f96be4a2 100644 --- a/cue/token/position.go +++ b/cue/token/position.go @@ -115,36 +115,32 @@ var NoPos = Pos{} // RelPos indicates the relative position of token to the previous token. type RelPos int +//go:generate go run golang.org/x/tools/cmd/stringer -type=RelPos -linecomment + const ( // NoRelPos indicates no relative position is specified. - NoRelPos RelPos = iota + NoRelPos RelPos = iota // invalid // Elided indicates that the token for which this position is defined is // not rendered at all. - Elided + Elided // elided // NoSpace indicates there is no whitespace before this token. - NoSpace + NoSpace // nospace // Blank means there is horizontal space before this token. - Blank + Blank // blank // Newline means there is a single newline before this token. - Newline + Newline // newline // NewSection means there are two or more newlines before this token. - NewSection + NewSection // section relMask = 0xf relShift = 4 ) -var relNames = []string{ - "invalid", "elided", "nospace", "blank", "newline", "section", -} - -func (p RelPos) String() string { return relNames[p] } - func (p RelPos) Pos() Pos { return Pos{nil, int(p)} } diff --git a/cue/token/relpos_string.go b/cue/token/relpos_string.go new file mode 100644 index 00000000000..0129d7bb62e --- /dev/null +++ b/cue/token/relpos_string.go @@ -0,0 +1,28 @@ +// Code generated by "stringer -type=RelPos -linecomment"; DO NOT EDIT. + +package token + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NoRelPos-0] + _ = x[Elided-1] + _ = x[NoSpace-2] + _ = x[Blank-3] + _ = x[Newline-4] + _ = x[NewSection-5] +} + +const _RelPos_name = "invalidelidednospaceblanknewlinesection" + +var _RelPos_index = [...]uint8{0, 7, 13, 20, 25, 32, 39} + +func (i RelPos) String() string { + if i < 0 || i >= RelPos(len(_RelPos_index)-1) { + return "RelPos(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _RelPos_name[_RelPos_index[i]:_RelPos_index[i+1]] +} diff --git a/internal/core/adt/composite.go b/internal/core/adt/composite.go index bbef133c4a8..a49435651e4 100644 --- a/internal/core/adt/composite.go +++ b/internal/core/adt/composite.go @@ -499,6 +499,8 @@ func (s *StructInfo) useForAccept() bool { // vertexStatus indicates the evaluation progress of a Vertex. type vertexStatus int8 +//go:generate go run golang.org/x/tools/cmd/stringer -type=vertexStatus + const ( // unprocessed indicates a Vertex has not been processed before. // Value must be nil. @@ -529,25 +531,6 @@ const ( finalized ) -func (s vertexStatus) String() string { - switch s { - case unprocessed: - return "unprocessed" - case evaluating: - return "evaluating" - case partial: - return "partial" - case conjuncts: - return "conjuncts" - case evaluatingArcs: - return "evaluatingArcs" - case finalized: - return "finalized" - default: - return "unknown" - } -} - func (v *Vertex) Status() vertexStatus { return v.status } diff --git a/internal/core/adt/debug.go b/internal/core/adt/debug.go index 4ecfb219763..b55e11d352c 100644 --- a/internal/core/adt/debug.go +++ b/internal/core/adt/debug.go @@ -152,6 +152,8 @@ func openDebugGraph(ctx *OpContext, v *Vertex, name string) { // dependencies are balanced. type depKind int +//go:generate go run golang.org/x/tools/cmd/stringer -type=depKind + const ( // PARENT dependencies are used to track the completion of parent // closedContexts within the closedness tree. @@ -200,37 +202,6 @@ const ( TEST // Always refers to self. ) -func (k depKind) String() string { - switch k { - case PARENT: - return "PARENT" - case ARC: - return "ARC" - case NOTIFY: - return "NOTIFY" - case TASK: - return "TASK" - case DISJUNCT: - return "DISJUNCT" - case EVAL: - return "EVAL" - case COMP: - return "COMP" - case ROOT: - return "ROOT" - - case INIT: - return "INIT" - case DEFER: - return "DEFER" - case SHARED: - return "SHARED" - case TEST: - return "TEST" - } - panic("unreachable") -} - // ccDep is used to record counters which is used for debugging only. // It is purpose is to be precise about matching inc/dec as well as to be able // to traverse dependency. diff --git a/internal/core/adt/depkind_string.go b/internal/core/adt/depkind_string.go new file mode 100644 index 00000000000..0308eb57c90 --- /dev/null +++ b/internal/core/adt/depkind_string.go @@ -0,0 +1,35 @@ +// Code generated by "stringer -type=depKind"; DO NOT EDIT. + +package adt + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[PARENT-1] + _ = x[ARC-2] + _ = x[NOTIFY-3] + _ = x[TASK-4] + _ = x[DISJUNCT-5] + _ = x[EVAL-6] + _ = x[COMP-7] + _ = x[ROOT-8] + _ = x[INIT-9] + _ = x[DEFER-10] + _ = x[SHARED-11] + _ = x[TEST-12] +} + +const _depKind_name = "PARENTARCNOTIFYTASKDISJUNCTEVALCOMPROOTINITDEFERSHAREDTEST" + +var _depKind_index = [...]uint8{0, 6, 9, 15, 19, 27, 31, 35, 39, 43, 48, 54, 58} + +func (i depKind) String() string { + i -= 1 + if i < 0 || i >= depKind(len(_depKind_index)-1) { + return "depKind(" + strconv.FormatInt(int64(i+1), 10) + ")" + } + return _depKind_name[_depKind_index[i]:_depKind_index[i+1]] +} diff --git a/internal/core/adt/errorcode_string.go b/internal/core/adt/errorcode_string.go new file mode 100644 index 00000000000..bb1e0da5d92 --- /dev/null +++ b/internal/core/adt/errorcode_string.go @@ -0,0 +1,27 @@ +// Code generated by "stringer -type=ErrorCode -linecomment"; DO NOT EDIT. + +package adt + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[EvalError-0] + _ = x[UserError-1] + _ = x[StructuralCycleError-2] + _ = x[IncompleteError-3] + _ = x[CycleError-4] +} + +const _ErrorCode_name = "evaluserstructural cycleincompletecycle" + +var _ErrorCode_index = [...]uint8{0, 4, 8, 24, 34, 39} + +func (i ErrorCode) String() string { + if i < 0 || i >= ErrorCode(len(_ErrorCode_index)-1) { + return "ErrorCode(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _ErrorCode_name[_ErrorCode_index[i]:_ErrorCode_index[i+1]] +} diff --git a/internal/core/adt/errors.go b/internal/core/adt/errors.go index ce814f14ef3..44ef238041c 100644 --- a/internal/core/adt/errors.go +++ b/internal/core/adt/errors.go @@ -42,45 +42,31 @@ import ( // control flow. No other aspects of an error may influence control flow. type ErrorCode int8 +//go:generate go run golang.org/x/tools/cmd/stringer -type=ErrorCode -linecomment + const ( // An EvalError is a fatal evaluation error. - EvalError ErrorCode = iota + EvalError ErrorCode = iota // eval // A UserError is a fatal error originating from the user. - UserError + UserError // user // StructuralCycleError means a structural cycle was found. Structural // cycles are permanent errors, but they are not passed up recursively, // as a unification of a value with a structural cycle with one that // doesn't may still give a useful result. - StructuralCycleError + StructuralCycleError // structural cycle // IncompleteError means an evaluation could not complete because of // insufficient information that may still be added later. - IncompleteError + IncompleteError // incomplete // A CycleError indicates a reference error. It is considered to be // an incomplete error, as reference errors may be broken by providing // a concrete value. - CycleError + CycleError // cycle ) -func (c ErrorCode) String() string { - switch c { - case EvalError: - return "eval" - case UserError: - return "user" - case StructuralCycleError: - return "structural cycle" - case IncompleteError: - return "incomplete" - case CycleError: - return "cycle" - } - return "unknown" -} - // Bottom represents an error or bottom symbol. // // Although a Bottom node holds control data, it should not be created until the diff --git a/internal/core/adt/runmode_string.go b/internal/core/adt/runmode_string.go new file mode 100644 index 00000000000..1cb34d6ab10 --- /dev/null +++ b/internal/core/adt/runmode_string.go @@ -0,0 +1,27 @@ +// Code generated by "stringer -type=runMode"; DO NOT EDIT. + +package adt + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[ignore-1] + _ = x[attemptOnly-2] + _ = x[yield-3] + _ = x[finalize-4] +} + +const _runMode_name = "ignoreattemptOnlyyieldfinalize" + +var _runMode_index = [...]uint8{0, 6, 17, 22, 30} + +func (i runMode) String() string { + i -= 1 + if i >= runMode(len(_runMode_index)-1) { + return "runMode(" + strconv.FormatInt(int64(i+1), 10) + ")" + } + return _runMode_name[_runMode_index[i]:_runMode_index[i+1]] +} diff --git a/internal/core/adt/sched.go b/internal/core/adt/sched.go index 488f8b30c55..f4f3186c0d3 100644 --- a/internal/core/adt/sched.go +++ b/internal/core/adt/sched.go @@ -176,6 +176,8 @@ func (s schedState) String() string { // runMode indicates how to proceed after a condition could not be met. type runMode uint8 +//go:generate go run golang.org/x/tools/cmd/stringer -type=runMode + const ( // ignore indicates that the new evaluator should not do any processing. // This is mostly used in the transition from old to new evaluator and @@ -196,20 +198,6 @@ const ( finalize ) -func (r runMode) String() string { - switch r { - case ignore: - return "ignore" - case attemptOnly: - return "attemptOnly" - case yield: - return "yield" - case finalize: - return "finalize" - } - return "unknown" -} - // condition is a bit mask of states that a task may depend on. // // There are generally two types of states: states that are met if all tasks diff --git a/internal/core/adt/vertexstatus_string.go b/internal/core/adt/vertexstatus_string.go new file mode 100644 index 00000000000..789f0883bb9 --- /dev/null +++ b/internal/core/adt/vertexstatus_string.go @@ -0,0 +1,28 @@ +// Code generated by "stringer -type=vertexStatus"; DO NOT EDIT. + +package adt + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[unprocessed-0] + _ = x[evaluating-1] + _ = x[partial-2] + _ = x[conjuncts-3] + _ = x[evaluatingArcs-4] + _ = x[finalized-5] +} + +const _vertexStatus_name = "unprocessedevaluatingpartialconjunctsevaluatingArcsfinalized" + +var _vertexStatus_index = [...]uint8{0, 11, 21, 28, 37, 51, 60} + +func (i vertexStatus) String() string { + if i < 0 || i >= vertexStatus(len(_vertexStatus_index)-1) { + return "vertexStatus(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _vertexStatus_name[_vertexStatus_index[i]:_vertexStatus_index[i+1]] +} diff --git a/internal/httplog/event.go b/internal/httplog/event.go index 291479dfaec..c6e70a21cb6 100644 --- a/internal/httplog/event.go +++ b/internal/httplog/event.go @@ -13,26 +13,17 @@ type Logger interface { type EventKind int +//go:generate go run golang.org/x/tools/cmd/stringer -type=EventKind -linecomment + const ( - NoEvent EventKind = iota - KindClientSendRequest - KindClientRecvResponse + NoEvent EventKind = iota + KindClientSendRequest // http client-> + KindClientRecvResponse // http client<- // TODO KindServerRecvRequest // TODO KindServerSendResponse ) -func (k EventKind) String() string { - switch k { - case KindClientSendRequest: - return "http client->" - case KindClientRecvResponse: - return "http client<-" - default: - return "unknown" - } -} - // Request represents an HTTP request. type Request struct { ID int64 `json:"id"` diff --git a/internal/httplog/eventkind_string.go b/internal/httplog/eventkind_string.go new file mode 100644 index 00000000000..bb30edfb63d --- /dev/null +++ b/internal/httplog/eventkind_string.go @@ -0,0 +1,25 @@ +// Code generated by "stringer -type=EventKind -linecomment"; DO NOT EDIT. + +package httplog + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[NoEvent-0] + _ = x[KindClientSendRequest-1] + _ = x[KindClientRecvResponse-2] +} + +const _EventKind_name = "NoEventhttp client->http client<-" + +var _EventKind_index = [...]uint8{0, 7, 20, 33} + +func (i EventKind) String() string { + if i < 0 || i >= EventKind(len(_EventKind_index)-1) { + return "EventKind(" + strconv.FormatInt(int64(i), 10) + ")" + } + return _EventKind_name[_EventKind_index[i]:_EventKind_index[i+1]] +}