// compileFields compiles a collection of AST fields into a FieldGroup.
487897
func compileFields(src []*ast.Field, options fieldOptions) (FieldGroup, error) {
	fieldsNS := newNamespace(caseInsensitive)
	usedIDs := make(map[int16]string)

	fields := make([]*FieldSpec, 0, len(src))
	for _, astField := range src {
		if err := fieldsNS.claim(astField.Name, astField.Line); err != nil {
			return nil, compileError{
				Target: astField.Name,
				Line:   astField.Line,
				Reason: err,
			}
		}

		field, err := compileField(astField, options)
		if err != nil {
			return nil, compileError{
				Target: astField.Name,
				Line:   astField.Line,
				Reason: err,
			}
		}

		if conflictingField, ok := usedIDs[field.ID]; ok {
			return nil, compileError{
				Target: astField.Name,
				Line:   astField.Line,
				Reason: fieldIDConflictError{
					ID:   field.ID,
					Name: conflictingField,
				},
			}
		}

		fields = append(fields, field)
		usedIDs[field.ID] = field.Name
	}

	return FieldGroup(fields), nil
}
1117587
func (this *GoTemplateCompiler) Compile(f string) (templates.Templater, error) {
	return template.ParseFiles(f)
}
557591
func (c *Compiler) CompileWriter(out io.Writer) (err error) {
	defer func() {
		if r := recover(); r != nil {
			err = errors.New(r.(string))
		}
	}()

	c.buffer = new(bytes.Buffer)
	c.visit(c.node)

	if c.buffer.Len() > 0 {
		c.write("\n")
	}

	_, err = c.buffer.WriteTo(out)
	return
}
51857
func (s *ExplainService) Fields(fields ...string) *ExplainService {
	s.fields = append(s.fields, fields...)
	return s
}
408020
func (s *SearchSource) Field(fieldName string) *SearchSource {
	if s.fieldNames == nil {
		s.fieldNames = make([]string, 0)
	}
	s.fieldNames = append(s.fieldNames, fieldName)
	return s
}
400412
func (c *Compiler) Compile(ctx context.Context, stmtNode ast.StmtNode) (*ExecStmt, error) {
	return c.compile(ctx, stmtNode, false)
}
980920
func compileMapType(src ast.MapType) (*MapSpec, error) {
	annots, err := compileAnnotations(src.Annotations)
	if err != nil {
		return nil, err
	}

	keySpec, err := compileTypeReference(src.KeyType)
	if err != nil {
		return nil, err
	}

	valueSpec, err := compileTypeReference(src.ValueType)
	if err != nil {
		return nil, err
	}

	return &MapSpec{
		KeySpec:     keySpec,
		ValueSpec:   valueSpec,
		Annotations: annots,
	}, nil
}
1054243
func (r *Render) compile() {
	for _, ts := range r.templates {
		fileList := make([]string, len(ts.fileList))
		for i, f := range ts.fileList {
			fileList[i] = path.Join(r.opt.Directory, f)
		}
		ts.template = template.New(ts.entry)
		ts.template.Delims(r.opt.Delims.Left, r.opt.Delims.Right)
		for _, funcs := range r.opt.Funcs {
			ts.template.Funcs(funcs)
		}
		ts.template = template.Must(ts.template.ParseFiles(fileList...))
	}
	log.Debugf("Templates have been compiled, count=%d", len(r.templates))
}
302583
func (this *AmberCompiler) Compile(f string) (templates.Templater, error) {
	// amber.CompileFile creates a new compiler each time. To limit the number
	// of allocations, reuse a compiler.
	if this.c == nil {
		this.c = amber.New()
	}
	this.c.Options = this.Options
	if err := this.c.ParseFile(f); err != nil {
		return nil, err
	}
	return this.c.Compile()
}
893742
func (tsconfig *Tsconfig) CompilerArgs() []string {
	val := reflect.ValueOf(tsconfig).Elem().FieldByName("CompilerOptions") // -> for tsconfig *Tsconfig
	// val := reflect.ValueOf(tsconfig.CompilerOptions)
	compilerOpts := make([]string, 0) // 0 because we don't know the real valid options yet.
	for i := 0; i < val.NumField(); i++ {
		typeField := val.Type().Field(i)
		valueFieldG := val.Field(i)
		var valueField string
		// only if it's string or int we need to put that
		if valueFieldG.Kind() == reflect.String {
			//if valueFieldG.String() != "" {
			//valueField = strconv.QuoteToASCII(valueFieldG.String())
			//	}
			valueField = valueFieldG.String()
		} else if valueFieldG.Kind() == reflect.Int {
			if valueFieldG.Int() > 0 {
				valueField = strconv.Itoa(int(valueFieldG.Int()))
			}
		} else if valueFieldG.Kind() == reflect.Bool {
			valueField = strconv.FormatBool(valueFieldG.Bool())
		}

		if valueField != "" && valueField != "false" {
			// var opt string

			// key := typeField.Tag.Get("json")
			// // it's bool value of true then just --key, for example --watch
			// if valueField == "true" {
			// 	opt = "--" + key
			// } else {
			// 	// it's a string now, for example  -m commonjs
			// 	opt = "-" + string(key[0]) + " " + valueField
			// }
			key := "--" + typeField.Tag.Get("json")
			compilerOpts = append(compilerOpts, key)
			// the form is not '--module ES6' but os.Exec should recognise them as arguments
			// so we need to put the values on the next index
			if valueField != "true" {
				// it's a string now, for example  -m commonjs
				compilerOpts = append(compilerOpts, valueField)
			}

		}

	}

	return compilerOpts
}
47388
func (p *Parser) parseFields() (Fields, error) {
	var fields Fields

	for {
		// Parse the field.
		f, err := p.parseField()
		if err != nil {
			return nil, err
		}

		// Add new field.
		fields = append(fields, f)

		// If there's not a comma next then stop parsing fields.
		if tok, _, _ := p.Scan(); tok != COMMA {
			p.Unscan()
			break
		}
	}
	return fields, nil
}
1285479
func (s *ScanOp) Fields(fields []string) *ScanOp {
	s.fieldsToRead = fields
	return s
}
1241847
func (r *Rego) Compile(ctx context.Context) (*CompileResult, error) {

	pq, err := r.Partial(ctx)
	if err != nil {
		return nil, err
	}

	if len(pq.Support) > 0 {
		return nil, fmt.Errorf("modules not supported")
	}

	policy, err := planner.New().WithQueries(pq.Queries).Plan()
	if err != nil {
		return nil, err
	}

	if r.dump != nil {
		fmt.Fprintln(r.dump, "PLAN:")
		fmt.Fprintln(r.dump, "-----")
		ir.Pretty(r.dump, policy)
		fmt.Fprintln(r.dump)
	}

	m, err := wasm.New().WithPolicy(policy).Compile()
	if err != nil {
		return nil, err
	}

	var out bytes.Buffer

	if err := encoding.WriteModule(&out, m); err != nil {
		return nil, err
	}

	result := &CompileResult{
		Bytes: out.Bytes(),
	}

	return result, nil
}
878660
func (t *transpilerState) mapFields(in cursor) (cursor, error) {
	columns := t.stmt.ColumnNames()
	if len(columns) != len(t.stmt.Fields) {
		// TODO(jsternberg): This scenario should not be possible. Replace the use of ColumnNames with a more
		// statically verifiable list of columns when we process the fields from the select statement instead
		// of doing this in the future.
		panic("number of columns does not match the number of fields")
	}

	properties := make([]*semantic.Property, 0, len(t.stmt.Fields)+1)
	properties = append(properties, &semantic.Property{
		Key: &semantic.Identifier{Name: execute.DefaultTimeColLabel},
		Value: &semantic.MemberExpression{
			Object: &semantic.IdentifierExpression{
				Name: "r",
			},
			Property: execute.DefaultTimeColLabel,
		},
	})
	for i, f := range t.stmt.Fields {
		if ref, ok := f.Expr.(*influxql.VarRef); ok && ref.Val == "time" {
			// Skip past any time columns.
			continue
		}
		value, err := t.mapField(f.Expr, in)
		if err != nil {
			return nil, err
		}
		properties = append(properties, &semantic.Property{
			Key:   &semantic.Identifier{Name: columns[i]},
			Value: value,
		})
	}
	id := t.op("map", &transformations.MapOpSpec{
		Fn: &semantic.FunctionExpression{
			Block: &semantic.FunctionBlock{
				Parameters: &semantic.FunctionParameters{
					List: []*semantic.FunctionParameter{{
						Key: &semantic.Identifier{Name: "r"},
					}},
				},
				Body: &semantic.ObjectExpression{
					Properties: properties,
				},
			},
		},
		MergeKey: true,
	}, in.ID())
	return &mapCursor{id: id}, nil
}
166975
func NonConvertibleFields(annotations map[string]string) map[string]string {
	nonConvertibleKeys := map[string]string{}
	for key, value := range annotations {
		if strings.HasPrefix(key, core.NonConvertibleAnnotationPrefix) {
			nonConvertibleKeys[key] = value
		}
	}
	return nonConvertibleKeys
}
754902
func (stmt RetInsertStmt) CompileColumns(d aspect.Dialect, params *aspect.Parameters, columns []aspect.ColumnElem) []string {
	names := make([]string, len(columns))
	for i, c := range columns {
		names[i], _ = c.Compile(d, params)
	}
	return names
}
324652
func compileExpression(s string) (expr Expression, err error) {
	tokens := tokenize(s)
	if contains(tokens, "?") {
		return ternaryToken.compile(tokens)
	}
	return constToken.compile(tokens)
}