// Run a file: .x file[(args)] bool MetaProcessor::executeFile(llvm::StringRef file, llvm::StringRef args, StoredValueRef* result, Interpreter::CompilationResult* compRes /*=0*/) { // Look for start of parameters: typedef std::pair<llvm::StringRef,llvm::StringRef> StringRefPair; StringRefPair pairPathFile = file.rsplit('/'); if (pairPathFile.second.empty()) { pairPathFile.second = pairPathFile.first; } StringRefPair pairFuncExt = pairPathFile.second.rsplit('.'); Interpreter::CompilationResult interpRes = m_Interp.loadFile(file); if (interpRes == Interpreter::kSuccess) { std::string expression = pairFuncExt.first.str() + "(" + args.str() + ")"; m_CurrentlyExecutingFile = file; bool topmost = !m_TopExecutingFile.data(); if (topmost) m_TopExecutingFile = m_CurrentlyExecutingFile; interpRes = m_Interp.process(expression, result); m_CurrentlyExecutingFile = llvm::StringRef(); if (topmost) m_TopExecutingFile = llvm::StringRef(); } if (compRes) *compRes = interpRes; return (interpRes != Interpreter::kFailure); }
MetaSema::ActionResult MetaSema::actOnxCommand(llvm::StringRef file, llvm::StringRef args, Value* result) { MetaSema::ActionResult actionResult = actOnLCommand(file); if (actionResult == AR_Success) { // Look for start of parameters: typedef std::pair<llvm::StringRef,llvm::StringRef> StringRefPair; StringRefPair pairPathFile = file.rsplit('/'); if (pairPathFile.second.empty()) { pairPathFile.second = pairPathFile.first; } StringRefPair pairFuncExt = pairPathFile.second.rsplit('.'); std::string expression = pairFuncExt.first.str() + "(" + args.str() + ")"; if (m_Interpreter.echo(expression, result) != Interpreter::kSuccess) actionResult = AR_Failure; } return actionResult; }