stack/source.go
func processCall(call *Call, f *ast.FuncDecl) {
	values := make([]uint64, len(call.Args.Values))
	for i := range call.Args.Values {
		values[i] = call.Args.Values[i].Value
	}
	index := 0
	pop := func() uint64 {
		if len(values) != 0 {
			x := values[0]
			values = values[1:]
			index++
			return x
		}
		return 0
	}
	popName := func() string {
		n := call.Args.Values[index].Name
		v := pop()
		if len(n) == 0 {
			return fmt.Sprintf("0x%x", v)
		}
		return n
	}

	types, extra := extractArgumentsType(f)
	for i := 0; len(values) != 0; i++ {
		var t string
		if i >= len(types) {
			if !extra {
				// These are unexpected value! Print them as hex.
				call.Args.Processed = append(call.Args.Processed, popName())
				continue
			}
			t = types[len(types)-1]
		} else {
			t = types[i]
		}
		switch t {
		case "float32":
			call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%g", math.Float32frombits(uint32(pop()))))
		case "float64":
			call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%g", math.Float64frombits(pop())))
		case "int", "int8", "int16", "int32", "int64", "uint", "uint8", "uint16", "uint32", "uint64":
			call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%d", pop()))
		case "string":
			call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%s(%s, len=%d)", t, popName(), pop()))
		default:
			if strings.HasPrefix(t, "*") {
				call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%s(%s)", t, popName()))
			} else if strings.HasPrefix(t, "[]") {
				call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%s(%s len=%d cap=%d)", t, popName(), pop(), pop()))
			} else {
				// Assumes it's an interface. For now, discard the object value, which
				// is probably not a good idea.
				call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%s(%s)", t, popName()))
				pop()
			}
		}
		if len(values) == 0 && call.Args.Elided {
			return
		}
	}
}
func processCall(call *Call, f *ast.FuncDecl) {
	values := make([]uint64, len(call.Args.Values))
	for i := range call.Args.Values {
		values[i] = call.Args.Values[i].Value
	}
	index := 0
	pop := func() uint64 {
		if len(values) != 0 {
			x := values[0]
			values = values[1:]
			index++
			return x
		}
		return 0
	}
	popName := func() string {
		n := call.Args.Values[index].Name
		v := pop()
		if len(n) == 0 {
			return fmt.Sprintf("0x%x", v)
		}
		return n
	}

	types, extra := extractArgumentsType(f)
	for i := 0; len(values) != 0; i++ {
		var t string
		if i >= len(types) {
			if !extra {
				// These are unexpected value! Print them as hex.
				call.Args.Processed = append(call.Args.Processed, popName())
				continue
			}
			t = types[len(types)-1]
		} else {
			t = types[i]
		}
		switch t {
		case "float32":
			call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%g", math.Float32frombits(uint32(pop()))))
		case "float64":
			call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%g", math.Float64frombits(pop())))
		case "int", "int8", "int16", "int32", "int64", "uint", "uint8", "uint16", "uint32", "uint64":
			call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%d", pop()))
		case "string":
			call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%s(%s, len=%d)", t, popName(), pop()))
		default:
			if strings.HasPrefix(t, "*") {
				call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%s(%s)", t, popName()))
			} else if strings.HasPrefix(t, "[]") {
				call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%s(%s len=%d cap=%d)", t, popName(), pop(), pop()))
			} else {
				// Assumes it's an interface. For now, discard the object value, which
				// is probably not a good idea.
				call.Args.Processed = append(call.Args.Processed, fmt.Sprintf("%s(%s)", t, popName()))
				pop()
			}
		}
		if len(values) == 0 && call.Args.Elided {
			return
		}
	}
}
func processCall ( call * Call , f * ast . FuncDecl ) { values := make ( [ ] uint64 , len ( call . Args . Values ) ) for i := range call . Args . Values { values [ i ] = call . Args . Values [ i ] . Value } index := 0 pop := func ( ) uint64 { if len ( values ) != 0 { x := values [ 0 ] values = values [ 1 : ] index ++ return x } return 0 } popName := func ( ) string { n := call . Args . Values [ index ] . Name v := pop ( ) if len ( n ) == 0 { return fmt . Sprintf ( " " , v ) } return n } types , extra := extractArgumentsType ( f ) for i := 0 ; len ( values ) != 0 ; i ++ { var t string if i >= len ( types ) { if ! extra { // These are unexpected value! Print them as hex. call . Args . Processed = append ( call . Args . Processed , popName ( ) ) continue } t = types [ len ( types ) - 1 ] } else { t = types [ i ] } switch t { case " " : call . Args . Processed = append ( call . Args . Processed , fmt . Sprintf ( " " , math . Float32frombits ( uint32 ( pop ( ) ) ) ) ) case " " : call . Args . Processed = append ( call . Args . Processed , fmt . Sprintf ( " " , math . Float64frombits ( pop ( ) ) ) ) case " " , " " , " " , " " , " " , " " , " " , " " , " " , " " : call . Args . Processed = append ( call . Args . Processed , fmt . Sprintf ( " " , pop ( ) ) ) case " " : call . Args . Processed = append ( call . Args . Processed , fmt . Sprintf ( " " , t , popName ( ) , pop ( ) ) ) default : if strings . HasPrefix ( t , " " ) { call . Args . Processed = append ( call . Args . Processed , fmt . Sprintf ( " " , t , popName ( ) ) ) } else if strings . HasPrefix ( t , " " ) { call . Args . Processed = append ( call . Args . Processed , fmt . Sprintf ( " " , t , popName ( ) , pop ( ) , pop ( ) ) ) } else { // Assumes it's an interface. For now, discard the object value, which // is probably not a good idea. call . Args . Processed = append ( call . Args . Processed , fmt . Sprintf ( " " , t , popName ( ) ) ) pop ( ) } } if len ( values ) == 0 && call . Args . Elided { return } } }
// processCall walks the function and populate call accordingly.
processCall walks the function and populate call accordingly .