Makes <<__Memoize>> work for top-level functions
commita22d159db06eceee0e63ddf3d654b85947015db9
authorPhil Saltzman <psaltzman@fb.com>
Fri, 22 Aug 2014 17:32:01 +0000 (22 10:32 -0700)
committerhhvm-bot <hhvm-bot@fb.com>
Fri, 22 Aug 2014 18:00:20 +0000 (22 11:00 -0700)
tree1c980de12f7aade612d61076361985ed92c9c90c
parent825952aa074a42b21f659e74e389425b7f627e68
Makes <<__Memoize>> work for top-level functions

Summary: It's a little silly to apply <<__Memoize>> to a top-level function with zero args, but with this diff the attribute can be tagged to every kind of function we want to build for. That way, as I add args it will work for all of them.

For tests, I couldn't actually figure out how to apply user attributes to inline functions without it being a syntax error. If you know how to do it I'll add a test.

While working on this diff I found that locals from the implementation were incorrectly also being emitted as locals in the memoization wrapper. This diff fixes that issue.

Reviewed By: @jano, @elgenie

Differential Revision: D1506790
hphp/compiler/analysis/emitter.cpp
hphp/compiler/analysis/emitter.h
hphp/test/quick/memoize_toplevel.php
hphp/test/quick/memoize_toplevel.php.expect [new file with mode: 0644]
hphp/test/quick/memoize_toplevel.php.expectf [deleted file]