NewEnv returns a new *Env with the given parameters.
(container *containers.Container, provider types.Provider, opts ...Option)
| 79 | |
| 80 | // NewEnv returns a new *Env with the given parameters. |
| 81 | func NewEnv(container *containers.Container, provider types.Provider, opts ...Option) (*Env, error) { |
| 82 | declarations := newScopes() |
| 83 | declarations.Push() |
| 84 | |
| 85 | envOptions := &options{} |
| 86 | for _, opt := range opts { |
| 87 | if err := opt(envOptions); err != nil { |
| 88 | return nil, err |
| 89 | } |
| 90 | } |
| 91 | aggLitElemType := dynElementType |
| 92 | if envOptions.homogeneousAggregateLiterals { |
| 93 | aggLitElemType = homogenousElementType |
| 94 | } |
| 95 | filteredOverloadIDs := crossTypeNumericComparisonOverloads |
| 96 | if envOptions.crossTypeNumericComparisons { |
| 97 | filteredOverloadIDs = make(map[string]struct{}) |
| 98 | } |
| 99 | if envOptions.validatedDeclarations != nil { |
| 100 | declarations = envOptions.validatedDeclarations.PushInherited() |
| 101 | } |
| 102 | return &Env{ |
| 103 | container: container, |
| 104 | provider: provider, |
| 105 | declarations: declarations, |
| 106 | aggLitElemType: aggLitElemType, |
| 107 | filteredOverloadIDs: filteredOverloadIDs, |
| 108 | jsonFieldNames: envOptions.jsonFieldNames, |
| 109 | }, nil |
| 110 | } |
| 111 | |
| 112 | // AddIdents configures the checker with a list of variable declarations. |
| 113 | // |