// AddVariable adds a new variable entry to debug_info.
// Will write a DW_TAG_variable, followed by a DW_AT_type and a
// DW_AT_location.
357912
func (b *Builder) AddVariable(varname string, typ dwarf.Offset, loc interface{}) dwarf.Offset {
	r := b.TagOpen(dwarf.TagVariable, varname)
	b.Attr(dwarf.AttrType, typ)
	b.Attr(dwarf.AttrLocation, loc)
	b.TagClose()
	return r
}
610596
func (c *Gcd) AddEnvironmentVars(vars []string) {
	c.env = append(c.env, vars...)
}
398678
func (cmd *Cmd) SetVar(k string, v interface{}) {
	cmd.context.SetVar(k, v, internal.LocalScope)
}
868418
func (s *Service) CreateVariable(ctx context.Context, variable *influxdb.Variable) error {
	return s.kv.Update(ctx, func(tx Tx) error {
		variable.ID = s.IDGenerator.ID()

		if err := s.putVariableOrgsIndex(ctx, tx, variable); err != nil {
			return err
		}

		if pe := s.putVariable(ctx, tx, variable); pe != nil {
			return &influxdb.Error{
				Err: pe,
			}

		}
		return nil
	})
}
661657
func (q TemplateQuery) Var(name string, value interface{}) TemplateQuery {
	q.vars[name] = value
	return q
}
335308
func (s *numericCompilerVisitor) AcceptVariable(v tree.Variable) {
	s.err = errors.New("a variable was found in an expression - this is likely a programmer error")
}
1008523
func (p *Parser) Variable() bool {

	c, _ := p.Byte()

	if c != '$' {
		p.UnreadByte()
		return false
	}

	c, _ = p.Byte()
	if c == '\\' {
		p.ev.Add("$")
		return true
	}

	p.UnreadByte()

	i := p.ev.Level()

	c, _ = p.Byte()
	if c == '(' {
		p.ev.Add(TypeExpression)
		p.ev.Inc()
		p.Expression()
		p.Space()
		p.Byte() // Should be ')'
	} else {
		p.ev.Add(TypePath)
		p.ev.Inc()
		if c != '{' {
			p.UnreadByte()
		} else {
			p.Space()
		}
		p.Path()

		if c == '{' {
			p.Space()
			p.Byte() // Should be '}'
		}
	}

	// Reset the level
	p.ev.SetLevel(i)

	return true

}
1286022
func (b *stdBackend) SetVariable(id string, v int64) {
	if b.ssvFilter != nil && !b.ssvFilter(id) {
		return
	}
	b.ssvChangeC <- &stdSSVChange{id, true, v}
}
992613
func (c *Client) UpdateVariable(ctx context.Context, id platform.ID, update *platform.VariableUpdate) (*platform.Variable, error) {
	op := getOp(platform.OpUpdateVariable)
	var variable *platform.Variable
	err := c.db.Update(func(tx *bolt.Tx) error {
		m, pe := c.findVariableByID(ctx, tx, id)
		if pe != nil {
			return &platform.Error{
				Op:  op,
				Err: pe,
			}
		}

		if err := update.Apply(m); err != nil {
			return &platform.Error{
				Op:  op,
				Err: err,
			}
		}

		variable = m
		if pe = c.putVariable(ctx, tx, variable); pe != nil {
			return &platform.Error{
				Op:  op,
				Err: pe,
			}
		}
		return nil
	})

	return variable, err
}
238349
func (b *stdBackend) ReadVariable(id string) (StaySetVariable, error) {
	resp, err := b.command(cmdStaySetVariableRead, id)
	if err != nil {
		return nil, err
	}
	return resp.(StaySetVariable), nil
}
1068370
func (s *VariableService) FindVariables(ctx context.Context, filter platform.VariableFilter, opts ...platform.FindOptions) ([]*platform.Variable, error) {
	url, err := newURL(s.Addr, variablePath)
	if err != nil {
		return nil, err
	}

	query := url.Query()
	if filter.OrganizationID != nil {
		query.Add("orgID", filter.OrganizationID.String())
	}
	if filter.Organization != nil {
		query.Add("org", *filter.Organization)
	}
	if filter.ID != nil {
		query.Add("id", filter.ID.String())
	}

	req, err := http.NewRequest("GET", url.String(), nil)
	if err != nil {
		return nil, err
	}
	req.URL.RawQuery = query.Encode()
	SetToken(s.Token, req)

	hc := newClient(url.Scheme, s.InsecureSkipVerify)

	resp, err := hc.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	if err := CheckError(resp); err != nil {
		return nil, err
	}

	var ms getVariablesResponse
	if err := json.NewDecoder(resp.Body).Decode(&ms); err != nil {
		return nil, err
	}

	variables := ms.ToPlatform()
	return variables, nil
}
326156
func (s *VariableService) UpdateVariable(ctx context.Context, id platform.ID, update *platform.VariableUpdate) (*platform.Variable, error) {
	u, err := newURL(s.Addr, variableIDPath(id))
	if err != nil {
		return nil, err
	}

	octets, err := json.Marshal(update)
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest("PATCH", u.String(), bytes.NewReader(octets))
	if err != nil {
		return nil, err
	}

	req.Header.Set("Content-Type", "application/json")
	SetToken(s.Token, req)

	hc := newClient(u.Scheme, s.InsecureSkipVerify)

	resp, err := hc.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	if err := CheckError(resp); err != nil {
		return nil, err
	}

	var m platform.Variable
	if err := json.NewDecoder(resp.Body).Decode(&m); err != nil {
		return nil, err
	}

	return &m, nil
}
1024229
func Var(inReal []float64, inTimePeriod int) []float64 {

	outReal := make([]float64, len(inReal))

	nbInitialElementNeeded := inTimePeriod - 1
	startIdx := nbInitialElementNeeded
	periodTotal1 := 0.0
	periodTotal2 := 0.0
	trailingIdx := startIdx - nbInitialElementNeeded
	i := trailingIdx
	if inTimePeriod > 1 {
		for i < startIdx {
			tempReal := inReal[i]
			periodTotal1 += tempReal
			tempReal *= tempReal
			periodTotal2 += tempReal
			i++
		}
	}
	outIdx := startIdx
	for ok := true; ok; {
		tempReal := inReal[i]
		periodTotal1 += tempReal
		tempReal *= tempReal
		periodTotal2 += tempReal
		meanValue1 := periodTotal1 / float64(inTimePeriod)
		meanValue2 := periodTotal2 / float64(inTimePeriod)
		tempReal = inReal[trailingIdx]
		periodTotal1 -= tempReal
		tempReal *= tempReal
		periodTotal2 -= tempReal
		outReal[outIdx] = meanValue2 - meanValue1*meanValue1
		i++
		trailingIdx++
		outIdx++
		ok = i < len(inReal)
	}
	return outReal
}
888911
func (g *Group) Var() *Statement {
	// notest
	s := Var()
	g.items = append(g.items, s)
	return s
}
194393
func (ln *line) isVariable() bool {
	if !ln.isTopIndent() {
		return false
	}

	_, _, err := variableNV(ln)

	return err == nil
}
458212
func (c *Compiler) DefineVariable(identifier string, value interface{}) (err error) {
	cid := C.CString(identifier)
	defer C.free(unsafe.Pointer(cid))
	switch value.(type) {
	case bool:
		var v int
		if value.(bool) {
			v = 1
		}
		err = newError(C.yr_compiler_define_boolean_variable(
			c.cptr, cid, C.int(v)))
	case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
		value := toint64(value)
		err = newError(C.yr_compiler_define_integer_variable(
			c.cptr, cid, C.int64_t(value)))
	case float64:
		err = newError(C.yr_compiler_define_float_variable(
			c.cptr, cid, C.double(value.(float64))))
	case string:
		cvalue := C.CString(value.(string))
		defer C.free(unsafe.Pointer(cvalue))
		err = newError(C.yr_compiler_define_string_variable(
			c.cptr, cid, cvalue))
	default:
		err = errors.New("wrong value type passed to DefineVariable; bool, int64, float64, string are accepted")
	}
	keepAlive(c)
	return
}
680429
func NewVariableService() *VariableService {
	return &VariableService{
		FindVariablesF: func(context.Context, platform.VariableFilter, ...platform.FindOptions) ([]*platform.Variable, error) {
			return nil, nil
		},
		FindVariableByIDF: func(context.Context, platform.ID) (*platform.Variable, error) { return nil, nil },
		CreateVariableF:   func(context.Context, *platform.Variable) error { return nil },
		UpdateVariableF: func(ctx context.Context, id platform.ID, update *platform.VariableUpdate) (*platform.Variable, error) {
			return nil, nil
		},
		ReplaceVariableF: func(context.Context, *platform.Variable) error { return nil },
		DeleteVariableF:  func(context.Context, platform.ID) error { return nil },
	}
}