MCPcopy Create free account
hub / github.com/crossoverJie/gscript / buildAppendParamValuesReturnLeft

Method buildAppendParamValuesReturnLeft

internal_function.go:410–431  ·  view source on GitHub ↗
(ctx *parser.FunctionCallContext)

Source from the content-addressed store, hash-verified

408}
409
410func (v *Visitor) buildAppendParamValuesReturnLeft(ctx *parser.FunctionCallContext) ([]interface{}, *LeftValue) {
411 ret := make([]interface{}, 0)
412 if ctx.ExpressionList() == nil {
413 return ret, nil
414 }
415 var left *LeftValue
416 for _, context := range ctx.ExpressionList().(*parser.ExpressionListContext).AllExpr() {
417 value := v.Visit(context)
418 switch value.(type) {
419 case *LeftValue:
420 leftValue := value.(*LeftValue)
421 if left == nil {
422 // 只需要赋值一次左值即可,避免 append(buf, temp); temp 也是变量时,第二次遍历时会把 temp 赋值给 left
423 left = leftValue
424 }
425 ret = append(ret, leftValue.GetValue())
426 default:
427 ret = append(ret, value)
428 }
429 }
430 return ret, left
431}
432
433func printf(v *Visitor, ctx *parser.FunctionCallContext) interface{} {
434 format, variableParams := v.getPrintfParams(ctx)

Callers 1

gAppendFunction · 0.80

Calls 4

VisitMethod · 0.95
GetValueMethod · 0.65
ExpressionListMethod · 0.45
AllExprMethod · 0.45

Tested by

no test coverage detected