summaryrefslogtreecommitdiff
path: root/poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php
diff options
context:
space:
mode:
authorLudovic Pouzenc <ludovic@pouzenc.fr>2012-08-03 19:15:04 +0000
committerLudovic Pouzenc <ludovic@pouzenc.fr>2012-08-03 19:15:04 +0000
commit537fb688fe12b04df433da95e8a68f0b89d70ebd (patch)
tree5d522b7c6c81af50ccf20685c55260a75691050a /poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php
parent7c4143798b972dc5bbf566e023e47e575a548409 (diff)
download2012-php-weave-537fb688fe12b04df433da95e8a68f0b89d70ebd.tar.gz
2012-php-weave-537fb688fe12b04df433da95e8a68f0b89d70ebd.tar.bz2
2012-php-weave-537fb688fe12b04df433da95e8a68f0b89d70ebd.zip
Parsing du code applicatif. Fractorisé avec le parsing du code du Framework, ajout d'un pruning pour les batteries de tests de CakePHP lui-même.
git-svn-id: file:///var/svn/2012-php-weave/trunk@14 d972a294-176a-4cf9-8ea1-fcd5b0c30f5c
Diffstat (limited to 'poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php')
-rw-r--r--poc/poc02-compiling-cake/src/php-weave/abstract_weaver.class.php21
1 files changed, 18 insertions, 3 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);