jomike::j_value Symbol_Component_List::derived_get_value(const Arguments& i_args)const{ assert(i_args.empty()); (void)i_args; //Symbol List getting the value is just getting the value of the last statement if(M_components.empty()){ throw J_Symbol_Error("Trying to get value from empty Symbol List!"); } J_Symbol_Scope new_scope(&symbol_scope()); j_value return_val = j_value(string(), J_Unit()); try{ for(auto symbol : M_components){ auto symbol_ptr = dynamic_cast<j_symbol*>(symbol); if(symbol_ptr){ symbol_ptr->get_value(); } } } catch(J_Routine_Transfer_Exception& e){ return_val += e.value(); } auto last_symbol = dynamic_cast<j_symbol*>(M_components.back()); if(!last_symbol){ throw J_Value_Error("Trying to get value from non j_symbol type. "); } return return_val; }
inline child launch(const Executable &exe, const Arguments &args, const Context &ctx) { detail::file_handle fhstdin, fhstdout, fhstderr; BOOST_ASSERT(!args.empty()); BOOST_ASSERT(!ctx.work_directory.empty()); #if defined(BOOST_POSIX_API) detail::info_map infoin, infoout; if (ctx.stdin_behavior.get_type() != stream_behavior::close) { detail::stream_info si = detail::stream_info(ctx.stdin_behavior, false); infoin.insert(detail::info_map::value_type(STDIN_FILENO, si)); } if (ctx.stdout_behavior.get_type() != stream_behavior::close) { detail::stream_info si = detail::stream_info(ctx.stdout_behavior, true); infoout.insert(detail::info_map::value_type(STDOUT_FILENO, si)); } if (ctx.stderr_behavior.get_type() != stream_behavior::close) { detail::stream_info si = detail::stream_info(ctx.stderr_behavior, true); infoout.insert(detail::info_map::value_type(STDERR_FILENO, si)); } detail::posix_setup s; s.work_directory = ctx.work_directory; child::id_type pid = detail::posix_start(exe, args, ctx.environment, infoin, infoout, s); if (ctx.stdin_behavior.get_type() == stream_behavior::capture) { fhstdin = detail::posix_info_locate_pipe(infoin, STDIN_FILENO, false); BOOST_ASSERT(fhstdin.valid()); } if (ctx.stdout_behavior.get_type() == stream_behavior::capture) { fhstdout = detail::posix_info_locate_pipe(infoout, STDOUT_FILENO, true); BOOST_ASSERT(fhstdout.valid()); } if (ctx.stderr_behavior.get_type() == stream_behavior::capture) { fhstderr = detail::posix_info_locate_pipe(infoout, STDERR_FILENO, true); BOOST_ASSERT(fhstderr.valid()); } return child(pid, fhstdin, fhstdout, fhstderr); #elif defined(BOOST_WINDOWS_API) detail::stream_info behin = detail::stream_info(ctx.stdin_behavior, false); if (behin.type_ == detail::stream_info::use_pipe) fhstdin = behin.pipe_->wend(); detail::stream_info behout = detail::stream_info(ctx.stdout_behavior, true); if (behout.type_ == detail::stream_info::use_pipe) fhstdout = behout.pipe_->rend(); detail::stream_info beherr = detail::stream_info(ctx.stderr_behavior, true); if (beherr.type_ == detail::stream_info::use_pipe) fhstderr = beherr.pipe_->rend(); STARTUPINFOA si; ::ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); detail::win32_setup s; s.work_directory = ctx.work_directory; s.startupinfo = &si; PROCESS_INFORMATION pi = detail::win32_start(exe, args, ctx.environment, behin, behout, beherr, s); if (!::CloseHandle(pi.hThread)) boost::throw_exception(boost::system::system_error(boost::system::error_code(::GetLastError(), boost::system::get_system_category()), "boost::process::launch: CloseHandle failed")); return child(pi.dwProcessId, fhstdin, fhstdout, fhstderr, detail::file_handle(pi.hProcess)); #endif }