summaryrefslogtreecommitdiff
path: root/poc
diff options
context:
space:
mode:
Diffstat (limited to 'poc')
-rw-r--r--poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php21
-rw-r--r--poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php27
2 files changed, 29 insertions, 19 deletions
diff --git a/poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php b/poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php
index 1bc7bce..117324d 100644
--- a/poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php
+++ b/poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php
@@ -120,14 +120,14 @@ abstract class AbstractWeaver {
if ($k instanceof PHPParser_Node_Scalar_String && $v instanceof PHPParser_Node_Scalar_String) {
$k=$k->value;
$v=$v->value;
- dbg(0,"Found '$k' => '$v'");
+// dbg(0,"Found '$k' => '$v'");
$constants[$k]=$v;
}
} else {
- dbg(0,"Skipped funcall: " . $this->prettyPrinter->prettyPrint(array($stmt)));
+// dbg(0,"Skipped funcall: " . $this->prettyPrinter->prettyPrint(array($stmt)));
}
} else {
- dbg(0,"Skipped : " . get_class($stmt));
+// dbg(0,"Skipped : " . get_class($stmt));
}
}
return $constants;
@@ -247,6 +247,21 @@ abstract class AbstractWeaver {
return $found;
}
+ public function parseAndCacheSourceTree($sourcetree_path, $cache_path, $regexMatch, $regexPrune, $env, $traverser=null) {
+ $filelist=$this->findAllFiles($sourcetree_path, $regexMatch, $regexPrune);
+ foreach ($filelist as $f) {
+ $cache_filepath=$cache_path . "/" . sha1($f) . "-" . substr(sha1(print_r($env,true)),-8,8) . ".ast";
+ // If the cache is already up to date, skip parsing
+ if ( $stat_cache=@stat($cache_filepath) ) {
+ $stat_source=stat($f);
+ if ($stat_cache['mtime'] >= $stat_source['mtime'] ) continue;
+ }
+
+ $ast=$this->parseAndWalk($f, $traverser, $env);
+ $this->serializeAST($ast, $f, $cache_filepath);
+ }
+ }
+
// Framework specific code
abstract public function detectFramework($sourcetree_rootpath);
abstract public function parseFrameworkConfig($fw_props);
diff --git a/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php b/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php
index 198b113..8439670 100644
--- a/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php
+++ b/poc/poc02-compiling-cake/src/php-weave/cakephp_weaver.class.php
@@ -23,32 +23,27 @@ class CakePHPWeaver extends AbstractWeaver {
}
public function parseFrameworkConfig($fw_props) {
+ // TODO : Not used for the moment...
return array();
}
public function parseFrameworkCode($fw_props, $fw_conf, $cache_path) {
- $filelist=$this->findAllFiles($fw_props['CAKE_CORE_INCLUDE_PATH'], '/(\.php|\.ctp)$/', '/^\.svn$/');
- //print_r($filelist);
-
- $env=$fw_props; //TODO : More things here ?
- foreach ($filelist as $f) {
- $cache_filepath=$cache_path . "/" . sha1($f) . "-" . substr(sha1(print_r($env,true)),-8,8) . ".ast";
- // If the cache is already up to date, skip parsing
- if ( $stat_cache=stat($cache_filepath) ) {
- $stat_source=stat($f);
- if ($stat_cache['mtime'] >= $stat_source['mtime'] ) continue;
- }
-
- $ast=$this->parseAndWalk($f, null, $env);
- $this->serializeAST($ast, $f, $cache_filepath);
- }
+ dbg(0,"Parsing and caching all framework code");
+ $fwdir=$fw_props['CAKE_CORE_INCLUDE_PATH'];
+ $this->parseAndCacheSourceTree($fwdir, $cache_path, '/(\.php|\.ctp)$/', '/^(\.svn|Test|TestSuite)$/', $fw_props, null);
+ return array(); //$fw_extra is unused
}
public function parseApplicationCode($fw_props, $fw_conf, $fw_extra, $cache_path) {
-
+ dbg(0,"Parsing and caching all application code");
+ $appdir=$fw_props['ROOT'] . $fw_props['DS'] . $fw_props['APP_DIR'];
+ $this->parseAndCacheSourceTree($appdir, $cache_path, '/(\.php|\.ctp)$/', '/^\.svn$/', $fw_props, null);
+ return array(); //$app_extra is unused
}
public function computePageList($fw_props, $fw_conf, $fw_extra, $app_extra) {
+ dbg(0,"Computing pagelist");
+ //TODO Not yet implemented
return array(
'page1' => array(),
'page2' => array(),