Gráfico de Commits

34 Commits

Autor SHA1 Mensagem Data
Paul Tarjan 2494ce49b5 Don't allow use Foo where Foo is already a class
Classes need to take up space in the alias map (according to zend).

Suprisingly, functions and constants don't. When importing a duplicate, zend doesn't do anything and just continues, and we currently overwrite the symbol. Should I match zend on this, or is the fact that we both continue working good enough?
2013-05-20 13:52:24 -07:00
Paul Tarjan 9309f4c9c7 don't use aliases for functions or constants
@andrewparoski had the excellent observation that functions and constants don't get imported with use statements.
2013-05-15 13:05:10 -07:00
Sara Golemon 6ec64e8bf9 make #includes consistent
I was learning from @jdelong and he said that you should use
double quotes for local includes and angle brackets for library
includes. I asked why our code was the way it was, and he said he wanted
to clean it up. I beat him to it :)

Conflicts:

	hphp/runtime/base/server/admin_request_handler.cpp
	hphp/runtime/vm/named_entity.h
2013-05-15 13:05:06 -07:00
Drew Paroski a8d84e2f21 Refactor HipHopSyntax and HackMode to play nice 2013-05-15 13:05:04 -07:00
Alok Menghrajani db9577b140 Rename strict with Hack
Strict mode was the old name. Let's avoid any confusion in the future and rename things.
2013-05-15 13:05:03 -07:00
Paul Tarjan 1e0f032ba7 absorb comments on namespaces
This test didn't really intentionally test this, but it caught us not eating comments on namespaces.

I don't understand the difference between ##ParserBase## and ##Parser##. Maybe this belongs here? It needed to be here to have access to ##pushComment##.
2013-05-15 13:05:03 -07:00
Paul Tarjan 96e793360b function and constant fallback for namespaces
It turned out a lot of the namespace stuff still worked. The biggest thing for the first pass is that we don't fallback to the global function or constant if there isn't a namespaced one.

Also, when a constant has a ##\## anywhere in it it throw an error when it isn't defined, instead of assuming the string.
2013-05-15 13:05:01 -07:00
Sara Golemon 38f9fab773 Fix __HALT_COMPILER() support
Actually halt the compiler, and set __COMPILER_HALT_OFFSET__ constant
2013-05-01 20:59:44 -07:00
Owen Yamauchi a57ae0488a Generate the parser at build time, part one
Update a number of things to make optionally generating the parser at
build time possible.  @sgolemon will add the OSS pieces of this in a
separate commit.
2013-04-30 09:57:57 -07:00
Paul Tarjan 5aede8cba8 fix segfault
Don't assume we are in a function.
2013-04-30 09:27:02 -07:00
bsimmers fa0a201dde Revert "name anonymous continuations as Class::Method$continuation" 2013-04-22 14:43:52 -07:00
Sara Golemon 82489e1fd1 Make generators always-enabled
Zend supports generators now, so it's not
really HipHop specific syntax anymore
2013-04-22 14:43:46 -07:00
drussi 6e8178da16 expose type annotation to reflection including generics, function types and tuples
This is intended so reflection can be used (via getTypehintText and getReturnTypehintText) to regenerate code the user annotated with types. Essentially using reflection to intrispect code in order to generate type safe
(hack safe) code. That is particularly important for the tools that do dependency injection. The runtime should be oblivious to the change as the rich type annotation is currently only stored for the sake of reflection. For
functions the values are in the shared portion which is cold and should also take care of traits.
2013-04-19 12:21:55 -07:00
ptarjan ac1d69902e name anonymous continuations as Class::Method$continuation
As a user, this often annoyed me that I couldn't get any debugging info
out of the name and then @ahupp asked for it.

I didn't really know what to name closure ones as the name is done at
emission time. So I went with ##{closure}##. I'm not sure how I feel
about that since it will be uncorrelated with the emitted name.

While I was in there, I deleted a lot of unused code.

I'm totally open to other names and ideas.
2013-04-11 10:58:54 -07:00
mikemag ab9e26f8af Avoid stack overflow on super-large expressions of binary operators.
A small change to optimize very simple binary operators in the parser. This avoids building very large parse trees for super-large expressions and folds binary operators involving two scalars directly in the parser. I've limited this to simple scalars since it's easy to prove they don't have anything too interesting going on in the other analysis phases leading up to BinaryOpExpression's normal folding. This works for all binary operators.
2013-04-09 15:31:40 -07:00
drussi bf740ca345 expose return type constraint (aka hint) from the AST to the runtime and reflection
This is the first part of the work to expose type constraint and generic all the way to reflection. This first DIFF exposes the return type with generic types coming next.
2013-04-09 15:31:40 -07:00
jdelong 6faa7cbea1 @override-unit-failures Initial support for <?hh typedefs and shapes
Adds runtime support for non-class typehints.  Typedefs are
introduced using type statements, and autoloaded via a new autoload
map entry.  Shapes are parsed but the structure is currently thrown
away and treated as arrays at runtime.  This extends the NamedEntity
structure to sometimes cache 'NameDefs', which are either Typedef*'s
or Class*'s.  VerifyParamType now has to check for typedefs if an
object fails a class check, or when checking non-Object types against
a non-primitive type name that isn't a class.
2013-04-09 13:01:46 -07:00
ptarjan 78df5374d5 change func_num_args() from parser error to warning
I also introduced some code that I'll use to map their error messages to ours.
2013-04-04 15:39:00 -07:00
jan 10b770d342 Simplify hphp_unpack_continuation
Do not generate yield labels as normal goto labels in the parser. Create
them at YieldExpression and use m_yieldLabels array in emitter.
2013-03-25 12:43:42 -07:00
jan 06713e6226 Eliminate transform_yield_break()
The only places where ReturnStatement is constructed are:

- onReturn(check_yield=true) -> not allowed in generator
- onReturn(check_yield=false) -> coming from transform_yield_break, right after creating hphp_continuation_done()
- MethodStatement, end of function call -> hphp_continuation_done() is created at end of generator in prepare_generator()

Emitter is emitting ContExit in ReturnStatements used in generators. As
can be seen from the analysis above, it's always preceded by emitting
ContDone from hphp_continuation_done(). Let's emit ContDone inside the
ReturnStatement directly and kill usage of hphp_continuation_done().

transform_yield_break() becomes a simple onReturn(check_yield=false), so
let's inline it into onYield and create ReturnStatement directly. After
this change, check_yield flag is always true and can be killed.

ContExit was also used after emitting a generator method in case the end
of method is still reachable. ContDone is added so that the generator is
properly closed. I believe this is never actually used, as MethodStatement
creates ReturnStatement at the end of method anyway.
2013-03-25 11:31:17 -07:00
jan 7b7343b56a Introduce YieldExpression
Unhack the parser and introduce YieldExpression that emits the
equivalent set of opcodes that were emitted by bunch of
expressions/statements generated by parser before.

YieldExpression expects evaluation stack to contain just the value
being yielded, so {,List}AssignmentExpression need to evaluate RHS
first. The previous code had the same behavior.

This will let us consolidate continuation-related opcodes and make
them less tied with continuation objects.
2013-03-22 13:01:05 -07:00
jan f9765d1c58 Fix local propagation of generator parameters
Alias manager does not know that generator parameters are populated and
assumes they are uninit. The current code works because control flow
algorithm gives up while trying to deal with the continuation switch
statement full of gotos.

This diff fixes it by setting isGeneratorParameter flag in symbols
representing parameters of enclosing generator wrapper and use variables
of enclosing closure.
2013-03-21 19:33:53 -07:00
ptarjan a1802db1d2 allow static keyword before closure
PHP added this in 5.4 so that you can say your closure shouldn't capture ##$this##. https://wiki.php.net/rfc/closures

Should we add it? Many of their unit tests use it.

Instead of putting a boolean somewhere I used the same attr framework and set the static bit there. Thoughts? It only needs one change in the ##FPushFunc##.
2013-03-21 16:50:55 -07:00
mwilliams cbf041b01b Remove Option::OutputHHBC and Option::SystemGen 2013-03-21 15:17:33 -07:00
jan 2db40741d0 Remove transform_foreach
Iteration opcodes work with locals that are correctly suspended/resumed
thru yield, transform_foreach not needed anymore.
2013-03-21 11:31:29 -07:00
ptarjan 71ee3ea273 get ref correct in closure parser 2013-03-09 13:26:15 -08:00
ptarjan fd2f07d1f1 Revert allowing $this in closures
I'm going to do a replacement diff anyways, so all this does is delays it a week.
2013-03-09 12:49:43 -08:00
mwilliams 10f9f6b239 const bool hhvm is dead 2013-03-09 12:49:37 -08:00
Owen Yamauchi bffeb65b84 Delete NativeXHP flag
This flag isn't being used in any of our deployments. I sure hope not,
anyway, because if you turn it off, things are mega-busted; I can't even
run a sandbox without crashing pretty early on.

This breaks the OSS build's dependency on xhp. We're still depending on
it internally in a Facebook-specific extension (exposing the XHP
preprocessor to PHP code as ##xhp_preprocess_code()##). There might be
some way to replicate this functionality using HPHP's native XHP parser,
but that seems low-pri.
2013-03-05 22:07:57 -08:00
ptarjan 9f21844eb5 handle reference closures
Handle a closure that returns by reference.
2013-03-05 22:07:56 -08:00
aalexandre b3b41e08bb Replaced NULL with nullptr 2013-02-19 06:57:54 -08:00
ptarjan f3cf268bb1 create onClosureStart
For parity with onFunctionStart we should have an onClosureStart. It was really confusing to start with onFunctionStart and then end with onClosure.
2013-02-11 06:36:50 -08:00
mwilliams f6efec4d7c Enable CodeError generation under hhvm
Just when running as hphp, so we can use the USE_HHVM version
of hphp to generate the reports
2013-02-11 06:32:54 -08:00
Jordan Delong 363d1bb20f Code move src/ -> hphp/
This change is mostly for FB internal organizational reasons.
Building is not effected beyond the fact that the target now
lands in hphp/hhvm/hhvm rather than src/hhvm/hhvm.
2013-02-11 02:10:41 -08:00