Pash-Project/Pash — pull request #178 by sburnicki (2013-11-19 12:32:49+00:00)
Title: Second step of scope integration: Functions, Aliases, Refacoring

This is the second big step of implementing scopes in Pash.
The major changes are the following:
* FunctionIntrinsics and AliasIntrinsics were introduced, s.t. function and aliases
are handled analogously to variables and drives.
Note: All the *Intrinsics classes need to be a little extended if the Providers /
cmdlets are updated to use them. But this shouldn't be hard any more, because
of the next point.

* The class SessionStateScope, which was introduced in the last step, was changed to
be generic and always refer to a specific type of items.
This approach was chosen, because the *Intrinsics classes are all specified a little
differently with different details. To avoid a lot of duplicate code, the core
methods are now directly in SessionStateScope, only the details (or wrapper functions)
are exposed in the *Intrinsic classes.
To review that class it's probably easier to just look at the complete new class instead of
checking the diff. It also includes an iterator to iterate through the scope hierarchy.

* The interface IScopedItem was introduced in oder to make AliasInfo, PSVariable, PSDriveInfo,
and FunctionInfo all usable by the new SessionStateScope implementation.

* The tests however still refer to the *Intrinsics classes, though they share mostly common
functionality. However, these classes count in the end and bring slightly differences,
so this makes sense.

* Some Exception classes were implemented in order to be used.

* First necessary changes in the cmdlets were done, in order to be able to integrate the
new architecture. However, they still need some refinement in order to support all features

* The CommandManager now always need an ExecutionContext in order to instantiate. This is
necessary in the new architecture and does make sense, as the SessionState is part of
the ExecutionContext and it provides information about available aliases and providers.
Therfore the provider intialization was moved to SessionStateGlobal, for now.
Later on, also the Providers should be handled by SessionState.Provider (ProviderIntrinsics,
see specification), but are no scoped items.

All tests run without errors, on both windows and linux. I also tested some basic work in Pash,
and didn't face any problems.

Upcoming steps:
* Make sure new scopes are created when scripts, functions or scriptblocks are executed
* Take another look at the existing cmdlets and refine some
* Make functions work with parameters

Sorry for the huge diff, but that's what it took to implement it properly ;-)