Skip to content
Browse files

refactor($parse): new and more performant $parse

Change the way parse works from the old mechanism to a multiple stages
parsing and code generation. The new parse is a four stages parsing
* Lexer
* AST building
* AST processing
* Cacheing, one-time binding and `$watch` optimizations

The Lexer phase remains unchanged.

AST building phase follows Mozilla Parse API [1] and generates an AST that
is compatible. The only exception was needed for `filters` as JavaScript
does not support filters, in this case, a filter is transformed into a
`CallExpression` that has an extra property named `filter` with the value
of `true`.

The AST processing phase transforms the AST into a function that can be
executed to evaluate the expression. The logic for expressions remains
unchanged. The AST processing phase works in two different ways depending
if csp is enabled or disabled. If csp is enabled, the processing phase
returns pre-generated function that interpret specific parts of the AST.
When csp is disabled, then the entire expression is compiled into a single
function that is later evaluated using `Function`. In both cases, the
returning function has the properties `constant`, `literal` and `inputs`
as in the previous implementation. These are used in the next phase to
perform different optimizations.

The cacheing, one-time binding and `$watch` optimizations phase remains
mostly unchanged.

  • Loading branch information
lgalfaso committed Jan 31, 2015
1 parent 2003fcf commit 0d424263ead16635afb582affab2b147f8e71626
Showing with 2,820 additions and 566 deletions.
  1. +1,193 −556 src/ng/parse.js
  2. +3 −3 src/ng/rootScope.js
  3. +1,624 −7 test/ng/parseSpec.js

0 comments on commit 0d42426

Please sign in to comment.
You can’t perform that action at this time.