Which function is actually called?

22 views
Skip to first unread message

Stepan Koltsov

unread,
Aug 6, 2012, 4:02:12 PM8/6/12
to clay-l...@googlegroups.com
Hi.

I'm calling

```
foo(a, b)
```

somewhere in my program.

Unless there is no compilation error, is there any way to find out which overload of foo is actually used here?

--
Stepan Koltsov

Stepan Koltsov

unread,
Aug 6, 2012, 4:04:03 PM8/6/12
to clay-l...@googlegroups.com


I mean "unless there is a compilation error".

In another words, how can I find, which function is used when compile compiles without errors?

--
Stepan Koltsov

Joe Groff

unread,
Aug 6, 2012, 4:06:48 PM8/6/12
to clay-l...@googlegroups.com
On Mon, Aug 6, 2012 at 1:04 PM, Stepan Koltsov <stepan....@gmail.com> wrote:
>
> I mean "unless there is a compilation error".
>
> In another words, how can I find, which function is used when compile
> compiles without errors?
>

There isn't a proper mechanism for this. Currently the only way to
observe what overload gets picked is to induce a compilation error in
one or more of the overloads.

-Joe

Joe Groff

unread,
Aug 6, 2012, 5:02:38 PM8/6/12
to clay-l...@googlegroups.com
I pushed a patch to master to add a '-log-match <module>.<symbol>'
option to the compiler, which will log the matching process for all
calls to the given symbol. You can use it like this:

```

% ./build/compiler/src/clay -Ilib-clay -log-match printer.println
examples/hello.clay
###############################

main() {
println("Hello World");
-----------^
}

###############################
examples/hello.clay(4,11): note: matched
lib-clay/printer/printer.clay(510,0)
matched

compilation context:
println(Static["Hello World"])
examples/hello.clay(4,11):
main()
lib-clay/core/system/system.clay(22,30):
getExitCode()
lib-clay/core/system/system.clay(22,26):
runMain(Int32, Pointer[Pointer[Int8]], Static[main])
lib-clay/core/system/system.clay(32,13):
callMain(Static[main], Int32, Pointer[Pointer[Int8]])
external main
```

-Joe

Stepan Koltsov

unread,
Aug 6, 2012, 5:14:22 PM8/6/12
to clay-l...@googlegroups.com


And it also prints which overload it couldn't use before it found matching one. Great! Thanks!

--
Stepan Koltsov
Reply all
Reply to author
Forward
0 new messages