cl: _testpy/gcd
This commit is contained in:
12
ssa/decl.go
12
ssa/decl.go
@@ -33,15 +33,19 @@ const (
|
||||
)
|
||||
|
||||
func VArg() *types.Var {
|
||||
return types.NewParam(0, nil, NameValist, types.Typ[types.Invalid])
|
||||
return types.NewParam(0, nil, NameValist, types.NewSlice(tyAny))
|
||||
}
|
||||
|
||||
func IsVArg(arg *types.Var) bool {
|
||||
return arg.Name() == NameValist
|
||||
}
|
||||
|
||||
func HasVArg(t *types.Tuple, n int) bool {
|
||||
return n > 0 && IsVArg(t.At(n-1))
|
||||
func HasVArg(t *types.Tuple, n int, sig *types.Signature) bool {
|
||||
has := n > 0 && IsVArg(t.At(n-1))
|
||||
if has && !sig.Variadic() { // TODO(xsw): remove this check
|
||||
panic("HasVArg: varg must mark as variadic in signature")
|
||||
}
|
||||
return has
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -196,7 +200,7 @@ func newParams(fn Type, prog Program) (params []Type, hasVArg bool) {
|
||||
sig := fn.raw.Type.(*types.Signature)
|
||||
in := sig.Params()
|
||||
if n := in.Len(); n > 0 {
|
||||
if hasVArg = HasVArg(in, n); hasVArg {
|
||||
if hasVArg = HasVArg(in, n, sig); hasVArg {
|
||||
n--
|
||||
}
|
||||
params = make([]Type, n)
|
||||
|
||||
Reference in New Issue
Block a user