main

File main.str
Author Eric Bouwers
Since unknown

reflect/files main-file

Strategies for including and requiring files as inPHP. It adds the ATerms of the files to the environment.




Statistics


General
Lines of code 143
Stratego
Module number 1 (0% documented)
Constructor number 0
Overlay number 0
Strategy number 16 (0% documented)
Rule number 0
DynamicRule number 0



Strategy summary


find-php-file Takes a filename and searches for this filename in the same way that PHP looks for the files to include main.str
get-current-php-file Section to store current file being processed main.str
include-and-require-files n/a main.str
include-php-file(Strategy s) Real inclusion of a filename and a strategy that must be applied to the included and parsed file main.str
process-inclusion(Strategy s) Processes the inclusion of a filename main.str
set-current-php-file Sets the name of the file currently being processed main.str

Rule summary


process-include(Strategy s) The real inclusion main.str
process-include(Strategy s) n/a main.str
process-include-and-require-files(Strategy s) Process and inclusion of files main.str
process-include-and-require-files(Strategy s) n/a main.str
process-include-and-require-files(Strategy s) n/a main.str
process-include-and-require-files(Strategy s) n/a main.str
process-include-and-require-files(Strategy s) Two special functions that we need to handle main.str



Strategy details


ATerm find-php-file
File main.str
Author unknown
Since unknown
 

Takes a filename and searches for this filename in the same way that PHP looks for the files to include.


type filename::String -> absolutepath::String

 
ATerm get-current-php-file
File main.str
Author unknown
Since unknown
 

Section to store current file being processed



 
ATerm include-php-file(Strategy s)
File main.str
Author unknown
Since unknown
 
Parameters
Strategy s s: AST -> AST

Real inclusion of a filename and a strategy that must be applied tothe included and parsed file.


type filename::String -> Inclusionid

 
ATerm process-inclusion(Strategy s)
File main.str
Author unknown
Since unknown
 
Parameters
Strategy s s: AST -> AST

Processes the inclusion of a filename. The strategy hasthe same semantics as within PHP. The file is looked-up withinthe current directory. When this fails and the filename is not relativethe file is looked up within the current directory.

The strategy 's' is applied to the newly parsed AST after which thenew AST is added to the current environment.

precondition: There must be an environment


type filename::String -> Inclusionid

 
ATerm set-current-php-file
File main.str
Author unknown
Since unknown
 

Sets the name of the file currently being processed



 

Rule details


ATerm process-include(Strategy s)
File main.str
Author unknown
Since unknown
 

The real inclusion. The first two rules only work on direct single- or doublequotedstrings with nothing fancy. Other rules can be added that take care of otherscenario's.



 
ATerm process-include-and-require-files(Strategy s)
File main.str
Author unknown
Since unknown
 

Process and inclusion of files. This rule finds the statementsthat should be processed.Note that this is a simple strategy. It includes all filesthat are directly accessiable to the environment. For a moreenhanced version see the analysis for constant propogation.



 
ATerm process-include-and-require-files(Strategy s)
File main.str
Author unknown
Since unknown
 

Two special functions that we need to handle.- chdir: changes working directory- ini-set: sets the include path if first argument is 'include_path'