TITLE ^

internals - Design and Implementation of Pipp

Source code ^

See pipp.pod on where to get the code.

Issue tracking ^

Not decided yet. Will be documented in pipp.pod. See also ../ROADMAP.

Testing ^

See testing.pod.

Parsing ^

Parsing is done with Parrot Compiler Toolkit, PCT.

Bytecode generation ^

The parse tree is transformed to a Parrot Abstrace Syntax Tree. PIR und Bytecode is then generated from the PAST.

Variables ^

List of scopes and types of variables.

globals in top file
Lexical. Might need extra treatment.
globals in included files
Lexical in scope of the included file.
Class constants
Class constants are stored a package variables in the namespace $?NS ~ '\\' ~ $?CLASS ~ '::'. The trailing '::' guarantees that there is no conflict with namespace constants.TODO: make them readonly
Static class members
Like class constants, but writable.
Class members
function and method scope
Lexical is scope of the function or method.
$this
Bound to register self.
constants
Currently constants are stored in the hash ['pipp'; 'php_constants']. The functions define and defined access this package scoped hash. This approach works good enough for constants in the global namespace. For namespaced constants the above approach could be extended to consider the namespace part of the constant, the current namespace and the active namespace aliases.Another approach is to treat constants as namespaced variables and work with standard PAST techniques. Experiments using that approach are underway.

Functions and closures ^

TODO: type hints in function declarations

Builtin functions ^

Closures ^

There is a major bug in the implementation. TODO: see t/php/closures.t

Internal functions ^

Object orientation ^

Namespaces ^

A namespace is introduced with the keyword namespace. The namespaced code can be enclosed in brackets. The namespace declaration needs to be the first statement in the file. With brackets, there can be multiple namespaces per file. Nesting is not possible. Namespaces don't carry over to included files. define() doesn't define in the current namespace. The backslash character serves as the namespace separator. Short names can be defined with use. Only classes, functions and constants are namespaced. The current namespace can be queried with __NAMESPACE__. Namespaces are case insensitive. No global code can precede the first namespace directive.

Implementation in Pipp ^

In order to ease implementation and testing, there are some divergences in Pipp.

Only the bracketed syntax is supported.
Code outside the scope of namespaces directives is allowed.
'const' outside a declared namespace is allowed.

SEE ALSO ^

http://docs.php.net/manual/en/language.namespaces.php
http://docs.php.net/manual/en/language.namespaces.faq.php
http://wiki.php.net/rfc/namespaces
http://wiki.php.net/rfc/namespaceseparator
http://wiki.php.net/rfc/backslashnamespaces
http://wiki.php.net/rfc/namespacecurlies
http://wiki.php.net/rfc/namespaceref
http://inside.webfactory.de/en/blog/php-namespaces-explained.html
http://marc.info/?l=php-internals&m=121527668606247
http://bugs.php.net/bug.php?id=46304
http://loveandtheft.org/2008/10/26/set-sail-for-fail-php-namespaces/

Including and requiring ^

require_once() is supported, but might have issues with variables.

Extensions ^

Implementation in Pipp ^

Currently, Pipp has no support at all for extensions.

SEE ALSO ^

  TODO: Embedding and Extending PHP, by Sahrah ...
  L<http://www.php.net/manual/en/internals2.php>

Interaction with the Parrot world ^

Using Modules from other HLLs. Inlining PIR and other languages.

Compatability ^

See pipp.pod for a list of divergences.

Related projects. ^

See the Wiki. Roadsend, Zend, PHC.

AUTHOR ^

Bernhard Schmalhofer - <Bernhard.Schmalhofer@gmx.de>


parrot