/**
  * return Compiler
  */
 public function create()
 {
     $aCompiler = parent::create();
     $aCompiler->registerGenerator("org\\jecat\\framework\\lang\\compile\\object\\Token", "org\\jecat\\framework\\lang\\compile\\generators\\translater\\JavascriptTranslater");
     $aCompiler->interpreter("org\\jecat\\framework\\lang\\compile\\interpreters\\oop\\SyntaxScanner")->addParser(new HereDocParser());
     return $aCompiler;
 }
Example #2
0
 public static function createAspectsFromCode($sSource, $sAspectName = null)
 {
     eval($sSource);
     $aClassCompiler = CompilerFactory::singleton()->create();
     $aAspectTokens = $aClassCompiler->scan(new InputStreamCache('<?php ' . $sSource . ' ?>'));
     $aClassCompiler->interpret($aAspectTokens);
     if ($sAspectName === null) {
         $arrAspects = array();
         foreach ($aAspectTokens->classIterator() as $aClassToken) {
             $arrAspects[] = self::createFromToken($aClassToken);
         }
         return $arrAspects;
     } else {
         if ($aClassToken = $aAspectTokens->findClass($sAspectName)) {
             return self::createFromToken($aClassToken);
         } else {
             return null;
         }
     }
 }
Example #3
0
 private function parseAspectClass($sAspectClass)
 {
     if (!($sClassFile = ClassLoader::singleton()->searchClass($sAspectClass, Package::nocompiled))) {
         throw new Exception("注册到AOP中的Aspace(%s)不存在; Aspace必须是一个有效的类", $sAspectClass);
     }
     $aClassCompiler = CompilerFactory::singleton()->create();
     $aTokenPool = $aClassCompiler->scan($sClassFile);
     $aClassCompiler->interpret($aTokenPool);
     if (!($aClassToken = $aTokenPool->findClass($sAspectClass))) {
         throw new Exception("根据 class path 搜索到class的定义文件:%s,但是该文件中没有定义:%s", array($sAspectClass, $sClassFile, $sAspectClass));
     }
     $this->aspects()->add(Aspect::createFromToken($aClassToken, $sClassFile));
 }