mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 19:29:39 +00:00
compiler: don't push X onto the stack for inlined method calls
Regular methods need this, because it'll be packed into parameters, but inlined ones should deal with it in inlining code itself because method receiver will be some local (aliased) variable anyway.
This commit is contained in:
parent
2ba9017207
commit
6014dd720f
1 changed files with 8 additions and 8 deletions
|
@ -914,15 +914,7 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
|
|||
return nil
|
||||
}
|
||||
case *ast.SelectorExpr:
|
||||
// If this is a method call we need to walk the AST to load the struct locally.
|
||||
// Otherwise, this is a function call from an imported package and we can call it
|
||||
// directly.
|
||||
name, isMethod := c.getFuncNameFromSelector(fun)
|
||||
if isMethod {
|
||||
ast.Walk(c, fun.X)
|
||||
// Don't forget to add 1 extra argument when its a method.
|
||||
numArgs++
|
||||
}
|
||||
|
||||
f, ok = c.funcs[name]
|
||||
if ok {
|
||||
|
@ -938,6 +930,14 @@ func (c *codegen) Visit(node ast.Node) ast.Visitor {
|
|||
c.emitExplicitConvert(c.typeOf(n.Args[0]), typ)
|
||||
return nil
|
||||
}
|
||||
if isMethod {
|
||||
// If this is a method call we need to walk the AST to load the struct locally.
|
||||
// Otherwise, this is a function call from an imported package and we can call it
|
||||
// directly.
|
||||
ast.Walk(c, fun.X)
|
||||
// Don't forget to add 1 extra argument when it's a method.
|
||||
numArgs++
|
||||
}
|
||||
case *ast.ArrayType:
|
||||
// For now we will assume that there are only byte slice conversions.
|
||||
// E.g. []byte("foobar") or []byte(scriptHash).
|
||||
|
|
Loading…
Reference in a new issue