// Evaluate executes code and pretty prints the result to the specified output
// stream.
4692
func (re *JSRE) Evaluate(code string, w io.Writer) error {
	var fail error

	re.Do(func(vm *otto.Otto) {
		val, err := vm.Run(code)
		if err != nil {
			prettyError(vm, err, w)
		} else {
			prettyPrint(vm, val, w)
		}
		fmt.Fprintln(w)
	})
	return fail
}
741443
func (_m *PolicyEvaluator) Evaluate(policyBytes []byte, signatureSet []*common.SignedData) error {
	ret := _m.Called(policyBytes, signatureSet)

	var r0 error
	if rf, ok := ret.Get(0).(func([]byte, []*common.SignedData) error); ok {
		r0 = rf(policyBytes, signatureSet)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
1237046
func (vm *VM) EvaluateSnippet(filename string, snippet string) (json string, formattedErr error) {
	output, err := vm.evaluateSnippet(filename, snippet, evalKindRegular)
	if err != nil {
		return "", errors.New(vm.ErrorFormatter.Format(err))
	}
	json = output.(string)
	return
}
774286
func (d *domainClient) Evaluate(ctx context.Context, args *EvaluateArgs) (reply *EvaluateReply, err error) {
	reply = new(EvaluateReply)
	if args != nil {
		err = rpcc.Invoke(ctx, "Runtime.evaluate", args, reply, d.conn)
	} else {
		err = rpcc.Invoke(ctx, "Runtime.evaluate", nil, reply, d.conn)
	}
	if err != nil {
		err = &internal.OpError{Domain: "Runtime", Op: "Evaluate", Err: err}
	}
	return
}
1350433
func (remote *RemoteDebugger) EvaluateWrap(expr string) (interface{}, error) {
	expr = fmt.Sprintf("(function(){%v})()", expr)
	return remote.Evaluate(expr)
}
1360449
func Evaluate(clients []*Client, truth [][]time.Duration) (stats Stats) {
	nodes := len(clients)
	count := 0
	for i := 0; i < nodes; i++ {
		for j := i + 1; j < nodes; j++ {
			est := clients[i].DistanceTo(clients[j].GetCoordinate()).Seconds()
			actual := truth[i][j].Seconds()
			error := math.Abs(est-actual) / actual
			stats.ErrorMax = math.Max(stats.ErrorMax, error)
			stats.ErrorAvg += error
			count += 1
		}
	}

	stats.ErrorAvg /= float64(count)
	fmt.Printf("Error avg=%9.6f max=%9.6f\n", stats.ErrorAvg, stats.ErrorMax)
	return
}
707816
func (i *DefaultInterpreter) Execute(
	expression string,
	ctx *Context) (interface{}, error) {
	funcs := template.FuncMap{}
	for k, v := range i.Funcs {
		funcs[k] = v
	}
	var res interface{}
	resultEvaluated := false
	funcs["set"] = func(r interface{}) interface{} {
		res = r
		resultEvaluated = true
		return r
	}
	funcs["eval"] = func(intrpr, expr string) (interface{}, error) {
		return ctx.EvalExpr(intrpr, expr, ctx)
	}
	templName := fmt.Sprintf("<<%s>>", ctx.LongName)
	left := i.LeftDelim
	right := i.RightDelim
	if left == "" {
		left = "{{"
	}
	if right == "" {
		right = "}}"
	}
	if i.AutoEnclose &&
		!(strings.HasPrefix(expression, left) &&
			strings.HasSuffix(expression, right)) {
		expression = fmt.Sprintf("%s%s%s", left, expression, right)
	}
	t, err := template.
		New(templName).
		Delims(left, right).
		Funcs(funcs).
		Parse(expression)
	if err != nil {
		return nil, err
	}
	var buf bytes.Buffer
	err = t.Execute(&buf, ctx)
	if err != nil {
		return nil, err
	}
	if resultEvaluated {
		return res, nil
	}
	return buf.String(), nil
}
662463
func (c *EvalCommand) Run(args []string) int {
	if len(args) == 0 {
		c.Ui.Error(c.Help())
		return 1
	}

	c.InitOpts()
	tmpls, err := c.parseOpts(args)
	if err != nil {
		if errwrap.Contains(err, "flag: help requested") {
			return 0
		}
		return 1
	}
	inputs, outputs := make([]string, len(tmpls)), make([]string, len(tmpls))
	var rawInput, readStdin bool
	for i, in := range tmpls {
		if readStdin {
			break
		}

		rawInput = c.rawInput
		if in == "-" {
			rawInput = true
			var f io.Reader = os.Stdin
			var buf bytes.Buffer
			if _, err := io.Copy(&buf, f); err != nil {
				c.Ui.Error(fmt.Sprintf("[ERROR]: Error reading from stdin: %v", err))
				return 1
			}
			in = buf.String()
			if len(in) == 0 {
				return 0
			}
			readStdin = true
		}
		inputs[i] = in

		if !rawInput {
			in = `{{` + in + `}}`
			inputs[i] = in
		}

		out, err := template.Parse(in)
		if err != nil {
			c.Ui.Error(fmt.Sprintf("ERROR[%d] in: %q\n[%d] msg: %v\n", i, in, i, err))
			return 1
		}
		outputs[i] = out
	}

	if c.debugOutput {
		for i, out := range outputs {
			c.Ui.Output(fmt.Sprintf("[%d] in: %q\n[%d] out: %q\n", i, inputs[i], i, out))
			if i != len(outputs)-1 {
				if c.debugOutput {
					c.Ui.Output(fmt.Sprintf("---\n"))
				}
			}
		}
	} else {
		sep := "\n"
		if c.suppressNewline {
			sep = ""
		}
		c.Ui.Output(strings.Join(outputs, sep))
	}

	return 0
}
488270
func (vertices vertices) evaluate(config NelderMeadConfiguration) {
	for _, v := range vertices {
		v.evaluate(config)
	}

	vertices.sort(config)
}
953471
func (sf *ScalarFunction) Eval(row []types.Datum, _ context.Context) (types.Datum, error) {
	return sf.Function.eval(row)
}
1309562
func (service *Service) Evaluate(getSvc GetService, findChild FindChildService, instanceID int) (err error) {
	if err = service.EvaluateEndpointTemplates(getSvc, findChild, instanceID); err != nil {
		plog.WithError(err).Error()
		return err
	}
	if err = service.EvaluateLogConfigTemplate(getSvc, findChild, instanceID); err != nil {
		plog.WithError(err).Error()
		return err
	}
	if err = service.EvaluateConfigFilesTemplate(getSvc, findChild, instanceID); err != nil {
		plog.WithError(err).Error()
		return err
	}
	if err = service.EvaluateStartupTemplate(getSvc, findChild, instanceID); err != nil {
		plog.WithError(err).Error()
		return err
	}
	if err = service.EvaluateRunsTemplate(getSvc, findChild); err != nil {
		plog.WithError(err).Error()
		return err
	}
	if err = service.EvaluateActionsTemplate(getSvc, findChild, instanceID); err != nil {
		plog.WithError(err).Error()
		return err
	}
	if err = service.EvaluateHostnameTemplate(getSvc, findChild, instanceID); err != nil {
		plog.WithError(err).Error()
		return err
	}
	if err = service.EvaluateVolumesTemplate(getSvc, findChild, instanceID); err != nil {
		plog.WithError(err).Error()
		return err
	}
	if err = service.EvaluatePrereqsTemplate(getSvc, findChild, instanceID); err != nil {
		plog.WithError(err).Error()
		return err
	}
	if err = service.EvaluateHealthCheckTemplate(getSvc, findChild, instanceID); err != nil {
		plog.WithError(err).Error()
		return err
	}
	if err = service.EvaluateEnvironmentTemplate(getSvc, findChild, instanceID); err != nil {
		plog.WithError(err).Error()
		return err
	}
	return nil
}
1253882
func EvaluateValue(v Value) error {
	switch v.Type() {
	case TBool, TI8, TDouble, TI16, TI32, TI64, TBinary:
		return nil
	case TStruct:
		for _, f := range v.GetStruct().Fields {
			if err := EvaluateValue(f.Value); err != nil {
				return err
			}
		}
		return nil
	case TMap:
		m := v.GetMap()
		defer m.Close()
		return m.ForEach(func(item MapItem) error {
			if err := EvaluateValue(item.Key); err != nil {
				return err
			}
			return EvaluateValue(item.Value)
		})
	case TSet:
		s := v.GetSet()
		defer s.Close()
		return s.ForEach(EvaluateValue)
	case TList:
		l := v.GetList()
		defer l.Close()
		return l.ForEach(EvaluateValue)
	default:
		return fmt.Errorf("unknown type %s", v.Type())
	}
}
176861
func (functions Functions) Evaluate(values map[string][]string) bool {
	for _, f := range functions {
		if !f.evaluate(values) {
			return false
		}
	}

	return true
}
143149
func (c *ConfigParser) evaluateExpressions(m map[string]interface{}, seenKeys []string, testOnly bool) error {
	for k, ei := range m {
		thisPath := append(seenKeys, k)
		switch subval := ei.(type) {
		case string, bool, float64, nil:
			continue
		case []interface{}:
			if len(subval) == 0 {
				continue
			}
			evaled, err := c.evalValue(subval)
			if err != nil {
				return fmt.Errorf("%s: value error %v", strings.Join(thisPath, "."), err)
			}
			if !testOnly {
				m[k] = evaled
			}
		case map[string]interface{}:
			if err := c.evaluateExpressions(subval, thisPath, testOnly); err != nil {
				return err
			}
		default:
			return fmt.Errorf("%s: unhandled type %T", strings.Join(thisPath, "."), ei)
		}
	}
	return nil
}
703691
func Eval(n EvalNode, ctx EvalContext) (interface{}, error) {
	// Call the lower level eval which doesn't understand early exit,
	// and if we early exit, it isn't an error.
	result, err := EvalRaw(n, ctx)
	if err != nil {
		if _, ok := err.(EvalEarlyExitError); ok {
			return nil, nil
		}
	}

	return result, err
}
458684
func (p *policy) Evaluate(signatureSet []*cb.SignedData) error {
	if p == nil {
		return fmt.Errorf("No such policy")
	}
	idAndS := make([]IdentityAndSignature, len(signatureSet))
	for i, sd := range signatureSet {
		idAndS[i] = &deserializeAndVerify{
			signedData:   sd,
			deserializer: p.deserializer,
		}
	}

	ok := p.evaluator(deduplicate(idAndS), make([]bool, len(signatureSet)))
	if !ok {
		return errors.New("signature set did not satisfy policy")
	}
	return nil
}
1193615
func Values(w io.Writer, r Output) error {
	if r.Error != nil {
		return prettyError(w, r.Error)
	}
	for _, rs := range r.Result {
		line := make([]interface{}, len(rs.Expressions))
		for i := range line {
			line[i] = rs.Expressions[i].Value
		}
		if err := JSON(os.Stdout, line); err != nil {
			return err
		}
	}
	return nil
}