Ejemplo n.º 1
0
 /**
  * @depends testCompile
  */
 public function testReading($wamFile)
 {
     $p = CodeReader::readProgram($wamFile);
     $tempFile = tempnam('.', 'wam');
     CodeReader::writeProgram($p, $tempFile);
     $this->assertFileEquals($wamFile, $tempFile);
     unlink($wamFile);
     unlink($tempFile);
 }
Ejemplo n.º 2
0
 /**
  * Load WAM Code
  *
  * @param string $fileName
  */
 protected function load($fileName)
 {
     $prog = CodeReader::readProgram($fileName);
     if ($prog == null) {
         if (false === strpos($fileName, ".wam")) {
             // if compilation didn't work, try with different file extension
             $this->writeLn("File \"" . $fileName . "\" could not be opened.");
             $this->writeLn("Trying \"" . $fileName . ".wam\" instead.");
             $prog = CodeReader::readProgram($fileName . ".wam");
         }
     }
     if ($prog == null) {
         $this->backtrack();
     } else {
         $this->p->addProgram($prog);
         $this->p->updateLabels();
         $this->programCounter++;
     }
 }