void InputConverterOPEquilibria::convert(std::istream& i, std::ostream& o) { InputParser p; p.parse(i, pcd.mcs()); writeProgram(o, pcd.mcs()); }
void Bank::getXml( Program* program, ostringstream& result ) { if( program ) { Document doc; Element* element = writeProgram( program ); doc.LinkEndChild( element ); result << doc; } }
std::unique_ptr<UnitEmitter> compile( const char* filename, const MD5& md5, folly::StringPiece code, AsmCallbacks* callbacks ) { if (RuntimeOption::EvalHackCompilerReset && m_compilations > RuntimeOption::EvalHackCompilerReset) { stop(); } if (!isRunning()) { start(); } std::string prog; std::unique_ptr<Unit> u; try { m_compilations++; writeProgram(filename, md5, code); prog = readProgram(); return assemble_string( prog.data(), prog.length(), filename, md5, false /* swallow errors */, callbacks ); } catch (CompileException& ex) { stop(); if (m_options.verboseErrors) { Logger::FError("ExternCompiler Error: {}", ex.what()); } throw; } catch (std::runtime_error& ex) { if (m_options.verboseErrors) { auto const msg = folly::sformat( "{}\n" "========== PHP Source ==========\n" "{}\n" "========== ExternCompiler Result ==========\n" "{}\n", ex.what(), code, prog); Logger::FError("ExternCompiler Generated a bad unit: {}", msg); // Throw the extended message to ensure the fataling unit contains the // additional context throw std::runtime_error(msg); } throw; } }
void Bank::save( const string& p, bool saveCurrent, bool backup ) { string path = p.empty() ? path_ : p; if( path.empty() ) return; if( saveCurrent ) saveCurrentProgram(); if( backup ) makeBackup(); Document doc; Declaration* declaration = new Declaration( "1.0", "", "no" ); doc.LinkEndChild( declaration ); Element* bankElement = new Element( "Bank" ); bankElement->SetAttribute( "name", name_ ); bankElement->SetAttribute( "program", programNum_ ); for( UINT32 i=0; i<size(); i++ ) { Program* program = at( i ); if( program->empty() == false ) { Element* programElement = writeProgram( program ); bankElement->LinkEndChild( programElement ); } } doc.LinkEndChild( bankElement ); try { doc.SaveFile( path ); path_ = path; } catch( const exception& e ) { TRACE( e.what() ); } doc.Clear(); }
std::unique_ptr<UnitEmitter> compile( const char* filename, const MD5& md5, folly::StringPiece code, const Native::FuncTable& nativeFuncs, bool forDebuggerEval, AsmCallbacks* callbacks ) { if (!isRunning()) { start(); } std::string prog; std::unique_ptr<Unit> u; try { m_compilations++; StructuredLogEntry log; log.setStr("filename", filename); int64_t t = logTime(log, 0, nullptr, true); writeProgram(filename, md5, code, forDebuggerEval); t = logTime(log, t, "send_source"); prog = readResult(&log); t = logTime(log, t, "receive_hhas"); auto ue = assemble_string(prog.data(), prog.length(), filename, md5, nativeFuncs, false /* swallow errors */, callbacks ); logTime(log, t, "assemble_hhas"); if (RuntimeOption::EvalLogExternCompilerPerf) { StructuredLog::log("hhvm_detailed_frontend_performance", log); } return ue; } catch (CompileException& ex) { stop(); if (m_options.verboseErrors) { Logger::FError("ExternCompiler Error: {}", ex.what()); } throw; } catch (CompilerFatal& ex) { // this catch is here so we don't fall into the std::runtime_error one throw; } catch (FatalErrorException&) { // we want these to propagate out of the compiler throw; } catch (AssemblerUnserializationError& ex) { // This (probably) has nothing to do with the php/hhas, so don't do the // verbose error handling we have in the AssemblerError case. throw; } catch (AssemblerError& ex) { if (m_options.verboseErrors) { auto const msg = folly::sformat( "{}\n" "========== PHP Source ==========\n" "{}\n" "========== ExternCompiler Result ==========\n" "{}\n", ex.what(), code, prog); Logger::FError("ExternCompiler Generated a bad unit: {}", msg); // Throw the extended message to ensure the fataling unit contains the // additional context throw AssemblerError(msg); } throw; } catch (std::runtime_error& ex) { if (m_options.verboseErrors) { Logger::FError("ExternCompiler Runtime Error: {}", ex.what()); } throw; } }